Author Topic: Level shifting DC signal  (Read 8524 times)

0 Members and 1 Guest are viewing this topic.

Offline BillyJTopic starter

  • Contributor
  • Posts: 10
Level shifting DC signal
« on: June 26, 2013, 06:39:57 pm »
I'm in the middle of a project in which I'm making a digital, open source, dashboard for my motorcycle.

After probing the current dash connections i have come across a problem.

The tachometer on the bike gives off a varying dc voltage between  5 and 6 (ish) volts.
I need to get this to 0-5v for my Arduino so it can read ADC and make sense of the signal.
My thoughts are to:

dc-dc converter down to 0-1v, and then opamp amplify it by 5 to 0-5v?

What do you guys think?

Thanks,
Billy
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
Re: Level shifting DC signal
« Reply #1 on: June 26, 2013, 06:47:07 pm »
A single op amp stage configured to subtract 5V and amplify by 5 will do. Look up the different types of summing amplifier.

DC-DC converters are for power.
No longer active here - try the IRC channel if you just can't be without me :)
 

Offline Dave

  • Super Contributor
  • ***
  • Posts: 1352
  • Country: si
  • I like to measure things.
Re: Level shifting DC signal
« Reply #2 on: June 26, 2013, 07:09:10 pm »
Why even bother with an ADC? Just use a comparator and feed your controller with a digital signal. ::)
<fellbuendel> it's arduino, you're not supposed to know anything about what you're doing
<fellbuendel> if you knew, you wouldn't be using it
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
Re: Level shifting DC signal
« Reply #3 on: June 26, 2013, 07:10:59 pm »
What if he wants more than 1 bit resolution...?
No longer active here - try the IRC channel if you just can't be without me :)
 

Offline BillyJTopic starter

  • Contributor
  • Posts: 10
Re: Level shifting DC signal
« Reply #4 on: June 26, 2013, 07:11:57 pm »
Why even bother with an ADC? Just use a comparator and feed your controller with a digital signal. ::)

OK this sounds good. But wouldn't that just give me a high or low out. I want a varying voltage, i just want it to be between 0v - 5v, not 5v - 6v

Also with the summing amplifier, could you lead me a bit more in the right direction. I've done very little on op-amps. (How would i get it to drop off the 5v. I can easily get it to amplify 5 times though.)
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
Re: Level shifting DC signal
« Reply #5 on: June 26, 2013, 07:16:51 pm »
Alternately, use an inverting amplifier, but invert around 5V instead of ground, with 5x gain. You can do that with no additional power rails if you use an op amp with rail to rail input and output. The signal will be inverted, which you can correct in software.
No longer active here - try the IRC channel if you just can't be without me :)
 

Offline BillyJTopic starter

  • Contributor
  • Posts: 10
Re: Level shifting DC signal
« Reply #6 on: June 26, 2013, 07:20:32 pm »
I don't fully understand.


So GND becomes +5v
Rf/Rin = 5
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
Re: Level shifting DC signal
« Reply #7 on: June 26, 2013, 07:21:57 pm »
Precisely. Again, you must use an op amp that allows rail-to-rail input and output, or this won't work.

