Functions for up to 2 channels per cog of duty modulated signals for D/A conversion through a low pass filter. More than one cog may be launched, so for example, if 5 signals are desired, use 3 cogs for up to 6 channels.
More...
#include "simpletools.h"
Go to the source code of this file.
Functions for up to 2 channels per cog of duty modulated signals for D/A conversion through a low pass filter. More than one cog may be launched, so for example, if 5 signals are desired, use 3 cogs for up to 6 channels.
- Author
- Andy Lindsay
- Copyright
- Copyright (C) Parallax, Inc. 2018. All Rights MIT Licensed.
- Version
- 0.5
- Help Improve this Library
- Please submit bug reports, suggestions, and improvements to this code to edito.nosp@m.r@pa.nosp@m.ralla.nosp@m.x.co.nosp@m.m.
◆ dac2ch_set()
void dac2ch_set |
( |
dac2ch * |
device, |
|
|
int |
pin, |
|
|
int |
channel, |
|
|
int |
dacVal |
|
) |
| |
Set a DAC signal's level.
- Parameters
-
*device | The dac2ch pointer/process ID returned by dac2ch_start. |
pin | The pin to send the duty modulated DAC signal. |
channel | 0 or 1. |
dacVal | For D/A, use 0 to (2^bits) - 1. For example, for 9 bits, that would be 0 to 511. To shut down a channel and set the I/O pin to input, use -1. |
◆ dac2ch_start()
dac2ch* dac2ch_start |
( |
int |
bits | ) |
|
Start duty modulation process in another cog for D/A conversion through a low pass filter.
- Parameters
-
bits | Number of bits for the D/A converter. The number of voltage settings will be 2^bits. For example, setting bits to 8 gives 2^8 = 256 voltage settings, from 0 -> 0 V to 255 -> 3.287 V on a 3.3 V scale. |
- Returns
- *device A pointer that should be stored in a dac2ch *variable and used as a process ID in other dac2ch_... function calls.
◆ dac2ch_stop()
void dac2ch_stop |
( |
dac2ch * |
device | ) |
|
Shut down dac2ch process and reclaim cog and I/O pins for other uses.
- Parameters
-
*device | The dac2ch pointer/process ID returned by dac2ch_start. |