Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Tools
Old 10th October 2009, 05:58 AM   #1
Default PIC - Outputting variable voltages

I want to see if I'm on the right track with this. I need a varied voltage leaving the PIC dependant on which way the SPDT switch is set.

And, what if I have a 3 way switch, can I just add another OUTPUT PORT >> RESISTOR >> DIODE?

Do I even need the DIODEs?

Thanks!

superflux is offline  
Old 10th October 2009, 10:25 AM   #2
Default

You could use the built in DAC and an OpAMP. It's a very course 16 level DAC though.

Notes:
Use PORTB and the internal pullups for the switch
You don't need to pullup unused I/O pins, just make them outputs in the code.
You will need decoupling caps.
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com/
blueroomelectronics is offline  
Old 10th October 2009, 11:58 AM   #3
Default What about PWM

You could go away, using a PWM signal duly filtered (two simple RC cells) to get almost any DC output you want.

That would be the way I would go anyway.
__________________
Agustín Tomás
In theory, there is no difference between theory and practice. In practice, however, there is.
atferrari is offline  
Old 10th October 2009, 02:02 PM   #4
Default

Quote:
Originally Posted by blueroomelectronics View Post
Notes:
Use PORTB and the internal pullups for the switch
You don't need to pullup unused I/O pins, just make them outputs in the code.
You will need decoupling caps.
All of the PORTB pins will eventually be used by LEDs.

I was told, or maybe it was a recommendation, to use every pin in order to prevent possible issues with the PIC - interference maybe? It's 100% fine to set unused PORTs to output ant not expect any ill effects?

What size caps and how many? I use a 1 uf 25v cap close to the 5v supply and ground on every PIC. The incoming power gets a 100uf before it hits the regulator. I should have put it in this schematic - is that sufficient?

Thanks!
superflux is offline  
Old 10th October 2009, 02:12 PM   #5
Default

Quote:
Originally Posted by superflux View Post
I was told, or maybe it was a recommendation, to use every pin in order to prevent possible issues with the PIC - interference maybe? It's 100% fine to set unused PORTs to output ant not expect any ill effects?
Yes, it's 100% fine, it's also 100% fine to set them as inputs as well.

The myth about unconnected inputs comes from the days of CMOS logic gates, where leaving inputs floating caused problems, it doesn't happen with PIC's.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 10th October 2009, 02:17 PM   #6
Default

Thanks guys! You are extremely quick with the helpful replies.
superflux is offline  
Old 10th October 2009, 02:33 PM   #7
Default

Quote:
Originally Posted by superflux View Post
I want to see if I'm on the right track with this. I need a varied voltage leaving the PIC dependant on which way the SPDT switch is set.

And, what if I have a 3 way switch, can I just add another OUTPUT PORT >> RESISTOR >> DIODE?

Do I even need the DIODEs?

Thanks!
Your output will always be zero, your output is wrong, you probably wanted a resistor in the emitter??
binzer is offline  
Old 10th October 2009, 03:10 PM   #8
Default

Quote:
Originally Posted by binzer View Post
Your output will always be zero, your output is wrong, you probably wanted a resistor in the emitter??
To my knowledge, this is a emitter follower scenario. The more voltage placed into the transistor, the higher the resulting voltage out the emitter - no?

Depending on the switch position, either PORTB 6 or 7 will be turned on via software, suppling 5 volts, to the selected port, dropped down slightly by the resistor/diode combo into the transistor.

I am all ears and willing to learn.

Thanks!
superflux is offline  
Old 10th October 2009, 03:24 PM   #9
Default

Quote:
Originally Posted by superflux View Post
To my knowledge, this is a emitter follower scenario. The more voltage placed into the transistor, the higher the resulting voltage out the emitter - no?

Depending on the switch position, either PORTB 6 or 7 will be turned on via software, suppling 5 volts, to the selected port, dropped down slightly by the resistor/diode combo into the transistor.

I am all ears and willing to learn.