Think of it in terms of this op amp behavior: it "tries" to make both inputs equal. If + is 5V, then - will be 5V as well. That will apply (x-5) across Rin, and to keep - equal to 5V, the op amp will have to put 5-5(x-5) on its output (Ohm's law and the fact that the current through both resistors is equal).

Rail to rail means it can go very close to its power supply voltages. Hopefully someone else can suggest a good one, because I don't use R-R much and refuse to navigate DigiKey on my phone...
« Last Edit: June 26, 2013, 07:27:46 pm by c4757p »
No longer active here - try the IRC channel if you just can't be without me :)
 

Offline BillyJTopic starter

  • Contributor
  • Posts: 10
Re: Level shifting DC signal
« Reply #8 on: June 26, 2013, 07:25:15 pm »
I got lucky with the last post, but i have no idea now?  |O

What is rail-rail input and output?
 

Offline Dave

  • Super Contributor
  • ***
  • Posts: 1352
  • Country: si
  • I like to measure things.
Re: Level shifting DC signal
« Reply #9 on: June 26, 2013, 07:31:59 pm »
Ha, I just assumed he wanted to measure the frequency of the tachometer or speedometer signal. My bad.

Ah, I see you beat me to it, I was putting together a simulation in multisim for the exact same thing.
Both graphs have zeros at -3 div and are set to 1V/div. The top graph is the input signal, the bottom graph is the output.
<fellbuendel> it's arduino, you're not supposed to know anything about what you're doing
<fellbuendel> if you knew, you wouldn't be using it
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
Re: Level shifting DC signal
« Reply #10 on: June 26, 2013, 07:34:38 pm »
Remember that LM358 is not rail to rail, so the waveform output would be very distorted if you tried running on just the existing +5V supply. Anyone know any good R-R op amps?
No longer active here - try the IRC channel if you just can't be without me :)
 

Offline BillyJTopic starter

  • Contributor
  • Posts: 10
Re: Level shifting DC signal
« Reply #11 on: June 26, 2013, 07:37:17 pm »
You guys are incredible pros.  :clap:

Can i just double check this:



non-inverting input(+) = 5v
Rf/Rin = 5 (i.e. 50k/10k)
Power rails are going to be +5v and -5v

Also if rails are going to be + and - 5, is there a regulator that will take +12v and give me -5v?
 

Offline Rufus

  • Super Contributor
  • ***
  • Posts: 2095
Re: Level shifting DC signal
« Reply #12 on: June 26, 2013, 07:46:26 pm »
The tachometer on the bike gives off a varying dc voltage between  5 and 6 (ish) volts.

I think the chances of a tachometer signal on a vehicle being a dc level between 5 and 6 volts are microscopic. When you say probing so you mean looked at them with a multimeter?
 

Offline BillyJTopic starter

  • Contributor
  • Posts: 10
Re: Level shifting DC signal
« Reply #13 on: June 26, 2013, 07:48:00 pm »
Yes, from what i could see with the analog meter i had available. The voltage with smoothly go between 5 and 6v when the tacho went up.

Could this be false readings from PWM maybe?
 

Offline Rufus

  • Super Contributor
  • ***
  • Posts: 2095
Re: Level shifting DC signal
« Reply #14 on: June 26, 2013, 07:57:07 pm »
Yes, from what i could see with the analog meter i had available. The voltage with smoothly go between 5 and 6v when the tacho went up.

Could this be false readings from PWM maybe?

Most likely some form of pulse per rev. The average dc level shifting with revs might just be the battery voltage shifting.
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
Re: Level shifting DC signal
« Reply #15 on: June 26, 2013, 07:58:07 pm »
Good point.
No longer active here - try the IRC channel if you just can't be without me :)
 

Offline BillyJTopic starter

  • Contributor
  • Posts: 10
Re: Level shifting DC signal
« Reply #16 on: June 26, 2013, 08:00:04 pm »
Hmm, do you by any chance know how common digital tachos are fed.

Or how i measure PWM, I have one of those small pocket oscilloscopes(Have access to).
 

Offline BillyJTopic starter

  • Contributor
  • Posts: 10
Re: Level shifting DC signal
« Reply #17 on: June 26, 2013, 08:06:31 pm »
Well when revved, the bike went from 5V to 6V relative to the engine speed.

This could be the on board charger kicking in (Probably is) but is there an easy way to measure pulse width modulation?
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
Re: Level shifting DC signal
« Reply #18 on: June 26, 2013, 09:05:11 pm »
With an oscilloscope? Just divide the duration of the "high" period by the entire period of the waveform. Many oscilloscopes can measure it for you.

With a microcontroller? Get the signal down to a level that can go into a digital input on the MCU (or the comparator - can't remember how fast the comparator is on one of those, I never use it) and count the time between edges.
No longer active here - try the IRC channel if you just can't be without me :)
 

Offline cthree

  • Frequent Contributor
  • **
  • Posts: 258
  • Country: ca
Re: Level shifting DC signal
« Reply #19 on: June 27, 2013, 05:10:04 am »
What's wrong with a simple voltage divider? Two 470 ohm resistors will drop your 5-6V to 2.5-3.0V What is the lowest valid voltage you expect to read on the ADC? Choose the resistor size based on how much current your ADC pin can sink.

Tachs use pulses from a position sensor on the crank. Speedos use pulses from a sensor in the transmission output shaft (after the gearbox). You'll need to adjust for the final drive ratio and tire diameter using math. Use a counter/timer to count the pulses within a specific time frame. What microcontroller are you using? The datasheet will have a section on how to use the counter/timer function. The ATmega328 for example has both 8 and 16 bit counter/timers.

I don't know how the ECU is delivering this to your dash so I'm not sure what else to tell you.
 

Offline Paul Price

  • Super Contributor
  • ***
  • Posts: 1419
Re: Level shifting DC signal
« Reply #20 on: June 27, 2013, 10:13:09 am »
"The tachometer on the bike gives off a varying dc voltage between  5 and 6 (ish) volts.
I need to get this to 0-5v for my Arduino so it can read ADC and make sense of the signal.
My thoughts are to:"

I think you are all barking up a tree. 

Why would a tach output range between 5 and 6 volts? 

As anyone  reasoned that the original measurement of the tach output levels was wrong.

What if  a pulldown resistor to ground or a resistor pullup to the +12 battery was needed or it was a kinda 20mA serial loop interface?
« Last Edit: June 27, 2013, 12:39:44 pm by Paul Price »
 

Offline amyk

  • Super Contributor
  • ***
  • Posts: 8270
Re: Level shifting DC signal
« Reply #21 on: June 27, 2013, 11:33:43 am »
If you can get access to an oscilloscope, you should use one to see what the signal looks like.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf