Level shift 0v-1v signal to attachInterrupt

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?

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

Cheers, Udo

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

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

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?

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.

How wrong can a guess be?

Totally? Thanks for helping a total newbie. :slight_smile:

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:

And one more:

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

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?

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

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

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