DAC Output

jwd146

New member
What are the required basic commands to run a DAC output on a complainant such as an LED. Or is this even possible?

I am using a 28x2 and cant figure out how to do this. I currently have the LED on pin a.3 which is not a PWM pin and am wondering if DAC does a similar thing to PWM in terms of perhaps dimming the LED instead of the current setup with high a.3 giving full voltage to the LED

thanks
 

premelec

Senior Member
DAC output is VOLTAGE of limited resolution and apparently fairly high source impedance - take a look at DAC BASIC commands [see these commands by clicking on PICAXE logo at top of this screen - select BASIC commands]. Voltage output is different than PWM output... could be useful to you if you use some external components - like a MOSFET with Source to V- resistor driving the LED from V+ to Drain. Really depends on just what you are trying to do... let us know just what you are trying to achieve...
 

jwd146

New member
DAC output is VOLTAGE of limited resolution and apparently fairly high source impedance - take a look at DAC BASIC commands [see these commands by clicking on PICAXE logo at top of this screen - select BASIC commands]. Voltage output is different than PWM output... could be useful to you if you use some external components - like a MOSFET with Source to V- resistor driving the LED from V+ to Drain. Really depends on just what you are trying to do... let us know just what you are trying to achieve...
Unless I’m completely wrong DAC is for outputting a 0-31 fraction of supply voltage (by default anyway). Is this correct?
I don’t specifically need it for anything, however I’m writing a school report and it would be good to have a better understanding.
Therefore I was trying to simply dim an LED. I’ve read about the dacsetup and daclevel commands but I’m still not sure how to simply run something lIke DAC 15 pinA.3 or whatever the actual command is.
I have no idea if this is possible but thanks anyway
 
Last edited by a moderator:

hippy

Technical Support
Staff member
DACSETUP and DACLEVEL are the commands to setup and control DAC output.

DAC output is only available on one specific pin, A.2 on the 28X2, and that pin will become a DAC output when the DACSETUP command is issued.

The output is effectively a 0-31 fraction of the supply voltage and usually needs to be buffered for external use.

You could probably buffer the output and add a LED+R to that and the brightness will vary because, as the voltage increases, so too will the current through the LED.
 

lbenson

Senior Member
DAC not generally suitable for driving an LED, but a high-brightness red LED+R can be detected in darkness with as little as two tenths of a millivolt, so you might try it and report back. There may be risk of damaging the DAC drivers in the chip, so be prepared to perhaps sacrifice pin C.0 on an 08M2 in the experiment (which is Serial Out, so significant).
 

premelec

Senior Member
@jwd146 - it is a voltage output - you must consider that the voltage is in effect in series with a resistor which in this case may be varying in value with what voltage is selected. For your purposes this may or may not give you a demonstration suitable. If you need any considerable current to the LED this may not be a suitable way [DAC] without external buffering - current amplification.
 

inglewoodpete

Senior Member
You may be able to drive an LED+Resistor if you connect the PIC's DAC pin to the non-inverting input of an op-amp configured as a voltage follower. I haven't tried this but it would be a good place to start experimenting.
 

AllyCat

Senior Member
Hi,

The PIC(axe) "DAC" is effectively a 160k ohm potentiometer (with only 32 positions), so is very unlikely to deliver enough current to illuminate a LED (since the lowest source impedance is about 5k).

In nearly all circumstances it's much better to use a PWM output as the DAC, with an R-C low-pass filter if required (not needed for a LED). This can give up to 1024 separate levels and greater drive current.

Cheers, Alan.
 
Top