SMALL - espritmodel.com SMALL - Telemetry SMALL - Radio
Reply
Thread Tools
Old Apr 17, 2009, 03:12 AM
Registered User
Brisbane, QLD, Australia
Joined Sep 2007
303 Posts
Discussion
Driving LED from Servo output - PicAxe-08 Success!

I'm trying to work out how to drive a LED from a servo output.

I see the CX3 has this in some sort of add-on - I want to create this myself.

I don't think it is as easy as hooking up a LED to the signal and positive lead (although that does work but not very bright).

I think the CX3 add-on must use a transistor and resistor inbetween which catches the voltage difference to switch on or off the LED.

Does anyone have any further insight or ideas to help out? I am planning a BL conversion of my Lama v4 and would like to use AUX1 to drive an LED - and be able to turn on or off from the DX7/AR6100e.

Thanks in advance,
Des.
deswong is offline Find More Posts by deswong
Last edited by deswong; Apr 18, 2009 at 11:09 PM.
Reply With Quote
Sign up now
to remove ads between posts
Old Apr 17, 2009, 04:50 AM
Registered User
vintage1's Avatar
East Anglia, UK
Joined Sep 2002
29,703 Posts
Easiest is to buy a very cheap BRUSHED ESC.

Then use resistors and LEDS in series on the output.
vintage1 is offline Find More Posts by vintage1
Reply With Quote
Old Apr 17, 2009, 05:08 AM
Registered User
Brisbane, QLD, Australia
Joined Sep 2007
303 Posts
Yeah, I was also thinking of just hacking a small servo board to do the same thing. I wanted to get something nice and easy - the CX3 RC light set seems to be a very simple unit - and I was really hoping it was just a resistor and transistor to turn on/off based on the slight voltage differential between + and Signal lead...
deswong is offline Find More Posts by deswong
Reply With Quote
Old Apr 17, 2009, 06:20 AM
"MAYONNAISE"
Acetronics's Avatar
Le Treport, France
Joined Jun 2004
1,403 Posts
Hi,

just need a small transistor, a pair of resistors and a capacitor ... using a RC lo-pass filter as integrator to smoothen the servo signal and the transistor for its .6v b-e threshold and its current gain ...

soo simple ...

Alain
Acetronics is online now Find More Posts by Acetronics
Reply With Quote
Old Apr 17, 2009, 11:12 AM
Registered User
Dan Baldwin's Avatar
United States, CA, Norwalk
Joined Apr 2004
2,715 Posts
Quote:
Originally Posted by Acetronics
Hi,

just need a small transistor, a pair of resistors and a capacitor ... using a RC lo-pass filter as integrator to smoothen the servo signal and the transistor for its .6v b-e threshold and its current gain ...

soo simple ...

Alain
Yup, soooo simple, but unfortunately, it doesn't work. The average voltage at 2 ms pulse width and 20 ms frame rate on a 5 volt supply is .5 volts. not enough to turn on the transistor. Add a diode and another resistor, and it would probably work. I'll try it.

Dan
Dan Baldwin is offline Find More Posts by Dan Baldwin
Reply With Quote
Old Apr 17, 2009, 11:39 AM
7000mw of raw power!
rich smith's Avatar
New Hampshire (not the old one)
Joined Dec 2006
5,987 Posts
Dan's right. It needs a diode. Ask me how I know.

By far best solution is PIC or AVR. Smaller, cheaper, and 1/5th as many parts. Of course "micro-phobia" will scare off the timid.


Quote:
Originally Posted by Dan Baldwin
Yup, soooo simple, but unfortunately, it doesn't work. The average voltage at 2 ms pulse width and 20 ms frame rate on a 5 volt supply is .5 volts. not enough to turn on the transistor. Add a diode and another resistor, and it would probably work. I'll try it.

Dan
rich smith is offline Find More Posts by rich smith
Reply With Quote
Old Apr 17, 2009, 12:10 PM
Registered User
Dan Baldwin's Avatar
United States, CA, Norwalk
Joined Apr 2004
2,715 Posts
I found that this circuit worked with a 1-2 ms 5 volt pulse and a 20 ms frame rate. If your system is different from that, it won't work. Of course, it doesn't have a nice clean turn on/off. At 1.5 ms the LED is about half brightness, at 1 ms LED is off, and at about 2 ms the LED is full brightness. This circuit will affected by temperature as well. If you need a nice clean turn on, Rich's suggestion of using a microcontroller would be best.

