How to programmatically vary voltage?

Thread Starter

geekman92

Joined Apr 5, 2013
9
Hi guys! =)

I'm a programmer not an electrician so bare with me!! :p

I have a motor controller that controls the speed of a motor by reading a voltage between 1.2v and 3v.

I would like to control this motor (via the controller) from an arduino/raspi, how would I go about programmatically varying the voltage from the 3.3v pin between 1.2v and 3v?

I have done a bit of research and come up with a few possible ideas:

  1. Using a digital potentiometer as a varying voltage divider.
  2. Using PWM through a filter. (I know you can use PWM to control motors but don't know if it will work with motor controllers)
  3. Would a variable voltage regulator work?
  4. Could I use a variable DAC?

I have virtually no electronics experience so I have no idea if any of these would work. Please could someone suggest what is the best way to vary the voltage?

Thanks in advanced!
 
Last edited:

tshuck

Joined Oct 18, 2012
3,534
You could go the route of PWM through a fillet, but our isn't terribly good. I would probably use a DAC, can be made by a R-2R resistor arrangement. this allows a digital value to create an analog voltage.

Since it just reads the voltage on a pin, most of your solutions would work.
 

Thread Starter

geekman92

Joined Apr 5, 2013
9
Thanks for the quick reply, sorry I haven't been as quick!!

Okay so PWM is ruled out!

If I used DAC I would probably use an IC DAC instead of an R-2R ladder but thanks for the suggestion.

Can anyone suggest a good DAC for my purpose? After a quick search on farnell.com I was looking at using the MCP4921, any thoughts?! =)

Thanks
 

crutschow

Joined Mar 14, 2008
34,464
If you filter the PWM signal properly to give a DC level and don't need high accuracy (say better than 2%) you likely could use that.

How fast do you need to vary the signal?
 

t06afre

Joined May 11, 2009
5,934
Since your load is a motor. Some ripple is acceptable. Hence the PWM way of doing it should be fine. Using a DAC IC would also work well. Pick one in the 10 to 12 bit range. If this is a hobbyist project. Be sure to select one in DIP package. You can use DIP package as selection criteria at Farnell
 

Thread Starter

geekman92

Joined Apr 5, 2013
9
Hi thanks for your responses

I think I am going to go the DAC IC route as it's less for me to cock up and don't have to worry about creating the right filter for my needs!

Yes I was looking at getting a DIP and the filter section of Farnell is great! =)

So would this MCP4921 IC be okay?

Thanks
 

t06afre

Joined May 11, 2009
5,934
Yes it will do the job. In addition you will also need some kind of voltage reference. At the Vref input. If you select a common 4.096 or 2.048 type. Your output resolution will be respectively 1 mV or 0.5 mV. This can make the output scaling more easy.
 

Thread Starter

geekman92

Joined Apr 5, 2013
9
Yes for the price of the IC it seems the best way to go! :)

As I have never worked with electronics before I'm trying to piece all this info together as I go along so please can you just clarify some things for me?

  1. On the DAC it has Vdd, Vss, and Vref.
    • Is Vdd the voltage to supply power to the PIC?
    • Is Vss the ground?
    • Is Vref the voltage source that the DAC changes, between 0 and Vref, depending on what command you send it?
  2. What is the difference between a voltage reference and a voltage regulator?
  3. How do you control the voltage reference? They only seem to have Anode, Cathode and Vref.

Thanks for all your help so far! =)
 

Thread Starter

geekman92

Joined Apr 5, 2013
9
Yes for the price of the IC it seems the best way to go! :)

As I have never worked with electronics before I'm trying to piece all this info together as I go along so please can you just clarify some things for me?

  1. On the DAC it has Vdd, Vss, and Vref.
    • Is Vdd the voltage to supply power to the PIC?
    • Is Vss the ground?
    • Is Vref the voltage source that the DAC changes, between 0 and Vref, depending on what command you send it?
  2. What is the difference between a voltage reference and a voltage regulator?
  3. How do you control the voltage reference? They only seem to have Anode, Cathode and Vref.

Thanks for all your help so far! =)
Hi sorry to be a best but can anyone help me with my questions?

Thanks! =)
 

Gibson486

Joined Jul 20, 2012
355
A Dac is just a very precise digi pot.

Vdd is power, Vss is ground Vref is the rail you use to supply your reference voltage. In lots cases, Vref and Vdd are connected because the device will run on 5V and you need to modulate 5V. If you need the reference to be very stable (your measurement cannot tolerate more than 2% error or your shared rail is not stable enough) or your volatge reference is something unique (like 3.3V), then you would use a voltage reference.
 

crutschow

Joined Mar 14, 2008
34,464
2. A voltage reference is a voltage regulator that regulates a voltage (generally feeding a low current load) with more stability than a typical voltage regulator.

3. Some voltage references can be adjusted, others have a fixed output that can't be adjusted. If you look at a voltage reference product list from companies like TI or Linear Technology, you will find several examples of both types.
 

Thread Starter

geekman92

Joined Apr 5, 2013
9
Oh okay! Thank you people! Your information has helped me a lot and I know feel I can buy some components and start on my project!

Thanks again for all your help! =)
 

Thread Starter

geekman92

Joined Apr 5, 2013
9
Hi t06afre,

I was going to use a 3v reference.

I did take into account your post suggesting I use a 4.096 or 2.048 type but unfortunately neither of them would work. I can't use a 4.096 type as the voltage from the arduino is 3.3v and I can't use the 2.048 type as I need a voltage range from 0-3v.

I am thinking of using a different arduino board or the the raspberry pi and use the 5v pin so that I can use a 4.096 type but I need to have a conversation with my friend to discuss this option.

Thanks! =)
 

t06afre

Joined May 11, 2009
5,934
If you have acess to 5 volt. It should be very easy to make it so you power the DAC with 5 volt. But connect it to a 3.3 volt controller. As I can see from the datasheet. Your DAC has only digital input pins. And it is perfectly OK to connect an output from a 3.3 volt system to a 5 volt system input pin
 

Thread Starter

geekman92

Joined Apr 5, 2013
9
Yes I figured that it would be okay to do so it's just some models (and indeed the model we were thinking of using) only have a 3.3v pin and not a 5v! I will talk to my friend and suggest we use a model with a 5v pin so we can then use a 4.096v reference.

Oh also just looking at voltage references, do I want a series or a shunt type?

Thanks for all your help so far! =)
 

t06afre

Joined May 11, 2009
5,934
Just to have mention that. It is not that important to use a voltage reference that give 1 or .5 volt mV steps. I mentioned it because it could do your programming somewhat more easy. IF changing to a 5 volt system give you trouble with the hardware. I would have stayed with a 3.3 volt system. After all it is much more easy to make adjustments in software:)
 

Thread Starter

geekman92

Joined Apr 5, 2013
9
Okay thanks for that, useful to know! Yer I realised it would make the coding easier as 2**12=4096 and I'm using a 12-bit DAC! I'll just talk over with my friend and see what the best solution for us would be! :)

What is the difference between shunt and series references and which one should I be using?!

Thanks!
 
Top