Author Topic: HELP: +/- Variable Voltage from uC  (Read 7098 times)

Offline sparky961

  • Hero Member
  • *****
  • Posts: 844
  • Country: ca
HELP: +/- Variable Voltage from uC
« on: February 23, 2013, 11:54:48 AM »
I tried to be succinct in the subject of this post.  That's pretty much it, I'm trying to think of the easiest or best way to have software control of signal ranging from +10V to -10V.  The software and digital hardware parts I have no problem with, but any analogue circuits involving transistors are a weakness of mine.  Suggestions for simple and effective solutions, or pointing me in the right direction would be greatly appreciated.

At my disposal and seeming to have promise are the following:
- Powerful uC with multiple 5V PWM outputs
- Plenty of digital I/O pins
- Two separate reference voltage signals, +10 and -10
- Unregulated power supply between 20 and 60VDC

I was thinking maybe using two transistors, NPN and PNP between the +10 and -10 "rails" could be the solution, but wasn't able to get past that point.  the generated voltage is a control signal and doesn't need much current.

-Sparky

Offline sparky961

  • Hero Member
  • *****
  • Posts: 844
  • Country: ca
Re: HELP: +/- Variable Voltage from uC
« Reply #1 on: February 23, 2013, 12:00:43 PM »
Hmm... or maybe an OpAmp?  Not sure why I didn't think of that before posting the first question.  I'm going to look into that.

Offline Bluechip

  • Madmodder Committee
  • Hero Member
  • *****
  • Posts: 1513
  • Country: england
  • Derbyshire UK
Re: HELP: +/- Variable Voltage from uC
« Reply #2 on: February 23, 2013, 01:08:55 PM »
You need to be a bit more specific.
 
If you use the digital outputs into an op-amp adder [ summing ] circuit, you'll get just about any output you want, except it will be inverted.
 
So, you just need to invert it again with a unity gain inverting buffer.
 
Some stuff in these, particularly the latter.
 
Dave BC
 
http://www.bing.com/images/search?q=op+amp+adder+circuit&qpvt=op+amp+adder+circuit&FORM=IGRE
 
http://www.ti.com/lit/an/slod006b/slod006b.pdf
 
 
I have a few modest talents. Knowing what I'm doing isn't one of them.

Offline sparky961

  • Hero Member
  • *****
  • Posts: 844
  • Country: ca
Re: HELP: +/- Variable Voltage from uC
« Reply #3 on: February 23, 2013, 01:19:34 PM »
Thanks for your input Dave.  The best solution would  limit the number of pins and discrete components, so I'm interested to see what else there would be that performs the same function with fewer components.  I'd like to see about 8 bits of resolution in the output signal.

Whether the output is inverted or not doesn't matter, as I can design for the polarity in firmware.

To simplify, what I think I need is a circuit that converts 0 -> +5V into a proportional -10 -> +10V signal, so a gain of 4? and offset of.... ?  Ok, that's where I start to get lost. :)

Offline Bluechip

  • Madmodder Committee
  • Hero Member
  • *****
  • Posts: 1513
  • Country: england
  • Derbyshire UK
Re: HELP: +/- Variable Voltage from uC
« Reply #4 on: February 23, 2013, 01:58:15 PM »
You might like to look at one of these ..
 
http://www.ti.com/lit/ds/symlink/dac0808.pdf
 
Or two ??
 
One of the diagrams has a negative Vref, I'm not sure if this implies you can get negative voltages out of them or not.
 
I have used this ic. but never negative, always with a +ve output.
 
But if I undestand the thing, it will drive to more than 10V .. Last time I faffed with one, it was to +5V .. not recently either ..  :scratch:
 
Dave BC
I have a few modest talents. Knowing what I'm doing isn't one of them.

Offline sparky961

  • Hero Member
  • *****
  • Posts: 844
  • Country: ca
Re: HELP: +/- Variable Voltage from uC
« Reply #5 on: February 23, 2013, 05:09:00 PM »
Here's a circuit and simulated data, which is pretty much what I'm looking for.  The LM741 doesn't output full rail to rail voltage, hence the approx. +/-7.5 V output.

However, when I tried this in actual hardware the results didn't come close to the simulation.  <sigh>

If this were to work, it should only require 1 PWM output pin, plus the discrete resistors and small IC.  I'm not sure why it doesn't work though.

Offline DMIOM

  • Hero Member
  • *****
  • Posts: 676
  • Country: gb
  • Isle of Man
Re: HELP: +/- Variable Voltage from uC
« Reply #6 on: February 23, 2013, 05:14:01 PM »
Sparky,

Would there be any chance you share a bit more about the target? and about the accuracy you need? - is it for speed? or absolute position?

