Flashing LEDs proportion to Servo position

I have a LED array already made, complete with resistors and 9.2V battery pack. I would like to be able to flash the LED's, with the speed of the flashing based upon the position of a servo. At 0 degrees, it would be on all the time without flashing, all the way to 90 degrees with it flashing 15 or 20 times a second.

To make things harder, this is using the throttle servo from my RC car, which also controls the brakes. At 0 degrees full brakes are applied, and at around 15 degrees I think, brakes are not applied and the engine just sits there idleing. If it's just idleing at 15 degrees it would be awesome if i could get it to flash for about 2/3rd's of a second (2/3rd's on, 2/3rd's off) and then when accelorating from there go up to the 15 or 20 flashes a second. But when applying any amount of brakes (from zero to 15 degrees) I would like it to be on the entine time. Does this sound to complicated for an amature like me to do? If so then a linear change in blinking speed would be OK.

I googled around, and found out that the signal wire for servos sends the angle information via pulses. 1.25ms for 0 degrees, up to 1.75ms for 180 degrees, according to:

formatting link

However, since my servo is set up with some custom trim levels, is there any way to find out what the pulse lengths are at various stages (full brakes, idleing, full throttle) so I don't have to just guess and check over and over?

I'm fairly new to electronics, and have no idea where to even start to make this fancy "switch" for my LEDs. I was looking at my old 75-in-One Electronic Project Lab that I got for my 12th birthday, and the closest I found was a variable strobe light, which used a transistor, transformer, some resistors, and a pot, to blink a LED at different intervals depending on the rotation of the pot.

