Attiny85 and unrecognized HIGH levels

Thread Starter

sumeryamaner

Joined May 29, 2017
114
I am working on RC aircraft projects. Most of the time I am using the Attiny85.
As you already know, radio control systems use PWM for servo control. Pulses of 1000 - 2000 microseconds every 20 milliseconds tell the servos what to do.
My projects are;
- Kill switch for gasoline engine ignition
- Servo reverser
- Servo slower
- Landing gear door sequencer
- Electronic switch (as a replacement for mechanical switches)
- Landing gear motor controller

All but the last project are working fine. Most of them have been tested for more than one year at the field. But I have problems with the last project.

RC Aircraft systems are being powered by batteries and regulators but there is no fixed standart voltage. So the electronic components must work at voltages between 4.8V and 8.4V. For this reason I always use a low dropout voltage regulator (LM2950) in my projects.

I always use one digital pin of the Attiny85 to read the incoming PWM pulse. I use the "pulseIn()" function of the Arduino IDE most of the time and there are no problems. But in the last project I noticed that the pulseIn() function cannot read the pulse width correctly. The HIGH level of the RC receiver output cannot be recognized as HIGH by the Attiny85. I added a transistor stage at the input and as the polarity of the PWM signal is now reversed I changed the code accordingly. This solved the problem.

What I want to know is...

I am using the same basic circuitry (Attiny85, internal oscillator @ 8 MHz, LM2950 as voltage regulator) in all my projects and I am using similar RC receivers (Hitec Optima series). Why do the first 5 projects work flawlessly and the 6th not?
Any ideas would be welcome...
 

Papabravo

Joined Feb 24, 2006
21,225
What does the datasheet say about the requirements for a valid HIGH level? What does it say about the Vcc range? Have you actually measured them, or are you just inferring that there is a problem?
 

Thread Starter

sumeryamaner

Joined May 29, 2017
114
I have produced my own PCB's using toner transfer method. They wor fine. Then I decided to use professionally fabricated PCBs.
20170513_215833.jpg 20170417_203455.jpg
 

Thread Starter

sumeryamaner

Joined May 29, 2017
114
Now I am experiencing this strange problem. The circuit behaves erratically. Does not follow the RC commands.

This addon made things better:

3.jpg
 

Papabravo

Joined Feb 24, 2006
21,225
You are right. I must give more information in order to receive good answers. :)

The basic circuit is this:

View attachment 127821
Question(s)
  1. What is the output voltage of the LM2950? Choices are 3.0V, 3.3V, and 5.0V
  2. What is the possible input voltage range on pin 2 of the ATTiny85 without the transistor inverter?
  3. In other words, what is the Vcc to the chip providing the PWM signal?
Stab in the dark. The ATTiny85 is running on +5VDC nominal and the receiver is running on 3.3V and the minimum output high voltage is not making it for the ATTiny85.
 

dl324

Joined Mar 30, 2015
16,923
Stab in the dark. The ATTiny85 is running on +5VDC nominal and the receiver is running on 3.3V and the minimum output high voltage is not making it for the ATTiny85.
That's my guess too. Circuit functioning depended on the high level input threshold voltage. It worked when it was on the low end of the spec.

A level shifter would fix that. Or a pullup resistor if it didn't force too much current into the driver.
 

shteii01

Joined Feb 19, 2010
4,644
1k for the indicator led is huge.
Assuming 2.2V red led with the current we want through it to be 15mA, then 5-2.2=2.8V, then 2.8V/15mA=187 Ohm resistor. I think 180 Ohm is one of the standard resistor values so just use that.
 

Thread Starter

sumeryamaner

Joined May 29, 2017
114
1k for the indicator led is huge.
Assuming 2.2V red led with the current we want through it to be 15mA, then 5-2.2=2.8V, then 2.8V/15mA=187 Ohm resistor. I think 180 Ohm is one of the standard resistor values so just use that.
The LED is only for indication purposes and you can be sure the current with 1kohm resistor is more than adequate. This is my standart setup and if you want I can send you a few pics. :)

Question(s)
  1. What is the output voltage of the LM2950? Choices are 3.0V, 3.3V, and 5.0V
  2. What is the possible input voltage range on pin 2 of the ATTiny85 without the transistor inverter?
  3. In other words, what is the Vcc to the chip providing the PWM signal?
Stab in the dark. The ATTiny85 is running on +5VDC nominal and the receiver is running on 3.3V and the minimum output high voltage is not making it for the ATTiny85.

  1. What is the output voltage of the LM2950? Choices are 3.0V, 3.3V, and 5.0
    It is 5.0 V
  2. What is the possible input voltage range on pin 2 of the ATTiny85 without the transistor inverter?
    In the datasheet the minimum voltage level for HIGH is 0.6Vcc. That means in my situation it is 3.0 V
  3. In other words, what is the Vcc to the chip providing the PWM signal?
    Most probably the receiver works at 3.6V (internal level) and the PWM pulse has an amplitude of 3.3V
