Pages: [1]   Go Down
Author Topic: Level shift 0v-1v signal to attachInterrupt  (Read 1779 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 38
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm looking for a transistor or IC that will shift a voltage range of 0 to 1 volts to 0 to 5 volts for use on a digital interrupt pin using attachInterrupt.

Anyone done this before?

Logged

0
Offline Offline
Faraday Member
**
Karma: 23
Posts: 3470
20 LEDs are enough
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Almost any transistor will do. For example BC238 would be more than sufficient.

Cheers, Udo
Logged

Check out my experiments http://blog.blinkenlight.net

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17262
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Tell us more about the 0-1v signal. Is the 0v- +1v signal a true digital signal, i.e. it can only be at 0v or +1v, never anything in between those two voltage levels? If so it's a digital signal and only needs to be amplified with a transistor or op-amp with a gain of 5. If however it's a true analog voltage (value may be anywhere between 0- +1vdc) then you need either a comparitor IC or an op-amp wired as a compator. It will need to have a reference set to 1/2 the input range (+1/2vde) and some kind of hystersis to make the switching point jitter free. The interrupt pin input for an Arduino is a TTL level digital input and the signal to it must be well behaved or you will either miss or have multipule interrupts in error.

Lefty
Logged

0
Offline Offline
Faraday Member
**
Karma: 23
Posts: 3470
20 LEDs are enough
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

One more thought: if it is some slow signal and you do not need the analog pins for something else, just read the signal as analog signals.

But of course you should consider retro's comment and take care of a hyteresis (this time in software).

Cheers, Udo
Logged

Check out my experiments http://blog.blinkenlight.net

0
Offline Offline
Newbie
*
Karma: 0
Posts: 38
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the replies!

No it's true digital output from a hall effect sensor, either 0 or 1v. On
the scope it looks like a square wave. Not terribly fast but I need
digital accuracy.

The BC238 looks good but there is not a sample circuit in the datasheet.

I'm guessing the collector would be my 1v signal, base to ground
and the emitter would be my 5v out? Would I need any caps to filter
he output or anything else special in the way of a circuit?

Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 602
Posts: 33362
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I'm guessing the collector would be my 1v signal, base to ground
and the emitter would be my 5v out?

How wrong can a guess be?
Base to resistor - resistor to your sensor. Emitter to ground, collector to arduino input (enable internal pull ups or put an external pull up from collector to +5.

Check how much current your sensor can supply, some hall effect sensors are very limited in output current.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 38
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
How wrong can a guess be?

Totally? Thanks for helping a total newbie.  smiley

There are no markings at all on the hall effect sensor.

I did some research and found what you described is as a
Common Emitter Amplifier circuit. I'm having trouble understanding
the math to size the resistors R1 and R2. Am I on the right
track with the circuit below? Can anyone help with the math or
sizing the resistors?



Here is a link to the page describing the Common Emitter Amplifier circuit.
http://webpages.ursinus.edu/lriley/ref/circuits/node4.html

And this one:
http://www.allaboutcircuits.com/vol_6/chpt_5/12.html

And one more:

http://en.wikipedia.org/wiki/Common_emitter
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17262
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

R2 can be near anything at or above 10k ohms. R1 is a little harder to determine as you probably don't know the output impedeance of the hall effect device. I would start out at 500 ohms and see if it causes the transistor to switch on and off.

 You do realize that the logic will be inverted by the transistor stage, a +1 out of hall will be near 0v to the input pin and 0v out of the hall will be +5vdc to the input pin. Not a problem, just need to be aware when you write your code.

Lefty
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 38
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Great. I'll give those a test and see how it works. Thanks much!

Seems like the inversion won't be an issue as all I care about is
reading a change from high to low (or vice-versa) using
attachInterrupt or am I not understanding something?
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17262
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Seems like the inversion won't be an issue as all I care about is
reading a change from high to low (or vice-versa) using
attachInterrupt or am I not understanding something?

Correct, your can have the interrupt happen on a 'rising' input or a 'falling' input or you can always interrupt on 'change' and then just read the input pin to determine if the new state is a high or low inside the interrupt routine (ISR).

Lefty
Logged

0
Offline Offline
Faraday Member
**
Karma: 23
Posts: 3470
20 LEDs are enough
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You can drop R2 completely if you enable the internal pullups. That is write a 1 to the ouput pin to enable the pullup.

Cheers, Udo
« Last Edit: March 05, 2010, 11:57:36 am by udoklein » Logged

Check out my experiments http://blog.blinkenlight.net

0
Offline Offline
Newbie
*
Karma: 0
Posts: 38
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank for all the input guys. I tested it last night and it worked great
both with R2 and using the internal pull up.

Logged

Pages: [1]   Go Up
Jump to: