PDA

View Full Version : How can I get a PIC to switch 2.5V DC to my Opamp pin?



HankMcSpank
- 6th November 2009, 00:15
So I found this little circuit that works well for my needs - the circuit takes one small analogue signal into an opamp & when a SPST switch is flicked, the opamp output changes from non-inverting to inverting.

http://img260.imageshack.us/img260/7429/polarityswitch.jpg (http://img260.imageshack.us/i/polarityswitch.jpg/)

I've changed the circuit to illustrate my needs - it normally switches a ground to the non inverting pin - that's fine if you're using dual rail/supply opamp circuits - but all my circuit is single rail & therefore my opamp pins input pins aren't biased at ground potential ..........my circuit uses a single rail of 5V - therefore all my opamps are biased at VCC/2 .... 2.5V.

So therefore rather than switch a ground to the non inverting pin (which would have been easy to do with a PIC!) ...I'm faced with having to switch 2.5V - so I'm looking for a way to get the PIC to do this with the lowest component count possible! Also, I want to avoid relays as I just don't have the PCB real estate available.

Now Melanie touched upon a way of switching to 5V/0V from a mid 2.5V DC potential (http://www.picbasic.co.uk/forum/showthread.php?t=11163 ) ...but I can't see how I could use her clever little suggestion in this instance - because the cicuit above is an on off switch.

Any ideas?

Pic_User
- 6th November 2009, 01:28
So I found this little circuit that works well for my needs - the circuit takes one small analogue signal into an opamp & when a SPST switch is flicked, the opamp output changes from non-inverting to inverting.

I've changed the circuit to illustrate my needs - it normally switches a ground to the non inverting pin - that's fine if you're using dual rail/supply opamp circuits - but all my circuit is single rail & therefore my opamp pins input pins aren't biased at ground potential ..........my circuit uses a single rail of 5V - therefore all my opamps are biased at VCC/2 .... 2.5V.

So therefore rather than switch a ground to the non inverting pin (which would have been easy to do with a PIC!) ...I'm faced with having to switch 2.5V - so I'm looking for a way to get the PIC to do this with the lowest component count possible! Also, I want to avoid relays as I just don't have the PCB real estate available.

Now Melanie touched upon a way of switching to 5V/0V from a mid 2.5V DC potential (http://www.picbasic.co.uk/forum/showthread.php?t=11163 ) ...but I can't see how I could use her clever little suggestion in this instance - because the cicuit above is an on off switch.

Any ideas?
Hi Hank,

Keep in mind I have never tried anything like this.
http://www.picbasic.co.uk/forum/attachment.php?attachmentid=3773&stc=1&d=1257470837
If you set Pin A to 5V and Pin B to 0V you should get the difference divided by the Voltage divider (2.5V).
If you set Pin A and Pin B to “float” you should get no voltage.

Just a theory, let us know about the reality.
May be too much noise on the floating resistors for your circuit.

-Adam-

HankMcSpank
- 7th November 2009, 00:15
Hi Adam,

That's worth a try (& pretty much the same as what Melanie advised in that post I linked to - but I couldn't see how I could use her suggestion in this instance)....I should get a go at it over the weekend - I'll report back.

thanks once again.

HankMcSpank
- 7th November 2009, 02:00
Well, I tried it - the good news is that when the 2.5V is switched in I get a nice clean inverted signal (vs the input) as seen at the output.

However, when I switch those pins off to remove the 2.5V (ie turn the corresponding pins into high impedance - by changing them to input pins), I get a terribly distorted waveform as seen at the output of the opamp.

I think I'm going to have to bite the bullet and make space for some bilateral switches in my circuit :-(

Thanks anyway.

mtripoli
- 9th January 2010, 22:04
I'll throw this out there; you'll have to try it yourself to verify it. If you have a split rail power supply of +/-2.5V then connect Vss of the PIC to -2.5V and Vdd to +2.5V. Anything that is connected to "GROUND" in the PIC circuit should connect to -2.5V. Basically, a device is only concerned with "potential" difference from Vss to Vdd. So now, "ground" is -2.5V, Vdd/2 is 0V and "logic high" is +2.5V. You'll be able to use standard code with one pin and no resistor biasing or anything.

IF it is a +5V device you can use a split supply like this (of course you need to pay attention to absolute max ratings, you can't use +/-3V, this adds up to 6V).

There are all sorts of caveats you need to keep in mind when doing things like this; if there is DC connection to ANYTHING on the outside world then "ground" is (most likely) going to be 0V (zero volts). This will mess things up. All parts of your circuit that are "digital" will have to be arranged the same way. AC coupling (say the input to the opamp) should be will be ok, just so long as you remember that the input signal is "referenced" to 0V.

Also (I said there would be caveats) you'll have to take into consideration a scheme for doing ICSP. Without seeing the circuit I couldn't guess what else...

Unfortunately I've been in situation that I've had to play all sorts of games with odd "ground" schemes in the past. I did a project years ago for a huge (gigantic) appliance manufacturer where they used a "positive ground" scheme so that the circuit used two less transistors (please, no lectures on designing for large scale production; I design consumer electronics and know the ramifications of each component in a circuit). However, if it means that a repair person makes the "assumption" that the circuit is "grounded" (meaning "0V referenced") and connects a "grounded" mains supplied tester to the circuit and sparks fly, I'll go for the extra two resistors.

Anyone remember "floating" TV chassis...?