One of the reasons I ask is because I have had both servo drives and spindle inverters which both wanted +/- 10v and in both cases by reconfiguring the target I could get it to work with 0..10v and a logic input for direction (IIRC the inverter was ABB, can't recall the servo drive but it was Italian...)

If you do try and look at making your own by generating, say, 0-20v and then offsetting zero, you can get into all sorts of bother with both disparate ground/0v rails, and more especially/dangerously zero drift.

Dave

Offline sparky961

  • Hero Member
  • *****
  • Posts: 844
  • Country: ca
Re: HELP: +/- Variable Voltage from uC
« Reply #7 on: February 23, 2013, 05:26:33 PM »
You were going in the right direction, Dave.  It's for controlling a BLDC Servo drive that wants a control signal in the range of +/- 10V.  It supplies a low current reference +10V and -10V that I think I could leverage but need the glue between that, the microcontroller, and the input.

The attached picture shows what's required and available from the servo drive.

Offline DMIOM

  • Hero Member
  • *****
  • Posts: 676
  • Country: gb
  • Isle of Man
Re: HELP: +/- Variable Voltage from uC
« Reply #8 on: February 23, 2013, 05:59:08 PM »
Sparky,

have you got any documentation for the BLDC drive?  Based on others I've seen, I would say there's a fighting chance there may be some jumper block / DIL switch / solder-bridge header / header for resistors in there.....

What sort of response rate & accuracy are you looking for?

Dave

Offline sparky961

  • Hero Member
  • *****
  • Posts: 844
  • Country: ca
Re: HELP: +/- Variable Voltage from uC
« Reply #9 on: February 23, 2013, 07:08:43 PM »
I have some documentation for a slightly different model.  It mentions fine tuning with discrete components, but not changing the input voltage signal.  I've opened the case and also found no indications that the makers intended to have this changed.

As for accuracy & response rate, well, I'm aiming for as good as I can reasonably get.  That said, This will be part of a PID control loop, so I don't think it needs to be perfect.  The rest of the system should be able to compensate for minor errors.

I've simulated a non-inverting version of the op-amp circuit (yes, I've been hard at this all day now...) and it looks promising.  I'm going to reconfigure the hardware and see if it works any better.

Offline sparky961

  • Hero Member
  • *****
  • Posts: 844
  • Country: ca
Re: HELP: +/- Variable Voltage from uC
« Reply #10 on: February 24, 2013, 02:05:35 AM »
For the record, this is what I came up with today (attached).  It seems to work well and I'm well on the way to implementing a PID control loop.  You might see a project that uses these in the near future.

Thanks for all of the advice and suggestions.  If anyone has a simpler idea that uses less components, speak up. :)

Offline srm_92000

  • Jr. Member
  • **
  • Posts: 72
  • Country: england
  • In NW Leicester
Re: HELP: +/- Variable Voltage from uC
« Reply #11 on: February 24, 2013, 05:31:13 AM »
Hi there,
From what you've done already you probably know this, but I just thought I'd say in case it had slipped by.
The thing is that you say you are using a PWM output which is not a 0 to 5v signal it is a 0 or 5v signal with the duty cycle of on-off changing, so the output would be a -10 to +10 PWM following(or maybe inverted) the input unless the incoming PWM is greatly smoothed and filtered to provide an average voltage output.
Hope this makes sense,
Steve,
I put it back together using all the right parts,
just not necessarily in the right order.:scratch:
(Eric morecambe - ish)

Offline sparky961

  • Hero Member
  • *****
  • Posts: 844
  • Country: ca
Re: HELP: +/- Variable Voltage from uC
« Reply #12 on: February 24, 2013, 11:44:33 AM »
Thanks for pointing out this very important fact, Steve.  Yes, I am indeed using an RC filter on the amplifier's input.  I tried first to see how well it would work without the filter, but the motor was not running smoothly.

I've been working with microcontrollers for almost 15 years now, and on this project I'm trying out one of the Arduino compatible boards.  From what I can see so far, "Arduino" could be replaced with "Microcontrollers for Dummies" because it greatly simplifies and glazes over some of the more difficult parts of microcontroller development.

Not that I'm complaining.  It enabled me to get up and running very quickly with minimal screwing around with initialization and figuring out which bits I needed to tweak this way and that.  While I was collecting information for this, I saw a posting online where someone said they were _surprised_ to learn that analogWrite() didn't actually output an analog signal, rather a square wave (aka PWM).  Though I think it's good that more people are making things using microcontrollers, I'm afraid that there's going to be a lot of mistakes made because of false assumptions due to a lack of knowledge.

It's sort of like programming for a PC these days.  Even I don't care much what's going on behind the scenes, though I do understand a lot of what goes on behind the scenes.

Thanks for putting up with my rant.  :)

-Sparky

Offline srm_92000

  • Jr. Member
  • **
  • Posts: 72
  • Country: england
  • In NW Leicester
Re: HELP: +/- Variable Voltage from uC
« Reply #13 on: February 24, 2013, 07:01:44 PM »
Ah - good stuff,
I thought you might already have got this sorted.
I'm still stuck using pic's - too set in my ways on the wrong side of 50 so I just keep on using what I'm used to.
I quite fancy buying a raspberry pi though just to play with. I've got no idea what to use it for though so I can't justify the cost (not the thing itself, just all the add ons I know I'll need once I get one :thumbup:
Steve,
I put it back together using all the right parts,
just not necessarily in the right order.:scratch:
(Eric morecambe - ish)