83Views17Replies

Author Options:

Controlling a servo with a Micro-controller? Answered

So I decided to spend some time to make a "gimbal" in a very loose sense. Basically I was experimenting using a square wave oscillator to generate the correct PWM to have a servo rotate between 0 and 180 degrees when a tilt sensor is tripped. After some research multiple sites said having a 1ms pulse every 20ms would have it move to the 0 degree position. Great so I will make a oscillator pulses ~1ms on one side and 19ms on the other. However this does not seem to be working. I am curious if it is a fault in my math or if the tolerance on the parts I am using are just too wide to be any good. Here is a diagram of my set-up with the values a came up with. One spot that may be weak is that I just notice someone somewhere mentioned using 50Hz for the timing I just used that number when I calc my figures. Any feedback?

 Also a side note is that I have been able to move the servo in one direction only and by accident ( in fact it's what inspired this project) when C1 & C2 were 2.2nF and the R1 & R2 were 10k potentiometers that I turned until something happened. Now that I am trying on purpose no results. 

Discussions

0
None
Jayccob

2 years ago

Mistake in the title suppose to be "Without" a micro-controller.

0
None
icengJayccob

Answer 2 years ago

A 555 is only an RC timer oscillator

555-Pinout-2.gif
0
None
rickharris

2 years ago

This version gives you continious control from the 555

ServoController.gif
0
None
Jayccobrickharris

Answer 2 years ago

Never thought of using the 555 timer. I will give that a go and let you know how it turns out.

0
None
iceng

2 years ago

I have not tested this. Servos need 5 to 6 VDC.

Like your Flip Flop the 555 makes the waveform u seek.

Be sure to click on the pic to see the whole image.

servoTest.gif
0
None
Jayccobrickharris

Answer 2 years ago

It is easier to buy a tester or use a micro-controller, but that isn't the point to be honest. I am doing this to help with my electronic skills and for fun. I came across discussion of something similar for low budget projects, but nothing further because they just broke down and got a controller.

0
None
rickharrisJayccob

Answer 2 years ago

a servo needs 5 to 6 volts to drive it.

0
None
Jayccobrickharris

Answer 2 years ago

The image above says 1.5v but I am actually using 3v (two AA in series) and has been working, but for experimentation I can throw a 9v on it.

0
None
rickharrisJayccob

Answer 2 years ago

As in my diagram below I would ALWAYS use a seperate power supply for the servo fro the elcetronics, common the ground supply.

0
None
rickharrisrickharris

Answer 2 years ago

Image didn't transfer. Click on image for full size.

Capture.JPG
0
None
steveastrouk

2 years ago

Signal polarity ? 1mSec high in 19 low, or 1ms low, 19 high ? It matters.

0
None
Jayccobsteveastrouk

Answer 2 years ago

Yeah single palarity. And 1 mSec high and 19Sec low. These are some of the images I came across that may help explain the PWM pulse I am attempting.

Untitled-159.jpgUntitled-165.jpg
0
None
steveastroukJayccob

Answer 2 years ago

Have you measured the timing ? Its pretty critical. If your signal is 1.1mSec, in 22, it won't like it. There are good reasons to digitally synthesise it.

0
None
Jayccobsteveastrouk

Answer 2 years ago

Ok, I did a little experimenting with the design that I know can move the servo in one direction, and drew up the math so you can see it. In case you are unfamiliar with the equation. T= total time, t1= HIGH time of the left transistor, t2= HIGH time of the right transistor. All three of those values must be in Seconds. C1 and C2 are the capacitor values of their respective transistor, must be represented in Farads. Then R1 and R2 are the resistors for the capacitors in Ohms.

At this point I am wondering if reworking the values for microseconds may be the answer. Any thoughts?

Math.png
0
None
Jayccobsteveastrouk

Answer 2 years ago

The only thng I have been able to do it calculate the needed number, chose the closest values I have then re-calculate the numbers using those values. I have gotten it down to something like .00100188 Sec on one side and .0192924 sec on the other, but this doesn't take into account the 10% my resistors or Capacitor have. I unfortunately don't have a oscilloscope to measure it any better.

0
None
JayccobJayccob

Answer 2 years ago

So to help clarify, the transistor on the left will be on for 1ms and the one on the right for 19ms back and forth. Because the control wire for the servo is only on the left transistor it should be getting power for that 1ms every 20ms created the hoped for effect.