Author Topic: Switching voltages  (Read 7204 times)

0 Members and 1 Guest are viewing this topic.

Offline FerdkillaTopic starter

  • Newbie
  • Posts: 9
Switching voltages
« on: February 14, 2012, 06:06:33 pm »
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.
 

Offline sacherjj

  • Frequent Contributor
  • **
  • Posts: 993
  • Country: us
Re: Switching voltages
« Reply #1 on: February 15, 2012, 02:40:42 am »
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.
 

Offline electrode

  • Regular Contributor
  • *
  • Posts: 141
  • Country: au
Re: Switching voltages
« Reply #2 on: February 15, 2012, 07:57:11 am »
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**]->[DAC]->[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).
« Last Edit: February 15, 2012, 08:00:30 am by electrode »
 

Offline sacherjj

  • Frequent Contributor
  • **
  • Posts: 993
  • Country: us
Re: Switching voltages
« Reply #3 on: February 15, 2012, 01:43:34 pm »
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).

That 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 - 1V
001 - 2V
010 - 3V
011 - 4V
100 - 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 = B3 

QUAD OR - 3 used for count down bit detect
QUAD NAND - 1 used for Inverting count down

Use 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.
 

Offline FerdkillaTopic starter

  • Newbie
  • Posts: 9
Re: Switching voltages
« Reply #4 on: February 15, 2012, 02:20:48 pm »
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??
 

Offline sacherjj

  • Frequent Contributor
  • **
  • Posts: 993
  • Country: us
Re: Switching voltages
« Reply #5 on: February 15, 2012, 04:22:55 pm »
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?
 

Offline FerdkillaTopic starter

  • Newbie
  • Posts: 9
Re: Switching voltages
« Reply #6 on: February 15, 2012, 05:31:31 pm »
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!!
 

Offline sacherjj

  • Frequent Contributor
  • **
  • Posts: 993
  • Country: us
Re: Switching voltages
« Reply #7 on: February 15, 2012, 05:51:57 pm »
Would the start up need to reset back to a fixed state or be in the last state you had selected?
 

Offline FerdkillaTopic starter

  • Newbie
  • Posts: 9
Re: Switching voltages
« Reply #8 on: February 15, 2012, 05:59:11 pm »
it doesnt matter at all actually what state it starts up in. whichever would be easier to do!
 

Offline sacherjj

  • Frequent Contributor
  • **
  • Posts: 993
  • Country: us
Re: Switching voltages
« Reply #9 on: February 15, 2012, 06:08:14 pm »
How comfortable are you with doing software?  Have you done any of that before?
 

Offline FerdkillaTopic starter

  • Newbie
  • Posts: 9
Switching voltages
« Reply #10 on: February 15, 2012, 06:30:47 pm »
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
 

Offline FerdkillaTopic starter

  • Newbie
  • Posts: 9
Re: Switching voltages
« Reply #11 on: February 15, 2012, 06:33:10 pm »
I also purchased the Arduino UNO package to make a test set up
 

Offline sacherjj

  • Frequent Contributor
  • **
  • Posts: 993
  • Country: us
Re: Switching voltages
« Reply #12 on: February 15, 2012, 08:19:14 pm »
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.
 

Offline FerdkillaTopic starter

  • Newbie
  • Posts: 9
Switching voltages
« Reply #13 on: February 15, 2012, 08:38:59 pm »
Will do! Thank you should I post up pictures and stuff of the process so you all can help me out??
 

Offline electrode

  • Regular Contributor
  • *
  • Posts: 141
  • Country: au
Re: Switching voltages
« Reply #14 on: February 15, 2012, 10:08:37 pm »
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).
 

Offline FerdkillaTopic starter

  • Newbie
  • Posts: 9
Switching voltages
« Reply #15 on: February 15, 2012, 11:14:57 pm »
This might be a dumb question but can you explain how a pwm works and what pwm stands for?
 

Offline electrode

  • Regular Contributor
  • *
  • Posts: 141
  • Country: au
Re: Switching voltages
« Reply #16 on: February 15, 2012, 11:24:07 pm »
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.
 

Offline FerdkillaTopic starter

  • Newbie
  • Posts: 9
Switching voltages
« Reply #17 on: February 16, 2012, 12:08:15 am »
Thank you very much sir that cleared up a lot!
 

Offline sacherjj

  • Frequent Contributor
  • **
  • Posts: 993
  • Country: us
Re: Switching voltages
« Reply #18 on: February 16, 2012, 04:28:17 am »
This might be a dumb question but can you explain how a pwm works and what pwm stands for?

Dave 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/
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf