Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

How do I get my 5v?

Status
Not open for further replies.
Hi,
I'm very new at programming pic controllers, in fact this is my first project. I don't have a lot of knowledge about electronics and micro controllers on a count that I'm still at secondary school.

What I'm trying to achieve is to move a servo using a pic 16F627 on a K8048 Programming board. [*dunno if this will help :) ]

I think i've got my pulses right (PortB), the problem is the output is only 2.93 volts whereas my servo requires 5 volts to recognize the signal.

My data sheet says the PIC can output 3.0 - 5.5 volts

I've read the instructions that came with my kit for some help on changing the voltage; no luck. So I'm stumped.

Really some general help would be appreciated, as in what am looking to alter? Am I supposed to select the voltage with the Pic controller in the code (using assembly btw)? Or do I control my output voltage by changing the resistors?

Thanks

Got a link https://www.electronickits.com/kit/complete/prog/vek8048operate.pdf
 
Last edited:
If you're using a regular multi meter to measure the servo output getting 2.93 volts is perfectly normal. The pulses coming from a PIC are 5 volt (if you're using a 5 volt supply) but they're not on all the time and the multi-meter tends to average things, so what you're actually seeing is a 5 volt signal that's on about half of the time, sounds normal to me. Keep in mind PICs can output 5 volts but only very low currents, so while it can drive the servo's signal line it can not power the servo itself. The servo will have to get it's power directly from a 3-6 volt power supply, make sure the servo shares a common ground with the PIC board. If you're still having trouble figuring things out after you read this post give us some more details, and since you don't sound like a schematic using kind of fellow take a handful of good (in focus) well light digital photos of how yuo have thing setup and we might be able to help.
After looking at the link you posted your board accepts a 15V supply, so do NOT directly connect the servo to a 15V power supply, or you'll fry the servo's electronics, and possibly the pic.
 
Last edited:
instead of controlling it straight put a transistor on the pic pin and connect the servo to it and 5v also so you toggle the transistor which in turn controls the servo. I think you would need a mosfet. But heh im not 100% sure not even 20% sure :D but at least its a though.
 
i think a pullup would not be good becuase there would be constand voltage/current on the servo then meaning it would move all the time. or jitter at most.
 
I was just thinking the servo inputs might be loading the PIC down. A small pullup might just get the high to (near) 5v, whilst still allowing the PIC outputs to go to 0v low. It would need suck it an see experimentation
 
Instead of controlling it straight put a transistor on the pic pin and connect the servo to it and 5v also so you toggle the transistor which in turn controls the servo. I think you would need a mosfet. But heh im not 100% sure not even 20% sure but at least its a thought.
Umm... Jason. Have you ever controlled a servo with a microcontroller? Very weird advice! :p Maybe I just don't get what you're talking about.

Anyway, ColinTheProgrammer, here's a diagram to wire a typical servo:
**broken link removed**
Now the notes to go with the above image:

1. The wire colors are not necessarily correct if your servo is not a Futaba, but those colors are very common. If you're unsure, Google for the proper colors for your brand/model of servo. There will be a power, a ground and a control wire.

2. The servo power should usually come from a different source than the one that supplies your MCU, and should be between 4.8V and 6V. 4.8V is the voltage of a stock battery pack when you buy a radio to fly your airplane/car/boat (or whatever). Servos can handle a bit more juice, but if you go much past 6V you risk cooking the servo.

If your MCU power supply can supply enough power without sagging and resetting the MCU when the servo moves, then you can use that. Either way the grounds MUST be common, as shown in the diagram.

3. The control line can be connected directly to the MCU pin. It's a logic line, and is made for that. Don't worry about the voltage. Your PIC puts out 5V on a pin when it's set high, provided the PIC is being supplied with 5V (it almost certainly is). The servo should receive a high pulse approximately every 20mS. That pulse should be approximately 1.5mS for center, 1mS for full counter-clockwise (CCW) and 2mS for full CW rotation, and of course varying durations between those for the full range of motion. Your servo may vary a bit, so test it.

For example: Say you want to drive the servo fully CW. Your program should send a 2mS high pulse and then 18mS of low, over and over, constantly to hold the servo in that position. This is called a pulse-train. To drive it to center and hold it there the MCU should constantly send a 1.5mS high pulse and then 18.5mS of low.

Listen closely when it's rotated fully in each direction. If it's buzzing it may be stalled against the end stops. This eats a lot of power and is hard on the servo, so adjust your pulse duty cycle until it stops.

