PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Simple Libraries
Convert
libabvolts
daVolts.c
1
#include "
abvolts.h
"
2
#include "
simpletools.h
"
3
4
float
abvolts_scale[2] = {1.0, 1.0};
5
int
abvolts_daCtrBits;
6
7
void
da_volts
(
int
channel,
float
daVal)
8
{
9
if
(!abvolts_daCtrBits)
10
{
11
da_out
(channel, 0);
12
}
13
int
levels = (1<<abvolts_daCtrBits);
14
daVal *= ((
float
) levels / 3.3);
15
daVal *= abvolts_scale[channel];
16
if
((daVal - (
float
)(int)daVal) >= 0.5) daVal += 1.0;
17
int
dacVal = (int) daVal;
18
if
(dacVal >= levels) dacVal = levels - 1;
19
if
(dacVal < 0) dacVal = 0;
20
da_out
(channel, dacVal);
21
}
22
float
simpletools.h
This library provides convenient functions for a variety of microcontroller I/O, timing,...
da_out
void da_out(int channel, int daVal)
Set D/A output.
Definition:
abvoltsDA.c:30
abvolts.h
Functions for setting voltages with D/A0, D/A1 outputs and measuring voltages with A/D0....
da_volts
void da_volts(int channel, float daVal)
Set D/A voltage (0 to ~3.3 V) on a given channel (0 or 1 for D/A0 or D/A1). Actual voltage will be ...
Definition:
daVolts.c:7
Generated on Fri May 20 2022 16:48:04 for PropWare by
1.8.17