I think this is right:
The ATTiny85 is running on +5VDC nominal and the receiver is running on 3.3V and the minimum output high voltage is not making it for the ATTiny85.
 
Last edited:

Thread Starter

sumeryamaner

Joined May 29, 2017
114
That's my guess too. Circuit functioning depended on the high level input threshold voltage. It worked when it was on the low end of the spec.

A level shifter would fix that. Or a pullup resistor if it didn't force too much current into the driver.
The components shown in the post #8 have been added. I make use of the internal pullup resistor to reduce part count.
I have checked the setup using actual components of the aircraft.The result seems to bir OK. Now I have to test it on the real aricraft.
 

Thread Starter

sumeryamaner

Joined May 29, 2017
114
I think if I replace the 5.0V 2950 with a 3.3V one, there won't be any logic level problems. Do you have any idea about the Attiny input exceeding Vcc? I mean, if I use the Attiny85 at 3.3V, will the IC be damaged if there is a pulse of 4.5V at an input pin?
(I will read thrugh the datasheet but if you have any experience it would help very much).
 

shteii01

Joined Feb 19, 2010
4,644
The LED is only for indication purposes and you can be sure the current with 1kohm resistor is more than adequate. This is my standart setup and if you want I can send you e few pics. :)
I just thought 1k was a waste. However, since you are satisfied with this specific aspect of the design, then I will bow out and see if I can learn from the rest of the design.
 

Papabravo

Joined Feb 24, 2006
21,225
There are chips you can use to interface a 3.3/3.6 Volt device with a 5V device. Let me check the ATTiny85 datasheet.

The maximum input voltage on any pin, with respect to GND is Vcc+0.5 Volts. So running on 3.3V the inputs would NOT be +5V tolerant.

Checkout the following datasheets for level translation purposes:

http://www.onsemi.com/pub/Collateral/MC74VHC1GT50-D.PDF

The key feature here is that ALL INPUTS have TTL Thresholds instead of CMOS thresholds and they are +5V tolerant. there are other members of this family and Fairchild and others make similar parts.

TTL Thresholds means a LOW is anything less that 0.8V regardless of Vcc
TTL Thresholds means a HIGH is anything over 2.0V regardless of Vcc

To use this part in your application connect Vcc to the same source as the ATTiny85. Connect GND(Vss) to the same place as the ATTiny GND. Connect the output to the ATTiny pin 2. Connect the input pin to the PWM source and pulse away.
 
Last edited:

dl324

Joined Mar 30, 2015
16,923
Do you have any idea about the Attiny input exceeding Vcc? I mean, if I use the Attiny85 at 3.3V, will the IC be damaged if there is a pulse of 4.5V at an input pin?
Most CMOS inputs have diode clamps to VCC and VSS. If you drive a 3.3V input from with a 5V signal, you need to follow the manufacturer's specification for current driven into the input. There are two things to be concerned with: latch up and electromigration. I guess a third thing would be damaging a device...
 

Thread Starter

sumeryamaner

Joined May 29, 2017
114
Thank you for the great ideas and hints. As I have 40 PCBs at hand, I am trying to solve the puzzle without the need for a new PCB. :)
I have soldered a 2N2222 and a base resistor to a piece of extension lead, covered all with hot silicone and then applied heat shrink. Now the incoming signal is reversed. I changed the code to read negative pulses insted of positive ones and activated the internal pullup resistor. Now it is working. But I cannot explain why my previous projects are working! :)

PS: I think I can protect the input with a resistor / 3V3 zener combination.
 

Papabravo

Joined Feb 24, 2006
21,225
Thank you for the great ideas and hints. As I have 40 PCBs at hand, I am trying to solve the puzzle without the need for a new PCB. :)
I have soldered a 2N2222 and a base resistor to a piece of extension lead, covered all with hot silicone and then applied heat shrink. Now the incoming signal is reversed. I changed the code to read negative pulses insted of positive ones and activated the internal pullup resistor. Now it is working. But I cannot explain why my previous projects are working! :)

PS: I think I can protect the input with a resistor / 3V3 zener combination.
The zener will add quite a bit of capacitance to the input. You might also want a series resistor to limit the current. A couple of hundred Ohms should be fine.
 

Thread Starter

sumeryamaner

Joined May 29, 2017
114
The zener will add quite a bit of capacitance to the input. You might also want a series resistor to limit the current. A couple of hundred Ohms should be fine.
Of course I will place a series resistor if I use a zener. :) Thank you. I don't think that the extra capacitance would harm in this setting.
 
Top