Thanks!
hi,
The emitter is grounded to 0V,it will always be 0V.
__________________
Eric " Good enough is Perfect "
I will NOT answer PM's requesting technical help, please use the Forum
PIC tutorials: Nigel's www.winpicprog.co.uk/ Bill's: www.blueroomelectronics.com/
ericgibbs is offline  
Old 10th October 2009, 03:36 PM   #10
Default

superflux, your output circuit is not good for many reasons.
What voltages do you want?
How much current? What are you driving?
go to wikipedia.com and look up r2r ladder (resistor ladder). In their example they use 5 port pins and 10 resistors to get 32 different voltages. The r2r ladder can be made longer or shorter.
ronsimpson is online now  
Old 10th October 2009, 05:36 PM   #11
Default

Quote:
Originally Posted by ronsimpson View Post
How much current? What are you driving?
go to wikipedia.com and look up r2r ladder (resistor ladder).
I need to feed a computer on a motorcycle certain voltages to override some programming. I need very little current - less than .5 ma and voltage from 1.8v to 5v. It's going into the ADC on the ECM of the motorcycle.

I also have a similar situation for giving an LED dual brightness in a situation where PWM is not possible.

Will both schematics, shown below, fly? The top one actually uses an LED which should complete the circuit. However; it seems that with the bottom schematic, using R2R, that anything is possible - I could use that for sending the low current voltages I need as well as controlling LED brightness.

I sincerely appreciate the clarification and your time, guys!



superflux is offline  
Old 10th October 2009, 05:59 PM   #12
Default

hi,
The top circuit will not give the result you require.

The bottom circuit is more inline with the requirement.


EDIT:

Google: dac ladder network
This link will give you an idea.

http://www.ecelab.com/circuit-dac-r2r.htm
__________________
Eric " Good enough is Perfect "
I will NOT answer PM's requesting technical help, please use the Forum
PIC tutorials: Nigel's www.winpicprog.co.uk/ Bill's: www.blueroomelectronics.com/

Last edited by ericgibbs; 10th October 2009 at 06:52 PM.
ericgibbs is offline  
Old 10th October 2009, 07:58 PM   #13
Default

For the LED try this.
Two resistors, one LED, two pins.
Set both pins=0.
Use the tri-state conrole to switch in the resistors.
If both pins are 'input' then no light.
If one pin is 'output' then R1 sets LED current.
If the other pin is 'output' then R2 sets current.
If both pins are 'output' then R1//R2 sets current.
Attached Thumbnails
PIC - Outputting variable voltages-image2.jpg  
ronsimpson is online now  
Old 10th October 2009, 08:28 PM   #14
Default

Quote:
Originally Posted by ronsimpson View Post
For the LED try this.
Two resistors, one LED, two pins.
Set both pins=0.
Use the tri-state conrole to switch in the resistors.
The reason I can't leave both set to OUTPUT and turn 1 on (1) and 1 off (0) would be that the one that is set to 'off' would simply GROUND the voltage coming from the one that was 'on' - correct?
superflux is offline  
Old 10th October 2009, 08:46 PM   #15
Default

What voltages do you need and what sort of current?
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com/
blueroomelectronics is offline  
Reply

Tags
outputting, pic, variable, voltages

Thread Tools
Display Modes


Similar
Title Starter Forum Replies Latest
Driving Higher Voltages from PIC 16F88 Tom81 Micro Controllers 9 18th August 2009 05:49 AM
My OpAmp is only outputting 1.6V - what am I doing wrong? PowerJunkie Electronic Projects Design/Ideas/Reviews 15 17th April 2009 04:43 PM
16f877 pic pin voltages when data is writing uditha33 Micro Controllers 2 6th June 2007 04:26 AM
outputting BCD values on a basic stamp German1981 Micro Controllers 2 12th April 2004 03:58 PM
Reading/outputting voltage magna Micro Controllers 10 4th March 2004 05:42 PM



All times are GMT. The time now is 05:48 AM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker