Switching voltages - Page 1
Forum section: electronics / beginners

author: Ferdkilla
author_rank: Newbie
timestamp: February 14, 2012, 06:06:33 pm
content: I'm in Need of some help/suggestions on some things. This is my first electronics project so bear with me please!I have two momentary switches (one for up and one for down) and voltages 1-5v. What I want to be able to do is when the power is turned on to the component I want it set at 1v then when I push the up switch I want it to go up one volt for every time I push it till it gets to 5v and not exceed 5v. Then when I push the down button I want the voltage to drop 1v for every time I push the button till it stops at 1v and nEver anything less. How do I do this?http://www.dieselplace.com/forum/showthread.php?t=339249<<<<<< this is how i am currently changing the voltages with a rotary switch.

author: sacherjj
author_rank: Frequent Contributor
timestamp: February 15, 2012, 02:40:42 am
content: There are many ways of doing this. You could work up digital logic with up down binary counters and use an R/2R Digital to Analog conversion. That would require a binary counter and at least some type of logic to limit the up count.I would probably use a small microcontroller with two inputs for the switches and a PWM output. (Dave's 4th Power Supply video describes PWM.) Of course, this depends on how accurate you need the voltage steps. The advantage of this setup is that you could decide that you need to change to 0.5V steps with just software changes.FYI - No one can see that thread without registering at the site. I would post the details here if you want us to see it. Also, what the voltage is used for would be helpful.

author: electrode
author_rank: Regular Contributor
timestamp: February 15, 2012, 07:57:11 am
content: You could do it with an up/down binary counter (eg. CD4029) and a DAC (either an IC, or homemade R-2R ladder). I can't see the thread in your link, as I don't have an account, so I'm not sure if you want these voltages for signals, or for supplying power.[Up/Down Pushbuttons]->[Debouncing*]->[Counter**]->->[Op-amp/transistor and/or voltage regulator]* Debounce with an RC filter and a schmitt trigger (Google)** Check the datasheets, but I believe your counter will need some combinational logic to prevent pressing "down" at 1V from wrapping your output back to 5V, and pressing "up" at 5V from wrapping around to 1V. Pretty simple to fix both of these cases with some logic gates (down input to counter only triggers IF <button pushed> AND NOT <at lowest counting number>).Of course, with a microcontroller, you can say goodbye to the debouncing hardware, the counter, any combo logic that might be needed, the DAC and remove the need for pull-up resistors. Doing it all in hardware is cooler and more educational though (IMO).

author: sacherjj
author_rank: Frequent Contributor
timestamp: February 15, 2012, 01:43:34 pm
content: Quote from: electrode on February 15, 2012, 07:57:11 amThat is about where I landed. Doing it all hardware would be cooler and more educational, but I'd go micro if I just wanted to get it done. A tiny little ATTiny or PIC12 would be all you need. But that is learning software too, if that is new to you.If you define the states with:000 - 1V001 - 2V010 - 3V011 - 4V100 - 5V[Stop counting with all bits are low.]Stop Count Down = NOT (B1 OR B2 OR B3)[Just stop counting with Bit 3 goes high]Stop Count Up = B3QUAD OR - 3 used for count down bit detectQUAD NAND - 1 used for Inverting count downUse buttons to pull value low, so a low count down inhibit combined with a low going switch, will generate a positive going NAND output to one of the two clock inputs.I'm probably missing something, as it has been years since I've done raw logic chips. But that was fun.

author: Ferdkilla
author_rank: Newbie
timestamp: February 15, 2012, 02:20:48 pm
content: Thanks for the suggestions guys! What I'm doing is makings a dsp5 (duramax switchable performance 5 position rotary switch) it uses 5.6k ohm,2.2k ohm, 1k ohm, 270 ohm, and 27k ohm resistors wired in the switch to regulated the voltages upon turning the switch. Now I want to dot the same thing the rotary switch does with the resistors but with two tactile button switches. Did I make that clearer or worse lol??

author: sacherjj
author_rank: Frequent Contributor
timestamp: February 15, 2012, 04:22:55 pm
content: What is the voltage going to? Does it have a high impedance input so that it isn't loading the supplier of the voltage or do we need to buffer it.Frankly, I like the reliability of a rotary. But I'm guessing that you are trying to achieve the reset to 1V each start, without having to manually do that. Is that the main driver for this?

author: Ferdkilla
author_rank: Newbie
timestamp: February 15, 2012, 05:31:31 pm
content: With the rotary switch how it works is there is a 5v signal supply coming from the ECM to the switch. When you turn the key on in the truck and the switch is in possition 1 it is at 5v then you turn the switch a notch and the voltage drops to 4v resulting in the file that the ECM is reading to change to the next tune. I want to loose the rotary switch and have one button for dropping the voltage and one for upping the voltage. The entire reason I'm doing this is to make some paddle shifters to change the the tunes with to have something kick ass as SEMA!!

author: sacherjj
author_rank: Frequent Contributor
timestamp: February 15, 2012, 05:51:57 pm
content: Would the start up need to reset back to a fixed state or be in the last state you had selected?

author: Ferdkilla
author_rank: Newbie
timestamp: February 15, 2012, 05:59:11 pm
content: it doesnt matter at all actually what state it starts up in. whichever would be easier to do!

author: sacherjj
author_rank: Frequent Contributor
timestamp: February 15, 2012, 06:08:14 pm
content: How comfortable are you with doing software? Have you done any of that before?

author: Ferdkilla
author_rank: Newbie
timestamp: February 15, 2012, 06:30:47 pm
content: I have never done anything like this before but my brother in law designs apps and test cell phones for AT&T so he will be helping me. He told me to join this forum and learn as much as possible about it first

author: Ferdkilla
author_rank: Newbie
timestamp: February 15, 2012, 06:33:10 pm
content: I also purchased the Arduino UNO package to make a test set up

author: sacherjj
author_rank: Frequent Contributor
timestamp: February 15, 2012, 08:19:14 pm
content: I would work in Arduino then. If you can get it to work with an Uno, then you can build into a smaller and cheaper version to install. Look at Arduino examples for switch denouncing and get push buttons being reliably working first. Them play with PWM output.

author: Ferdkilla
author_rank: Newbie
timestamp: February 15, 2012, 08:38:59 pm
content: Will do! Thank you should I post up pictures and stuff of the process so you all can help me out??

author: electrode
author_rank: Regular Contributor
timestamp: February 15, 2012, 10:08:37 pm
content: Arduino route should be fairly straightforward for you. Only external hardware you need is something to filter the PWM, so that instead of a pulsing wave at the output, you get a time-averaged analogue output. There's much to learn about RC filters by a google search, but I'd suggest a 1uF capacitor and a 100k resistor as a starting point. Basically, the bigger the time constant (RxC), the smoother your resultant voltage, but the slower the response ("slow" usually means microseconds or milliseconds, so not usually a problem with human-operated switches).

author: Ferdkilla
author_rank: Newbie
timestamp: February 15, 2012, 11:14:57 pm
content: This might be a dumb question but can you explain how a pwm works and what pwm stands for?

author: electrode
author_rank: Regular Contributor
timestamp: February 15, 2012, 11:24:07 pm
content: Sure.PWM = pulse-width modulation. Start with a square wave, ie. a simple example of which is just an output toggling between high and low indefinitely at some frequency. PWM is the process of controlling the duty cycle of this square wave (ie. the % of time the wave is high). For example, a 50% duty cycle square wave will be high and low equally, and if connected to an LED, would appear to be half the brightness of the LED if it were constantly on*.This link should help you understand.* Saying this for simplicity's sake. LED apparent brightness is non-linear.

author: Ferdkilla
author_rank: Newbie
timestamp: February 16, 2012, 12:08:15 am
content: Thank you very much sir that cleared up a lot!

author: sacherjj
author_rank: Frequent Contributor
timestamp: February 16, 2012, 04:28:17 am
content: Quote from: Ferdkilla on February 15, 2012, 11:14:57 pmDave gave a good overview of this on the Part 4 power supply video:http://www.eevblog.com/2011/12/07/eevblog-225-lab-power-supply-design-part-4-pwm-control/