PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Simple Libraries
Convert
libabvolts
daCalibrate.c
1
#include "
abvolts.h
"
2
#include "
simpletools.h
"
3
4
static
int
pinCh0 = 26, pinCh1 = 27;
5
float
abvolts_scale[2];
6
7
void
da_setupScale
()
8
{
9
high
(pinCh0);
10
high
(pinCh1);
11
12
pause
(5);
13
14
float
vA =
ad_volts
(0);
15
float
vB =
ad_volts
(1);
16
17
//print("%f %f\n", vA, vB);
18
19
if
( (vA > 3.1 && vA < 3.5 && vB > 3.1 && vB < 3.5))
20
{
21
for
(
int
i = 0; i < 39; i++)
22
{
23
vA +=
ad_volts
(0);
24
vB +=
ad_volts
(1);
25
}
26
vA /= 40;
27
vB /= 40;
28
29
vA = 3.3 / vA;
30
vB = 3.3 / vB;
31
32
int
addr =
_abvolts_EE_start_
;
33
34
ee_putStr
(
"abvolts"
, 8, addr);
35
addr += 8;
36
37
ee_putFloat32
(vA, addr);
38
addr += 4;
39
40
ee_putFloat32
(vB, addr);
41
addr += 4;
42
43
low
(pinCh0);
44
low
(pinCh1);
45
46
input
(pinCh0);
47
input
(pinCh1);
48
49
putStr
(
"Ch0 scalar = "
);
50
putFloat
(vA);
51
putStr
(
"\nCh1 scalar = "
);
52
putFloat
(vB);
53
putChar
(
'\n'
);
54
putChar
(
'\n'
);
55
56
abvolts_scale[0] = vA;
57
abvolts_scale[1] = vB;
58
}
59
else
60
{
61
putStr
(
"Error! Something went wrong. Check your circuit and power source."
);
62
}
63
}
64
ad_volts
float ad_volts(int channel)
Get a voltmeter style floating point voltage measurement from one of the A/D converter's input channe...
Definition:
abvoltsF.c:16
ee_putFloat32
void ee_putFloat32(float value, int addr)
Store a 32-bit precision floating point value at a certain address in the Propeller Chip's dedicated ...
Definition:
eeprom_putFloat.c:24
pause
void pause(int time)
Delay cog from moving on to the next statement for a certain length of time.
Definition:
libws2812.c:125
putFloat
void putFloat(float value)
Print string representation of a 32 bit floating point number to the debug port.
Definition:
putFloat.c:10
low
void low(int pin)
Set an I/O pin to output-low.
Definition:
low.c:19
simpletools.h
This library provides convenient functions for a variety of microcontroller I/O, timing,...
ee_putStr
void ee_putStr(unsigned char *s, int n, int addr)
Store a string of byte values starting at a certain address in the Propeller Chip's dedicated EEPROM.
Definition:
eeprom_putStr.c:25
_abvolts_EE_start_
#define _abvolts_EE_start_
abvolts EEPROM calibration data start address.
Definition:
abvolts.h:45
da_setupScale
void da_setupScale(void)
Set up scale to adjust D/A0 and D/A1. Connect DA/0 to AD/0 and DA/1 to AD/1 before running....
Definition:
daCalibrate.c:7
input
int input(int pin)
Set an I/O pin to input and return 1 if pin detects a high signal, or 0 if it detects low.
Definition:
input.c:19
putChar
void putChar(char c)
Print a char to the debug port.
Definition:
putChar.c:30
abvolts.h
Functions for setting voltages with D/A0, D/A1 outputs and measuring voltages with A/D0....
high
void high(int pin)
Set an I/O pin to output-high.
Definition:
high.c:19
putStr
int putStr(const char *str)
Print string to the debug port.
Definition:
putStr.c:10
Generated on Fri May 20 2022 16:48:04 for PropWare by
1.8.17