Maker Pro
Maker Pro

PWM for Servo w/o Microcontroller

Hey everyone,

I have a nice project that the sole purpose is to control a servo w.o using a microcontroller.

I have built a sort of PWM. I dont have an schematic, just a block diagram I can upload when I get my phone back.

I am using the Parallax Servo with range of 0.75ms to 2.25ms with the center at 1.5ms.
I determined that if I want 1 degree to correspond to 1 bit (more on this later) I would need a period of 8.33uS or ~120khz. So I simply put together an astable 555 timer (with a pot for Rb) to get my desired frequency. I do have a simple solder kit function generator, but I prefer having all my components on my breadboard.

I then use a 74hc161 counter (just one for now, will need 3 to get the minimum timing of 0.75ms)
and a 74ls181 (I wanted a quick one chip solution, bought some comparators though) to compare the counter with the desired pulse length. Or more straight forward: I use the comparator mode on the 74ls181 to determine when to reset the signal based on a value I can manually input into the 74ls181 through jumper wires (for now). The A=B pin will be my output to the servo as well as the the reset (through a NOT gate) to the 74hc161 counter.

This way I can change one bit on the 74ls181 and have it correspond to 8.33uS on the pulse width, which is equal to on degree on the Parallax Servo. By one bit I mean numerically one. Obviously the 2nd bit would equal 2 degrees or 16.66uS.

"Main Issue"

The only problem I have now is: how do I synchronize this clock with a 50hz clock? The servo requires a 20ms delay between pulses.

I have thought of having a 50hz 555 timer(CLK) to control the first 555 timer (PWM) via the reset pin. When the altered PWM goes high, the CLK should be halted by the reset pin.

On the falling edge of PWM (the altered frequency) could trigger CLK to start up again, but how could I be sure that the counter (74hc161) would be reset properly? The PWM is going at 120khz which is kind of fast for most breadboard projects I have done.
Is there some better way to do this?


The main point of this project is to learn, not really doing things "easy" or whatever. I could control a Servo in 2 minutes with an Arduino or BASIC STAMP.

So ask any questions if you do not understand what I said or need clarification!
 

Harald Kapp

Moderator
Moderator
but how could I be sure that the counter (74hc161) would be reset properly?
Use the reset pin on the 161s.
The PWM is going at 120khz which is kind of fast for most breadboard projects I have done.
120 kHz can be handled by a breadboard if the wiring is neat and short and all ics are properly decoupled by a 100 nF capacitor between Vcc and GND.

Is there some better way to do this?
There are usually different ways to solve a task. Which one is better depends on the quality function used, i.e. what is "better" in your view? It could mean higher precision, less cost, less number of components, any other quality attribute or a combination thereof.
In your case you may consider using a presettable down counter (e.g. 4516B or a similar one). load it with the binary number corresponding to the length of your pulse. use the carry-out output for the pulse. Carry out indicates count = 0 thus eliminating the need for a separate comparator. Use the start signal from the 50 Hz 555 chip to set a flipflop, use carry-out to reset the flipflop. The Q-output of the flipflop will thus be active for a period corresponding to the value loaded into the down counter.
 
Thanks for your input!

I have the 74hc193 binary up/down counter

I like your method a lot and will try it out. Using less chips means less wire cutting for me, so I like this way more.

There is only one thing more:

To pre-program again I could use an OR gate with the signal from the 50hz timer and the Q output of the flipflop.
This way the counter will always start at the exact value I want.

Also, this works well with one counter with one carryout, but I will be needing three carryouts, which I guess could just be
NOR'd to the RESET of the flipflop.

Or should I consider controlling the RESET on the 555 timer?
 
There is a simple 555 servo tester over at Talkingelectronics web site.........

search for ..........talkingelectronics interactive ..........

Make certain you search for the above as shown........
I have had instances where the web site simply searched as ....talkingelectronics ...has been overridden by some wacko pill manufacturer

Scroll down on the LHS to 555 timer book, click there and an array of projects are presented.

Again run down to servo tester which will open the next set of diagrams.

Shown below is just one from a Google search to the interactive site.........

ServoTester.jpg
 

Harald Kapp

Moderator
Moderator
Also, this works well with one counter with one carryout, but I will be needing three carryouts, which I guess could just be
NOR'd to the RESET of the flipflop.
No, these counters can be cascaded and you'll have to look at the carry of the lowest counter only.
 
Alright, thanks Mr. Kapp!

You lent me an idea to create the circuit the way I had thought of. I was going to build it the way you described, but I had already ordered some 74hc682's so I decided to see if my way works.

All I had to do was have active low output from the comparator, which the 74hc682 provides (on equality), to reset the 74hct161 counters and reset a flipflop. The 50hz timer I used to send a set signal to the flipflop. The Q output of the signal would control my original clock of 120khz's reset pin.

The Q output would also function as the control signal for the servo. I measured on the oscilloscope the signals and verified everything worked out! Then I hooked up a servo and it worked!

Thanks for the help, and as far as controlling a servo with a 555 timer... I should try that out as well. It will give me more knowledge of this amazing chip!
 
The beauty is in building it yourself.

My car needs new tyres but not interested in making them myself anymore.
As for the tester, it was simply a suggestion.
If the Op has no interest then fine but I don't see why any suggestion I make should be poo pooed by anyone.
 
I built one years ago using a 556 which is just two 555's in one package. It used a frame rate of 50Hz and was fully proportional with a pot to control rotation.
 
Interesting @WHONOES

And I managed to make it, but now I am having a bit of an "electrical" issue with my build.
I included another circuit to make it compatible with an 8 bit ADC. Due to the parts I had with my immediate disposal I came up with this... and it is not letting me upload the JPG of it.
44111-a8eb39c6c7c70aeea4b497887c6b712f.jpg


edit: got it in...was way too big a picture!

oh and also the problem is when I bring the 4th bit high on the latch. The servo just swings in one direction and just gets stuck there eating up a lot of current. I really am not sure how to begin to trouble shoot this...well I did swap the latch out for a different one and that didnt change anything.
 

Attachments

  • smallerpic.jpg
    smallerpic.jpg
    29.3 KB · Views: 8
Last edited:
Top