Dan
Dan Baldwin is offline Find More Posts by Dan Baldwin
Reply With Quote
Old Apr 18, 2009, 04:23 AM
Registered User
Brisbane, QLD, Australia
Joined Sep 2007
303 Posts
Quote:
Originally Posted by Dan Baldwin
I found that this circuit worked with a 1-2 ms 5 volt pulse and a 20 ms frame rate. If your system is different from that, it won't work. Of course, it doesn't have a nice clean turn on/off. At 1.5 ms the LED is about half brightness, at 1 ms LED is off, and at about 2 ms the LED is full brightness. This circuit will affected by temperature as well. If you need a nice clean turn on, Rich's suggestion of using a microcontroller would be best.

Dan
Yep - I looked at the circuit and it's great, but I need something which is smaller, neater and clean on/off.

I found my stash of picaxe's and am planning on building a "deadbug" version - so the receiver is wired to the picaxe and that drives the LEDS all in a 8 pin DIP package. I can then shrinkwrap it once I am done and leave it in the heli... that's the plan anyhow.

Now I am hunting to see if anyone else has written code to read/interpret servo signals into the 08 - link here.

I haven't played with picaxe's in 3+ years so this will be fun...
deswong is offline Find More Posts by deswong
Reply With Quote
Old Apr 18, 2009, 06:48 AM
Pompano Hill Flyers
Miami Mike's Avatar
Miami Lakes, Florida, USA
Joined Mar 2003
8,485 Posts
I think using the PC board from a stripped servo is by far the simplest solution. Just replace the pot with a voltage divider made of two resistors and drive the LED with a resistor in series with the motor output.
Miami Mike is offline Find More Posts by Miami Mike
Reply With Quote
Old Apr 18, 2009, 07:40 AM
R.I.P, Aardvark.
F-111 John's Avatar
Holt, MI
Joined Jan 2009
1,554 Posts
Quote:
Originally Posted by Miami Mike
I think using the PC board from a stripped servo is by far the simplest solution. Just replace the pot with a voltage divider made of two resistors and drive the LED with a resistor in series with the motor output.
Don't forget a diode. LEDs don't like to be reverse biased above 5V.
F-111 John is offline Find More Posts by F-111 John
Reply With Quote
Old Apr 18, 2009, 07:58 AM
Pompano Hill Flyers
Miami Mike's Avatar
Miami Lakes, Florida, USA
Joined Mar 2003
8,485 Posts
That crossed my mind, but in all honesty I'm not convinced that a diode would really be needed.
Miami Mike is offline Find More Posts by Miami Mike
Reply With Quote
Old Apr 18, 2009, 10:06 AM
7000mw of raw power!
rich smith's Avatar
New Hampshire (not the old one)
Joined Dec 2006
5,987 Posts
Quote:
Originally Posted by Miami Mike
That crossed my mind, but in all honesty I'm not convinced that a diode would really be needed.
Mike is correct. Modern LEDs have much higher reverse voltage and even if avalanche occurs they are designed to take it. One example is 110vac LED "replacement" bulbs which need no rectifier. Just 30-40 diodes in series.
rich smith is offline Find More Posts by rich smith
Reply With Quote
Old Apr 18, 2009, 11:05 PM
Registered User
Brisbane, QLD, Australia
Joined Sep 2007
303 Posts
Well, I have had some time today to quickly write some code for the PicAxe-08 to do what I am after.

This is very nasty and probably badly coded but it works...

Code:
' AUX1 (pitch) two stage switch and Anti-Collusion Flasher for Lama v4
' Servo AUX1 channel signal connected to pin 4 (Input 3)
' Anti-collision LED connected to pin 7 (Output 0)
' Nav Light Set connected to pin 6 (Output 1)
' Spots/Landing Set connected to pin 5 (Output 2)
' Use appropriate resistors for your LED strings
' and use a 33k resistor between pin 2 (Serial In) and ground
' for reliable operation.
'
' At all times Anti-Collision LED's are flashing. 
'
' On 100% pitch this will light both the nav and spot/landing LEDs
' Between 25%-75% pitch this will only light the nav LEDs
' Below 25% pitch this will switch off both nav and spot/landing LEDs
'
'
' Code by Desmond Wong
' Last updated 19/04/2009 1.55PM
' Use at your own risk.


