Config - is a constant/variable specifying the DAC configuration
Configure the DAC (digital to analogue) reference voltage.
Some PICAXE chips have a DAC voltage reference. This may be used internally, or externally via the DAC output pin. Note that the DAC MUST BE BUFFERED for reliable use. It cannot, for instance, provide enough current to light an LED. It is purely a reference voltage for use with, for example, an op-amp configured as a voltage follower.
After the DAC has been configured, a 'daclevel' command is used to set the actual DAC level, which is divided by 32 equal steps. The maximum theoretical output value is 31/32 * supply voltage, which equates to 4.84V with a 5V supply. The best results at 5V supply have been achieved experimentally with a Microchip MCP6022 op amp with a 100nF capacitor, which gave excellent results (4.78V). An OP90GPZ gave the second best result with only slight clipping (4.09V). Older op amps such as the CA3140EZ gave very poor (badly clipped) results (2.73V). A 'readdac' command can also read the DAC value, this is equivalent to a 'readadc command on the DAC level'. The supply for the DAC can be configured as follows:
bit7 = 0 DAC disabled = 1 DAC enabled bit6 = 0 not used, use 0 bit5 = 0 DAC internal only = 1 DAC also on DAC external output pin (overrides input/output) bit4 = 0 not used, use 0 bit3-2 = 00 DAC upper is Supply Voltage = 01 External Vref+ pin (see adcconfig command) = 10 FVR voltage (see fvrsetup command) = 11 not used bit1 = 0 not used, use 0 bit0 = 0 DAC lower is Supply 0V = 1 External Vref- pin (see adcconfig command)
Configure the DAC output
Set up the DAC output and cycle through DAC output levels
Submit Your Own Code!
You must be logged in to submit code examples. Login now.