Non invert Attiny 85 led driver.
- ShowMaster
- Posts: 4327
- Joined: Thu Dec 29, 2011 3:44 am
- Country: -
- Location: Los Angeles, CA USA
Non invert Attiny 85 led driver.
I’ve been asked by a club member to help with a RC landing light attiny85 circuit. It’s a GitHub posted diy.
https://github.com/hasbridge/arduino-rc ... /README.md
I’m still a beginner but was able to burn a bootloader into a Tiny85 and then the sketch, both operations were using my uno and was a success.
I owe that to the help and posts you all have made!
I took it on to further educate myself on flashing bootloaders and programming Arduino.
It works well for what he wants to do, with several pwm output pins driving a led to strobe and one is turned on or off via a ppm input from a receiver (landing lights pin 2).
1ms to 2ms on or off.
The LEDs seem to want to be connected from the output pins to ground.
The issue I’m having is he wants to drive higher current and brighter LEDs. The Attiny85 is only good fro 40ma per output pin, 200ma total.
I’m trying to use a get or transistor as a led driver but it inverts the pulses. My work around was to use 2 transistors to cancel the pulse inversion.
I just can’t seem to get it working. The transistors don’t seem to saturate and it averages the pwm pulses and the brightness and strobe action is compromised.
I have tried a n channel mosFET as the last stage driven by a 3904 with the same results.
1rfz44n is what I have in stock.
Any ideas or tips/circuits would be a big help.
Thank you
Sent from my iPhone using Tapatalk Pro
https://github.com/hasbridge/arduino-rc ... /README.md
I’m still a beginner but was able to burn a bootloader into a Tiny85 and then the sketch, both operations were using my uno and was a success.
I owe that to the help and posts you all have made!
I took it on to further educate myself on flashing bootloaders and programming Arduino.
It works well for what he wants to do, with several pwm output pins driving a led to strobe and one is turned on or off via a ppm input from a receiver (landing lights pin 2).
1ms to 2ms on or off.
The LEDs seem to want to be connected from the output pins to ground.
The issue I’m having is he wants to drive higher current and brighter LEDs. The Attiny85 is only good fro 40ma per output pin, 200ma total.
I’m trying to use a get or transistor as a led driver but it inverts the pulses. My work around was to use 2 transistors to cancel the pulse inversion.
I just can’t seem to get it working. The transistors don’t seem to saturate and it averages the pwm pulses and the brightness and strobe action is compromised.
I have tried a n channel mosFET as the last stage driven by a 3904 with the same results.
1rfz44n is what I have in stock.
Any ideas or tips/circuits would be a big help.
Thank you
Sent from my iPhone using Tapatalk Pro
Re: Non invert Attiny 85 led driver.
Drive an N Mosfet directly from the ATtiny pin, or a P channrel Mosfet from an NPN transistor. In this case, base of the transistor to the Microcontroller pin, emitter to ground, and.collector to the Mosfet gate..
Place an 100K resistor between source and gate so the Mosfet can turn off..
João
Place an 100K resistor between source and gate so the Mosfet can turn off..
João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9
Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9
Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
Re: Non invert Attiny 85 led driver.
If the inversion of the signal is your only problem, why not change the code to get an inverted signal ?I’m trying to use a get or transistor as a led driver but it inverts the pulses. My work around was to use 2 transistors to cancel the pulse inversion.
A short view into the mentioned code shows me, that for the most output pins there is always a little peace of code that makes an output pin high or low. If you exchange the high and low settings for a single pin, it should give you the inverted signal that your inverting transistor needs.
e.g.
Code: Select all
if (state && !curLandingLight) {
digitalWrite(LL_PIN_LIGHT, HIGH);
} else if (!state && curLandingLight) {
digitalWrite(LL_PIN_LIGHT, LOW);
- MikeB
- 9x Developer
- Posts: 17995
- Joined: Tue Dec 27, 2011 1:24 pm
- Country: -
- Location: Poole, Dorset, UK
Re: Non invert Attiny 85 led driver.
Use an emitter follower:
According to the datasheet of the TINY85, the 40mA and 200mA are absolute maximum ratings, at 40mA out from a pin, you won't get much voltage. Normal output current is +/- 8mA on a pin.
Mike
This provides non-inverting current gain.According to the datasheet of the TINY85, the 40mA and 200mA are absolute maximum ratings, at 40mA out from a pin, you won't get much voltage. Normal output current is +/- 8mA on a pin.
Mike
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
The difficult we do immediately,
The impossible takes a little longer!
- ShowMaster
- Posts: 4327
- Joined: Thu Dec 29, 2011 3:44 am
- Country: -
- Location: Los Angeles, CA USA
Re: Non invert Attiny 85 led driver.
All good ideas! My thought was to invert the code but that’s still a challenge for me.
If the posted code mod does that I’ll give it a try. I’ll study the changes and what they are doing.
It’s a logical option but I’m more component oriented and usually take that approach.
I should stock some P channel mosfets to go with my N channel stock so I’ll order some to have and try.
The emitter follower circuit I’ll also try Mike as it’s something I forgot about and should explore it again anyway.
I look at these options as a learning moment to solve a challenge different ways.
Sent from my iPhone using Tapatalk Pro
If the posted code mod does that I’ll give it a try. I’ll study the changes and what they are doing.
It’s a logical option but I’m more component oriented and usually take that approach.
I should stock some P channel mosfets to go with my N channel stock so I’ll order some to have and try.
The emitter follower circuit I’ll also try Mike as it’s something I forgot about and should explore it again anyway.
I look at these options as a learning moment to solve a challenge different ways.
Sent from my iPhone using Tapatalk Pro
- ShowMaster
- Posts: 4327
- Joined: Thu Dec 29, 2011 3:44 am
- Country: -
- Location: Los Angeles, CA USA
Re: Non invert Attiny 85 led driver.
Wouldn’t driving a N channel directly invert the pwm?jhsa wrote:Drive an N Mosfet directly from the ATtiny pin, or a P channrel Mosfet from an NPN transistor. In this case, base of the transistor to the Microcontroller pin, emitter to ground, and.collector to the Mosfet gate..
Place an 100K resistor between source and gate so the Mosfet can turn off..
João
My confusion is he didn’t post a actual layout showing the LEDs going from the + rail to the output pins, or from the output pins to ground ( both options use a current limiting resistor)?
Connecting the series led/resistor to the output pin and ground seems to give the flashing subscribed in his info. This would imply I need a non inverting output driver?
Sent from my iPhone using Tapatalk Pro
Re: Non invert Attiny 85 led driver.
Well, I didn't look at the code yet (not at the PC), but now that you mention it, the LED can be connected from the VCC rail to the pin, or from the pin to Ground. This could explain the inversion you are seeing.
If the LED is connect to VCC, the pin will connect to ground to turn it ON.
If the LED is connected from the pin to Ground, then the pin will connect to VCC to turn it ON. I think this why you are seeing it inverted. I believe you will need to invert it in the code and then just use a transistor connected via a resistor (3K3) to the pin, and then connect the LED and its resistor between VCC and the collector. Emitter to Ground.
Let me get to my PC and have a look at the code.
João
If the LED is connect to VCC, the pin will connect to ground to turn it ON.
If the LED is connected from the pin to Ground, then the pin will connect to VCC to turn it ON. I think this why you are seeing it inverted. I believe you will need to invert it in the code and then just use a transistor connected via a resistor (3K3) to the pin, and then connect the LED and its resistor between VCC and the collector. Emitter to Ground.
Let me get to my PC and have a look at the code.
João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9
Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9
Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
Re: Non invert Attiny 85 led driver.
That code snippet was the original code. So to have that special output (landing light) inverted the HIGH and LOW have to be exchanged with each other like in this modified code.If the posted code mod does that I’ll give it a try.
Code: Select all
if (state && !curLandingLight) {
digitalWrite(LL_PIN_LIGHT, LOW); // changed from HIGH to LOW
} else if (!state && curLandingLight) {
digitalWrite(LL_PIN_LIGHT, HIGH); // changed from LOW to HIGH
Reinhard
Re: Non invert Attiny 85 led driver.
yep, it is as ReSt says
João
João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9
Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9
Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
- ShowMaster
- Posts: 4327
- Joined: Thu Dec 29, 2011 3:44 am
- Country: -
- Location: Los Angeles, CA USA
Re: Non invert Attiny 85 led driver.
So I must be spacing out?
Gave it a try today after some sleep and coffee, with an emitter follower and then common emitter.
The mode that looks correct to me is having the led connected from the Tiny85 output pins to ground.
The common emitter with the led in the collector seems to look correct flashing wise to me. I’m not a pilot so I’ve never really looked st what all the flashing lights look like, or throw colors. I will now!
Sorting this out, this is what I think is going on. Posting this for any comments on my thinking.
This I assume is the “sinking mode” that when the pin goes high it pulls up to the rail (vcc) voltage. My led ( with limiting resistor) being connected to ground and the output pin goes high to light the led.
I can’t find a internal representation of the Tiny85 output pin circuit, but I’m thinking it’s maybe both a n and p channel totem pole allowing for sourcing and sinking?
That being the case, no inversion is needed by the external led driver circuit using a npn bpt or n channel mosfet as a common emitter or common source stage. Putting the led in the collector or drain to vcc seems to follow the same action as having the led connected to the Tiny85 output pins and ground. The pins go on high to ground, off low to ground. Connecting this to a N bpt or n channel mosfet base or gate and the led in the collector or drain lead to vcc, buffers the current drawn and also follows the T85 output pin action.
If this makes sense then not only is this solved, but any future coding attempt I make will use the sinking mode to allow for a simple external buffering/driver. This allows the use of a higher voltage/current source for LEDs and other devices.
The LEDs my friend is using will run on a 2 cell lipo he says, so I’ll add a 5v regulator for the t85. I don’t think it should run on the esc bec 5v but that also an option. I’m thinking others will want to build/use this circuit and being a self contained pc or hand wired board why not add the regulator. Maybe a 78lo5 if it’s 100ma rating is enough it doesn’t have to power the leds.
I’ll wire one up for him with mosfet drivers and he’ll let me know if it’s correct.
Sent from my iPhone using Tapatalk Pro
Gave it a try today after some sleep and coffee, with an emitter follower and then common emitter.
The mode that looks correct to me is having the led connected from the Tiny85 output pins to ground.
The common emitter with the led in the collector seems to look correct flashing wise to me. I’m not a pilot so I’ve never really looked st what all the flashing lights look like, or throw colors. I will now!
Sorting this out, this is what I think is going on. Posting this for any comments on my thinking.
This I assume is the “sinking mode” that when the pin goes high it pulls up to the rail (vcc) voltage. My led ( with limiting resistor) being connected to ground and the output pin goes high to light the led.
I can’t find a internal representation of the Tiny85 output pin circuit, but I’m thinking it’s maybe both a n and p channel totem pole allowing for sourcing and sinking?
That being the case, no inversion is needed by the external led driver circuit using a npn bpt or n channel mosfet as a common emitter or common source stage. Putting the led in the collector or drain to vcc seems to follow the same action as having the led connected to the Tiny85 output pins and ground. The pins go on high to ground, off low to ground. Connecting this to a N bpt or n channel mosfet base or gate and the led in the collector or drain lead to vcc, buffers the current drawn and also follows the T85 output pin action.
If this makes sense then not only is this solved, but any future coding attempt I make will use the sinking mode to allow for a simple external buffering/driver. This allows the use of a higher voltage/current source for LEDs and other devices.
The LEDs my friend is using will run on a 2 cell lipo he says, so I’ll add a 5v regulator for the t85. I don’t think it should run on the esc bec 5v but that also an option. I’m thinking others will want to build/use this circuit and being a self contained pc or hand wired board why not add the regulator. Maybe a 78lo5 if it’s 100ma rating is enough it doesn’t have to power the leds.
I’ll wire one up for him with mosfet drivers and he’ll let me know if it’s correct.
Sent from my iPhone using Tapatalk Pro
Re: Non invert Attiny 85 led driver.
See the link to a video on the Github project pageShowMaster wrote: ↑Sun Sep 23, 2018 4:02 pm So I must be spacing out?
Gave it a try today after some sleep and coffee, with an emitter follower and then common emitter.
The mode that looks correct to me is having the led connected from the Tiny85 output pins to ground.
The common emitter with the led in the collector seems to look correct flashing wise to me. I’m not a pilot so I’ve never really looked st what all the flashing lights look like, or throw colors. I will now!
The ATtiny will connect the pin to VCC when it is HIGH, and to ground when it is set to LOW, so if you connect the LED between the pin and ground, it will light when the pin is HIGH (connected to VCC).This I assume is the “sinking mode” that when the pin goes high it pulls up to the rail (vcc) voltage. My led ( with limiting resistor) being connected to ground and the output pin goes high to light the led.
I can’t find a internal representation of the Tiny85 output pin circuit, but I’m thinking it’s maybe both a n and p channel totem pole allowing for sourcing and sinking?
If you connect the LED between VCC and the ATtiny pin, the LED will light when the pin is set to LOW (connected to GND).
Correct..That being the case, no inversion is needed by the external led driver circuit using a npn bpt or n channel mosfet as a common emitter or common source stage. Putting the led in the collector or drain to vcc seems to follow the same action as having the led connected to the Tiny85 output pins and ground.
I think that is a safer solution..The LEDs my friend is using will run on a 2 cell lipo he says, so I’ll add a 5v regulator for the t85.
João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9
Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9
Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW