Problem using Reset as Input

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi everyone,

I've been working on an pulse monitor circuit for a while now based on a Tiny12 AVR and everything was working perfect, until I decided to raise the frequency to allow better resolution. The circuit uses a simple programming switch to program a setpoint. I was using PB3 for the switch, but since I wanted to raise the frequency I had to move it to PB5, which is typically the reset input.

I used my high voltage programmer and configured the pin to NOT be a reset and now I'm having issues with the AVR recognizing the switch (I have verified that all programming references were changed).

From the data sheet I can tell that PB5 does NOT have an internal pull up resistor, but since my circuit has an external pull up (10K) I can't see how this would be an issue. The switch itself is wired to ground on one side, and to a PNP resistor through a 10K resistor. The emitter goes to ground, the collector goes to 5VDC through a 10K resistor. My switch tie in point is between the resistor and the transistors collector. I have verified that the pin is seeing a 'low' voltage at the input pin, so I have ruled out hardware issues.

I have never used an AVR without the internal pull up enabled, am I over looking something? Oh, and I have tried three separate circuits with three separate Tiny12s! Each circuit will occasionally read the low voltage, and I have noticed that if my DMM is on the input pin I stand a much better chance of the button being read as a 'low.'

Thank you,

--------------------------------
Kevin Pierson

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So at 5 volts, a low voltage should be less than 1.5 volts (0.3Vcc). At the pin (collector of the NPN) do you get less than 1.5 volts for a "low voltage"?.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm actually getting about 1.6VDC at the pin with the button pushed, a little bit higher then I would like, but it worked flawlessly on PB3 (I have verified the voltage is 1.6VDC on both setups). I think tonight I'm going to switch back to the internal oscilator and remove the crystal just to eliminitate that as a cause of interference (unlikely).

Oh, one other thing, I'm running an 8mhz crystal. The data sheets states that the maximum crystal frequency is 4mhz, but the chip is an 8mhz chip, so I figured it would be able to handle the faster crystal, is this an accurate assumption? Maybe I should try a 4mhz crystal and see if I have better results?

--------------------------------
Kevin Pierson

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I don't think the crystal is the problem.
The problem is your hardware. You're lucky that your circuits work for the ordinary port pins.
Take a look at the attached picture. As I have understood it, your circuit is wired as the first one. You should switch emitter and collector and it should work for all pins.

Also, it will work without the base resistor as well, the current is drawn through the emitter and out of the base and is limited by the pull-up resistor.
Infact, the whole transistor is unnecessary, you're not even using it. The only thing you're "using" is the emitter-base diode.

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Or you can probably just replace the NPN with a N MOSFET transistor.
That will give you a near zero voltage drop i.e. Vds =0 (approx) when Vgs>threshold.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you very much for the diagram. The transistors are included for two reasons, to isolate the input pins from the outside world and to provide tolerance for a 12vdc signal (not actually used in this particular case, but standard for all my designs just to be safe).

Would the same voltage leves be true for NPN transistors also? I have been using them for quite a while in the same fashion as the PNP with no issues to date.

Thank you for your help, I really appreciate it and I'll post back when I get a chance tonight to work on this circuit!

--------------------------------
Kevin Pierson

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In this case, the transistors does not isolate the switches from the inputs. You should probably use an NPN or N-channel MOSFET instead and have the switches connected to Vcc instead of ground. If you really want to use PNP-transistors, you should connect the emitter directly to Vcc and the collector to the input-pin on the AVR. You'll also need a pull-down resistor on the input.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

My applications don't typically allow me to choose my switch voltage or polarity. I deal with 5vdc and 12vdc circuits and they vary from postitive switching to ground switching, so my circuit boards are setup to go either way. I honestly didn't know that PNP transistors were that much differnet then NPN transistors. I guess I'll have to hit the books again, its been a while..... I just swapped the transistor around and I'm getting much better low voltage... around .7VDC (imagine that!). I'm going to go throw this board in my truck and see how it responds! Thanks again for everyones help, you guys are major stress relievers!

--------------------------------
Kevin Pierson

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The switch works flawlessly now! Now on to the next stage of debugging :)

Thanks again,

--------------------------------
Kevin Pierson