If you can understand C, here's an ultra-simple demo program in BoostC for 18F448 that shows how it's done for two servos, on RB0 and RC3. This is NOT how you would normally control a servo. It's only a demo. It uses delays to do the pulses. Normally you'd use timers and interrupts so you can get something else done while driving the pulse-train controlling the servo in the background.
Code:
#include <system.h>
#pragma CLOCK_FREQ 20000000
#pragma DATA    _CONFIG1H, _HS_OSC_1H
#pragma DATA    _CONFIG2H, _WDT_OFF_2H
#pragma DATA    _CONFIG4L, _LVP_OFF_4L

void main(void)
{
	int i;
	trisb=trisc=0;
	while(1){
		for(i=0;i<50;i++){		//50 pulses 1.5mS - center
			latb.0=1;
			latc.3=1;
			delay_ms(1);
			delay_us(200);
			latb.0=0;
			latc.3=0;
			delay_ms(18);
			delay_100us(5);
		}
		delay_ms(100);

		for(i=0;i<50;i++){		//50 pulses 1mS - cw
			latb.0=1;
			latc.3=1;
			delay_100us(3);
			delay_us(80);
			latb.0=0;
			latc.3=0;
			delay_ms(18);
			delay_100us(7);
		}
		delay_ms(100);

		for(i=0;i<50;i++){		//50 pulses 1.5mS - center
			latb.0=1;
			latc.3=1;
			delay_ms(1);
			delay_us(200);
			latb.0=0;
			latc.3=0;
			delay_ms(18);
			delay_100us(5);
		}
		delay_ms(100);

		for(i=0;i<50;i++){		//50 pulses 2mS - ccw
			latb.0=1;
			latc.3=1;
			delay_ms(2);
			latb.0=0;
			latc.3=0;
			delay_ms(18);
		}
		delay_ms(100);
	}
}
 
Last edited:
Add pull up resistors to the PIC outputs, to help them get to 5v.
I was just thinking the servo inputs might be loading the PIC down. A small pullup might just get the high to (near) 5v, whilst still allowing the PIC outputs to go to 0v low. It would need suck it an see experimentation
No, and no. Don't do that. Unnecessary, and probably will make your servo not work at all.
 
hey futz no i never did but i also never claimed i did :D I was truthful about not knowing but at least i tried to help. I was right about the pullup i presume tho :)

From my other post:
ut heh im not 100% sure not even 20% sure but at least its a thought.
 
If you power your servo right you can't load your pic down . The only way to load down the pic is to try to power from a port of the pic to the servo with out and switching transistor or relay. The pic can only source or sink so much power
Maximum output current sunk by any I/O pin..........................................................................................................25 mA
Maximum output current sourced by any I/O pin ....................................................................................................25 mA

Maximum current sunk by PORTA and PORTB (Combined)................................................................................200 mA
Maximum current sourced by PORTA and PORTB (Combined)...........................................................................200 mA
pullups bad ideal
 
futz Your right I'm sorry I some how posted to the wrong form I was reading more then 1 sorry I posted the stepper on the wrong thread I was fixing a PS/2 power supply and didn't look where I posted.
 
I'm using an Acoms AS-12 analogue servo.

A little update I tried just putting port B high so it's constantly on and that comes out as 2.93v. When the pulses are running it's only at 0.14v when my pulses run.

I'm gonna look through all your post once my homework is clear :). Thanks for all your advice i'll keep you posted.
 
K8048 Programming board how are you using this to run your servo where did you hook your 3 wire coming from your servo? In a socket. That board has no header pins to play with and jumpers to change sockets and no real place to get your vdd and vss
 
Ok I think with your help I have solved my problem.

After reading your posts, and using futz's circuit diagram, I started poking the voltmeter in different places. (Educated guesses using futz's diagram and the diagram of my pic **broken link removed**) It turns out that really there was nothing wrong with the program code or setup...

I had the negative of the servo connected to the negative of the +5v battery cell instead of ground. (First thing mentioned by Sceadwian and again by others later) So thanks for that one :) !

But also the reason I wasn't getting a +5v signal was because I connected the signal wire on the servo to the resistor by LD1 (**broken link removed**)

So now I've tried it again, connecting the servo negative (and the battery negative) to VSS (pin 5) and the signal wire to RB0 (pin 6) and I'm pleased to report the servo has moved to a position near center and opposes me moving it.
Now I'm going to play with the code and attempt to get the servo in different places.

I would like to thank you all for you opinions, ideas and generally the enthusiasm I received from you all.

Thanks for the time you spent helping me :)
 
If he is trying to run a servo from the programmer the Voltage Regulator that is on it can't put out the power he needs to run it. It is using UA7805 voltage regulator with 100ma output you'll have to power your servo with power supply of it's own
 
Status
Not open for further replies.

Latest threads

Back
Top