But that did it based upon the resistance, not pulses, so I am back to the beginning :(

I would like to learn as much as possible as I make this variable switch, so if it is possible, please dumb things down, so I can at least partially comprehand your idea/point, and google for more info as needed.

Thanks,

--Farrell F.

P.S. In case this information helps:

I'm using 32 LED's, wired in a series-parallel configuration. 2 LEDs + resistor in series, with 16 strings wired in parallel. The LEDs are spec'd for FV 3.0-3.4V, so aiming for 3.2V, I went with 160 ohm resistors since my power source is 9.6V. Each LED draws ~20mA, so all

32 LEDs draw ~640mA. Perhaps this information effects the components I should select to make this fancy switch?
Reply to
upgrdman
Loading thread data ...

Two options spring to mind:

  1. Convert the pulse width to a voltage using an RC filter. Then, generate the variable flash rate using a voltage controlled oscillator.
  2. Use a PIC Micro-controller. This requires fewer components because everything is done in software. The PIC measures the pulse width and generates the output pulses.

You can measure the pulse widths using an oscilloscope. However you decide to tackle it, you'll need a 'scope for a project like this.

Reply to
Andrew Holme

--
I\'ve posted a schematic for you, at:

news:e203e1l9dl58eib2qpa14ijube0gncaaqd@4ax.com

based on the data at the link you posted.  The circuit should do
everything you want, including the steady "brakes on" function.  Below
15° the LED array should be ON all the time, at idle (15°) it should
flash at about 1Hz and, at 90°, at around 16Hz.

The two one-shots (U1A and B) are adjustable so that you can set the
response of the LEDs at idle and also to avoid overrun at the high
end.  If you need a circuit description, ask and I\'ll post it.
Reply to
John Fields

i am unable to follow that URL, any chance you can e-mail me the schematic?

upgrdman at mindspring dot com

thanks

--farrell f.

Reply to
upgrdman

Thanks you so very much, John Fields. If it's not too much trouble, I would appriciate it if you would post the circuit description as well.

On a side note, I'm thinking of buying a new Electronic Project Lab. The 75-in-1 I have is limited, and I'm thinking about perhaps gettings the 500-in-1 model from Elenco. Amazon.com has some info on it, although their price is higher than most places.

formatting link

Anyone have any advice? I can barely understand anything above a basic schematic, and want to learn as much as possible, in a way that is somewhat entertaining. The 75-in-1 model I have is alright, but it's doesn't explain the "why" very well in most cases, and it doesn't get into the advanced stuff like IC programming and radio. This lab seems like a good thing to me, but I am interested if anyone has anything to say one way or another.

Thanks again,

--Farrell F.

Reply to
upgrdman

--- OK.

From the link you gave, it turns out that your servo, with an input pulse width of 1250µs corresponding to a rotation of 0° and 1500µs corresponding to 90°, will need a pulse about 1300µs wide to rotate to

15°, your approximate idle/no brakes position. Looking at the timing graphically, we have something like this:

|| _________________________ ______ T1___| |________...___________|

|| __________________________ ______ T2___| |_______...___________|

|| ______________________________ ______ T3___| |___...___________|

||

Where T1 is the input pulse with maximum braking applied, T2 is the input pulse with the engine idling and the brakes off, and T3 is the input pulse with the servo at full throttle. the 20ms time is how often the input pulse repeats, and stays constant at 20 milliseconds.

Since we have two states we want to differentiate between, (the first being when the brakes are on and the second being when they aren't) what we need is a circuit which can tell the difference between when the input pulse is less than 1300µs wide and when it's greater than

1300µs wide. U1A, (a monostable multivibrator with a period of 1300µs) U2A, (a "D" type flip-flop) U3A, (a NAND gate) and U4A (an OR gate)do that, like this:

|| __________________________ ______ U1-6___| |_______...___________| ___ ________...___________ U3-3 |_________________________| |______ _________________________ ______ U1-4___| |________...___________| ________...__________________ U2-5_____________________________| ___________________________________________________________ U4-3_____________________________|

Assuming that U2-5 starts off low, if the pulse from the servo, U1-4, goes low before U1A times out, its inverted version at U3-3 will clock the high on U2-2 through to U2-5, and U2-5 will stay high for at least one 20ms cycle of the servo. If the next pulse from the servo is shorter than 1300ms, a high will again be clocked though U2A, with the result that U2-5 will remain high as long as the pulse from the servo is less than the period of U1A, which is 1300ms, which corresponds to

15°, the idle/no brakes boundary. Since U4 is an OR, if any of its inputs are high its output will also be high. So, as long as U4-1 remains high, U4-3 will remain high, (regardless of what's happening on U4-2) the gate of Q1 (a logic-level MOSFET) will be driven high, and the LED array will be continuously illuminated. That, then, fulfills the first requirement, which is that the LEDs stay ON continuously any time the brakes are applied, which will be any time the servo's input pulse is less than 1300µs wide.

Now, assume that the servo's input pulse width increases to greater than 1300µs. The timing will look like this:

|| __________________________ ______ U1-6___| |_______...___________| ___ _____...___________ U3-3 |____________________________| |______ ____________________________ ______ U1-4___| |_____...___________| ________________________________ U2-5 |_____...__________________ ______________________________________...__________________ U4-3 |_____...__________________

Notice that now, since the servo's input pulse went low _after_ U1A timed out, U1-6 will be low when U3-3 goes high, so U4-1 will go low, allowing whatever is on U4-2 to control what happens on U4-3.

Since we have a pulse width of 1300µs with the engine at idle and

1500µs with the engine at full throttle, we have a difference of up to 200µs between when U1A times out and the pulse input to the servo times out, and we'd like to be able to use that difference to make the LED array flash slowly when the engine is idling and flash quickly when it's at full throttle.

In order to do that we can use an up counter to accumulate high-frequency clocks during the time between when U1-6 goes low and the input pulse to the servo goes low, and then load that count into a down counter which counts continuously and loads itself with the count on the output of the up counter every time it gets to zero. If we use

4 bit counters we can have up to 15 different flash rates, with U6 being the up counter and U7 being the down counter.

Assuming that we want a 200µs difference between the two pulses to result in a maximum count of 15 means that if we enable the counter for 200µs we'll need to accumulate high-frequency clocks at the rate of 15 clocks per 200µs, which is a frequency of:

1 1 f = --- = ----------- = 75kHz T (200µs/15)

Since we'll want to accumulate clocks using the high frequency 75kHz clock, but display the speed-variable flash at a much lower frequency we can use something like a 4060, which has an integral oscillator and a fairly long ripple chain to good advantage here, and U5 is that counter. Since we need 75kHz and Q3 is the highest frequency output available from the ripple chain, we'll need to set the oscillator to 8 times 75kHz, or 600Khz, with C3, R3, and R4, according to:

T = 2.5 R3 C3

Where T is the period of 600kHz:

1 1 T = --- = --------- = 1.67E-6s = 1.67µs f 6.0E5Hz

Arbitrarily choosing C3 as 100pF and rearranging

T = 2.5 R3 C3

to solve for R3 we have:

T 1.67E-6s R3 = -------- = ---------------- = 6680 ohms 2.5 C3 2.5 * 1.0E-10F

6650 is a standard 1% value and is shown on the schematic with a 5% cap. R4 needs to be approximately equal to twice R3, so 13.7k will work there. However, depending on your application and the pulse width of your servo control signal, the frequency may need to be adjusted in order for the thing to work properly.

Now, in order to gate the 75kHz counter (U6) properly, we need to first clear it, and then enable it to count by supplying it with a low-going pulse with a width which will allow it to count 75kHz clocks, with the number of clocks counted being proportional to the difference in timeout times between U1A and the servo's input pulse.

The CLEAR pulse is generated by U2B and U3B, and is a single pulse with a maximum width of about 13µs generated every time the servo's input pulse goes high, while the enable pulse is generated by -ORing the output of the 1300µs one-shot, the inverted servo input pulse, and the complementary output of U1B, a one-shot set to time out about

1500µs after the start of the servo's input pulse. The enable pulse timing with the servo pulse timing out close to 1300µs is:

----------------1500µs--------->|

--1300µs-->| | ______| | U1-6 |___________________________ _______ SERVO |__________________________ ______ U1-9____________________________| _______ ______ U6-4 |____________________| ||

and with the servo pulse timing out far from the 1300µs one-shot:

----------------1500µs--------->|

--1300µs-->| | ______| | U1-6 |___________________________ _________________________ SERVO |________ ______ U1-9____________________________| __________________________ ______ U6-4 |_| -->| |

Reply to
John Fields

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.