main:	pulsin 3,1,w1 				' Measure time between pulses
	if w1 >= 166 then gosub landingon	' If > 166 then turn on the landing lights
	if w1 < 165	 then gosub landingoff	' If 125 < w1 > 165 then turn off landing lights
	if w1 >125 then gosub navlightson	' but keep nav lights on
	IF W1 < 120 THEN GOSUB alloff		' If w1 < 120 then turn off the nav lights and landing lights
	gosub flasher				' Flash the Anti-Collision lights
	goto main					' Loop back to start
	
flasher: 	high 0	
		nap 1
		low 0
		nap 2
		high 0
		nap 1
		low 0
		nap 5
		return

landingon: 	high 2
		return

landingoff:	low 2
		return

		
navlightson:high 1
		return
		
alloff:	low 1
		low 2
		return
It does exactly what I want it to do - plus a bit more. It will flash the Anti-collision LEDs for me (which I originally was just going to use a flashing LED with a white LED in series on the 7.4v line) and control landing lights and nav lights.
deswong is offline Find More Posts by deswong
Reply With Quote
Old Apr 19, 2009, 10:00 PM
R/C Electro-Gadgeteer
Tomapowa's Avatar
N.E. USA
Joined Oct 2003
813 Posts
Awesome Desmond... good job. The more you keep messing with the 08M, you'll be amazed what you can do. The SERVO, PWM and ADC commands are pretty powerful too!

Contrary to your code comment though, you are in fact measuring the servo pulse duration (high pulse length, 1-2ms, with 10us resolution, hence the 100-200 value read), not the "time between pulses". The time between pulses should be roughly constant, around 20ms or 50Hz (i.e. servo pulse frame length).

To read the length between pulses, you would use the code:

pulsin 3,0,w1

(0 instead of 1)... but then again, why measure that?
Tomapowa is offline Find More Posts by Tomapowa
Last edited by Tomapowa; Apr 19, 2009 at 10:06 PM.
Reply With Quote
Old Apr 20, 2009, 01:37 AM
Registered User
Brisbane, QLD, Australia
Joined Sep 2007
303 Posts
I've had several PM's about this code in the last day - this was done to do what *I* wanted it to do - feel free to use this as a base and make changes to the code to suit your purpose.

For me, I wanted lights for my Lama v4 to be controllable by the transmitter. I have realised I can get smart with this - as all I need to do is pick a point in the pitch curve to trigger an output pin.

So the way mine works is that:

a) AC lights always on and flashing
b) Nav lights when pitch curve is above 25% (approx)
c) Spots/Landing lights when pitch curve is above 75% (approx)

So this would mean that if I have the spots/landing LED's on, naturally it would be dark so the Nav lights should also be lit at this time.

This I can then control with my stunt switch It has 3 positions, so I set normal mode to use only the AC lights, ST-1 will light up Nav and ST-2 will light up Nav and Spots.

Please remember that I have provided the code here to help others out who are interested in DIY and are of a level to be able to understad and edit the code to their needs. You can go overboard if you really wanted to and make triggers for all different points in your pitch curves or make your knob trigger 6 or more different actions by multiplexing, only left up to your imagination.

I do wish that I had gotten the 08M rather than the 08 - I could have then had better code and use the interrupt so I can keep a consistent flash rate and faster response to where the pitch curve sits to turn on the relevant lighting setup. At the moment depending on where it catches the position of the servo pulse it may take 1/2 second to acknowledge the change in position and light the relevant setup.

I also used the nap mode rather than sleep - sleep would result in accurate timings, but I am not too concerned and the tiny bit of power saving that I have made using nap rather than sleep may (or may not) pay off in the long run.

I've completed mine as a deadbug unit - I probably could have done straight to the chip but for this first prototype I have done it into an IC socket, and have the flexibility to re-program the chip externally if I want to change this to a triple flash or whatever effect I would like.

I've been tempted to use the ADC so I can also make this a LV alarm flashing a certain light pattern - but I think I need more parts and so far in this version I have achieved more than what I was originally after - in a much smaller, lighter and cheaper unit than a commercially bought switch (which would not have the two-step switching).

Tomapowa - is the 08M going to be quick enough to decode a section of a PPM signal? My next insane project is to strip out a section of the PPM signal so I can then read that and control something from a straight PPM signal...
deswong is offline Find More Posts by deswong
Reply With Quote
Reply


Thread Tools

Similar Threads
Category Thread Thread Starter Forum Replies Last Post
Help! JMP board max ma safely from actuator output mjsimon Scratchbuilt Indoor and Micro Models 1 Jan 27, 2006 08:37 PM
Question 10-bit analog output from servo input, anybody have a canned solution available? EddieB DIY Electronics 33 Mar 11, 2005 01:47 AM