so ive been trying to add a reverse to a speed controller from a dead r/c airplane, so that i may be able to re-purpose it for ground vehicles.
so what ive done is to use an attiny85 to operate a relay and convert the control signal. works like this:
r/c receiver pipes in the signal which is a pulse between 1000 and 2000 us to a digital pin on the mcu.
mcu reads signal as an axis value, using data generated at calibration time (this happens when you install a jumper and reset the device) it splits the axis in half so that anything above the center is forward and anything below it is reverse.
if the stick crosses the deadzone at the center this causes the relay to toggle. ive wrote my code so that the motor gets about a half a second of off time before toggling the relay, this is meant to protect mechanical components, and electrical ones too (like the relay welding its self open or closed).
the signal pulse that controls the speed controler is re-created on another pin and that is hooked to the speed controller, essentially it remaps the range out so that moving the joystick away from center increases the speed, while going to center decreases the speed while the relay only controls direction.
now the relay im using is a high sensitivity dpdt relay that sports a minimum coil current of 30ma. according to the datasheet on the attiny85, i can source up to 40ma from an io pin. most of the tutorials ive seen do 2 things. first is drive the coil with a transistor, which i assume is to boost the current to the coil (do i need to do this?). the second is use a flyback diode (for which i used a rectifier diode). i have the prototype working in the breadboard, but i want to protect the circuit as best as possible.
so would using a transistor be advisable or is this kinda thing only needed if you need more current than the mcu can source?
LordNothing:
now the relay im using is a high sensitivity dpdt relay that sports a minimum coil current of 30ma. according to the datasheet on the attiny85, i can source up to 40ma
That is in the table listing "Absolute Maximum Ratings," and operation under those condiitions is not (that's not) recommended by Atmel.
In particular, the Notice to the right of that table says, specifically:
Exposure to absolute maximum rating
conditions for extended periods may affect
device reliability.
So, the data sheet does not say that it's OK to source 40 mA from a pin. Even if you seem to "get away with" ignoring the manufacturer's recommendations, you may cause damage in the CPU that will result in its eventual failure.
Furthermore...
The next table in the data sheet lists "DC Characteristics" under given test conditions. Note (5) for that table says:
- Although each I/O port can source more than the test conditions (10 mA at VCC = 5V, 5 mA at VCC = 3V) under steady state
conditions (non-transient), the following must be observed:
1] The sum of all IOH, for all ports, should not exceed 60 mA.
If IOH exceeds the test condition, VOH may exceed the related specification. Pins are not guaranteed to source current
greater than the listed test condition.
(Emphasis added.)
Bottom line: Regardless of what happens experimentally, it is not recommended to design an application (with 5 Volts on the Vcc) that tries to have an I/O current greater than 10 mA for any given pin. I mean, how much cost does doing the Right Thing (using a transistor+base resistor) add to the project?
Regards,
Dave
Based on many (MANY) years of experience with micros and relays:
NEVER drive a relay directly from a micro. ALWAYS use an external transistor or a driver chip (ULN2803 is a good one that will drive 8 relays and contains built-in protection diodes).
ALWAYS use a protection diode across the relay's coil (cathode to + side of the coil).
from a dead r/c airplane, so that i may be able to re-purpose it for ground vehicles.
Have you checked into the legality of doing this, or don't you care. The folks trying to fly their airplanes near your ground vehicle might care.
Don
davekw7x:
LordNothing:
now the relay im using is a high sensitivity dpdt relay that sports a minimum coil current of 30ma. according to the datasheet on the attiny85, i can source up to 40ma
That is in the table listing "Absolute Maximum Ratings," and operation under those condiitions is not (that's not) recommended by Atmel.
In particular, the Notice to the right of that table says, specifically:
Exposure to absolute maximum rating
conditions for extended periods may affect
device reliability.
So, the data sheet does not say that it's OK to source 40 mA from a pin. Even if you seem to "get away with" ignoring the manufacturer's recommendations, you may cause damage in the CPU that will result in its eventual failure.
Furthermore...
The next table in the data sheet lists "DC Characteristics" under given test conditions. Note (5) for that table says:
- Although each I/O port can source more than the test conditions (10 mA at VCC = 5V, 5 mA at VCC = 3V) under steady state
conditions (non-transient), the following must be observed:
1] The sum of all IOH, for all ports, should not exceed 60 mA.
If IOH exceeds the test condition, VOH may exceed the related specification. Pins are not guaranteed to source current
greater than the listed test condition.
(Emphasis added.)
Bottom line: Regardless of what happens experimentally, it is not recommended to design an application (with 5 Volts on the Vcc) that tries to have an I/O current greater than 10 mA for any given pin. I mean, how much cost does doing the Right Thing (using a transistor+base resistor) add to the project?
Regards,
Dave
this is kind of what i need to know. i didnt want to build something that would self destruct with use. i have several transistors on hand 2n7000, pn2222a pn2907a. im sure i have others in my scrap box. would any of these work?
floresta:
from a dead r/c airplane, so that i may be able to re-purpose it for ground vehicles.
Have you checked into the legality of doing this, or don't you care. The folks trying to fly their airplanes near your ground vehicle might care.
Don
its a speed controller, not a receiver. granted i will likely test it with the aircraft receiver (of course i still need it for my heli). but i built a receiver board awhile back that uses an ask module, and will likely use that once everything is working.
Using the 2N7000 or the 2N2222 (PN2222) would be just fine. There are many examples available with a quick google search.