Shop OBEX P1 Docs P2 Docs Learn Events
Pulsed DC to constant voltage trigger — Parallax Forums

Pulsed DC to constant voltage trigger

JBernardJBernard Posts: 8
edited 2013-08-08 20:23 in BASIC Stamp
Hi all, trying to finish a small project for a street bike and running into a few issues.
Here's the basis of my idea: I'm turning on an accessory (say headlight, gps, ect) on when the arduino input detects a voltage (bike is running).
Think of it as a timer almost. When bike is running i want a smooth low voltage out of the circuit.

I had a rough prototype i thought was working. I took a reading off the killswitch rail which with a voltage meter measured 0-30'ish volts. The problem is that it was a dirty and pulsed signal. Tricking the accessory and turning it on and off constantly. obviously i need a smoother clean signal. I originally tested the on/off with a AA battery hooked up to the prototype and it worked perfect, so thats what kind of signal i'm after.

So my guess is I need to find a circuit that will take 0-30v (maybe a bit more for safety). and upon seeing any voltage, it will trigger something else to bleed say 2.5v out to a pin i can use for a basic on/off (max input on arduino pin is 5v so i want to stay well under).

This is somewhat like a tachometer, but i dont need to measure the pulses at all. if the 30v is an issue, it's possible I could take a inductance voltage reading off the spark plug wire wrap method, but its way more cluttered than what i have in place now.
Thought about using a frequency to voltage converter. But i dont think i need something that elaborate, where it will lock frequency to a specific voltage.


I'm probably vastly over thinking this, maybe a few caps, resistors and transistor will do?
also, i have a Fluke DMM, but no scope. I know reading the killswitch rail voltage with a scope would help me out a lot, but dont have one available at this moment.

Let me know any ideas! I'm pretty basic in terms of electronics experience compared to most of you guys, but I'm willing to learn!

Thanks,
Taylor

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-08-08 14:49
    Welcome to the Parallax forum, Taylor!

    Here's a circuit that should do what you want:

    attachment.php?attachmentid=103251&d=1375998651

    The 2.2K resistor and the two diodes absorb most of the input current, limiting the voltage to 1.2V. That gets applied to the transistor inverter via the 1K limiting resistor.

    -Phil
    306 x 254 - 1K
  • JBernardJBernard Posts: 8
    edited 2013-08-08 15:03
    Phil,
    Thanks for the quick reply!

    What kind of transistor would you recommend?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-08-08 15:11
    Any general-purpose NPN should work, e.g. 2N3904, 2N4401, PN2222. IOW, anything you can get your hands on from RadioShack.

    BTW, if the input voltage makes any negative excursions, you can add another diode in parallel to the two series diodes, but pointing the opposite way.

    -Phil
  • JBernardJBernard Posts: 8
    edited 2013-08-08 15:33
    great, thank you. going to get some supplies here soon.

    quick VERY beginner question trying to understand this circuit...how does the +5v powering the transistor pin not constantly output a voltage (5v-4.7K resistor) to the output? so wouldnt i be seeing a voltage even if there was no incoming signal before the diodes?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-08-08 15:37
    Upon an incoming signal, the transistor conducts from collector to emitter, effectively shorting the 4.7K resistor to ground.

    -Phil
  • JBernardJBernard Posts: 8
    edited 2013-08-08 15:48
    so any voltage 0-30v on the input should get limited and should show up on the output as 1.2v when running. but will anything be detected on the output if it is not?

    edit*
    or does the transistor act like a switch and when it sees an input opens the +5v to enter the output of the circuit?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-08-08 16:16
    The input voltage gets limited to 1.2V at the diodes. Anything over about 0.7V on the input will cause the transistor to conduct, puliing the output at the 4.7K resistor down to near zero.

    -Phil
  • JBernardJBernard Posts: 8
    edited 2013-08-08 16:29
    ok, another quick question. if the input signal is pulsed and noisy, what part of the circuit is smoothing it out so its not turning on/off rapidly? i figured a cap would be in some part of it.

    and if i want to test this out with a 9v battery pack to make sure it works...i will be fine with red lead into input and black to circuit ground correct?
    sorry for all the beginner questions!
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-08-08 18:31
    You could add a cap across the diodes to increase response time and decrease the effects of noise. Or you could just do the debouncing in your program code. Your choice.

    As to the 9V battery test, sure, go ahead with it.

    -Phil
  • JBernardJBernard Posts: 8
    edited 2013-08-08 19:26
    Phil, got a breadboard up and running and with a 6V battery hooked into the input i'm getting 2.422V on the output. which is great.
    only issue is that when battery is off its jumping back up to 4.85 (assume its getting power reading constantly after that 4.7K resistor.

    goal is to have it read 0V while off, then that 2.5V when switched on.

    Let me know what you think.
    Thanks again for all the help so far, learned a good bit today!

    Taylor
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-08-08 19:46
    Taylor,

    The circuit I supplied is an inverter. It's supposed to read low when the input is high and vice-versa. But 2.422V is not low enough to read as a logic "0." I may have to juggle some of the values. OTOH, you may have reversed emitter and collector in your circuit, which will put the transistor in a less-optimum conduction mode. In the meantime, are you sure that you can't live with a non-inverted output?

    -Phil
  • JBernardJBernard Posts: 8
    edited 2013-08-08 20:07
    phil,
    good thinking. i goofed up and had the transistor wired backwards.
    now she reads 4.85V when off, and .042V when on.

    I can probably suffice with this for now. I reckon in code i could just say if 'INPUT VOLTAGE <3' then 'START TIMER'. and it will do the same thing.
    I'm testing with battery right now so theres no fluctuation in the voltage reading at all. youre saying when i hook this up to a noisy DC circuit it should behave the exact same way it is now?

    do you mind clarifying one more time how the circuit above smooths out the pulsed dc current before it hits the transistor? whats to keep the current setup from pulsing the output voltage if the input is pulsed?

    I dont have a scope, but another member here was doing something similar and this is what his reading looked like, I would bet my voltage off the killswitch would be VERY similar since its straight from the CDI box as well...
    also, the voltage reading i was getting before was higher based on RPM. highest reading i got was around 30V and at idle it was 3-7V.

    NewFile0.jpg

    you can see why my arduino was giving me problems before. i think it was taking a reading every 100ms or so to check for voltage, so it was a roll of the dice on wether it hit on an actual voltage peak or not to be able to turn on or off.
    printing back in the serial window gave results like this when bike was running -> 0,0,0,0,0,0,0,5,5,0,0,0,7,0,0,0,0,15,0,0,4,0,0,8
    thus turning the unit on and off constantly. even though the bike was running. it was thinking it was turning on and off rapidly due to the pulsing.

    thanks again!
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-08-08 20:11
    That scope trace is showing some negative excursions. Please see my suggestion regarding that in post #4.

    -Phil
  • JBernardJBernard Posts: 8
    edited 2013-08-08 20:23
    ok, will do. just a diode in opposite direction than the ones in series, before the 1K resistor and tied to ground?

    also made some edits i think while you were posting, if you dont mind re-reading it.
    thanks again, would buy you a beer if you were down in Houston, 103* today. ouch.

    one thing i forgot. is that the arduino i'm using has a Atmega328P.
    the board is ultra-low power. and i'm powering it with a 3.7v 150mAh micro sized LiPo battery. The board has a stepup 5V rail, but also a 3.3V
    will this circuit draw a lot of power? should i use the 3.3V to the transistor instead?
Sign In or Register to comment.