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.
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?
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.
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.
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.
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.
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!
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.
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?
Just looking for a couple set voltages around 4.3 and 4.7 volts for this project. However; I'm also looking for a design that would allow me to use this same design in other projects for dimming leds where PWM is not possible.
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.
Well your schematic shows the emitter is GROUNDED, thus output will always be zero.
It's obvious to me that there should be a resistor on the emitter and your output pulled from across it, just drawn wrong.
Mike.
I got the idea from here My PIC Projects
read down to the sine wave I did it for the voltage not a sine wave. so i'm just setting the port to get what voltage I need.