PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
|
dac function source, see simpletools.h for documentation. More...
#include "simpletools.h"
Go to the source code of this file.
Macros | |
#define | DUTY_SE (0b110 << 26) |
Functions | |
void | dac_ctr_cog (void *par) |
void | dac_ctr_res (int bits) |
Set D/A voltage resolution. More... | |
void | dac_ctr (int pin, int channel, int dacVal) |
Set D/A voltage. More... | |
void | dac_ctr_stop (void) |
Stop the cog that's transmitting the DAC signal(s). More... | |
Variables | |
static unsigned int | stack [44+16] |
static int | dacCtrBits |
static unsigned int | cog |
static volatile int | ctra |
static volatile int | ctrb |
static volatile int | frqa |
static volatile int | frqb |
dac function source, see simpletools.h for documentation.
@detail Please submit bug reports, suggestions, and improvements to this code to edito. r@pa ralla x.co m
Definition in file dac.c.
void dac_ctr | ( | int | pin, |
int | channel, | ||
int | dacVal | ||
) |
Set D/A voltage.
Launches process into another cog for up to two channels of D/A conversion on any I/O pin. Other libraries may be available that provide D/A for more channels. Check SimpleIDE/Learn/Simple Libraries/Convert for options. For more options, check obex.parallax.com.
This library uses another cog's counter modules (2 per cog) to perform duty modulation, which is useful for D/A conversion. The digital signal it generates will affect LED brightness. The signal can be passed through a low pass RC filter for digital to analog voltage conversion. Add an op amp buffer if it needs to drive a load.
Default resolution is 8 bits for output voltages ranging from 0 V to (255/256) of 3.3 V.
General equation is dacVal * (3.3 V/2^bits)
Default is 8 bits, which results in dacVal * (3.3 V/ 256), so dacVal specifies the number of 256ths of 3.3 V. You can change the resolution with the dac_ctr_res function.
pin | I/O pin number. |
channel | Use 0 or 1 to select the cog's CTRA or CTRB counter modules, which are used for D/A conversion. |
dacVal | Number of 256ths of 3.3 V by default. Use a value from 0 (0 V) to 255 . |
void dac_ctr_res | ( | int | bits | ) |
Set D/A voltage resolution.
Default resolution is 8-bits for output voltages ranging from 0 V to (255/256) of 3.3 V.
General equation is dacVal * (3.3 V/2^bits)
Default is 8 bits, which results in dacVal * (3.3 V/ 256), so dacVal specifies the number of 256ths of 3.3 V.
bits | The D/A converter's resolution in bits. |