Silly ADC problem
Akros
Posts: 1
Hi there,
Im just trying to follow one of the simplest code examples in the website. I use the Prop ASC+, so I need to change the parameters in the example because it uses diferent pins to read the analog input in the board.
My code is quite simple but Im not receiving any lecture. Am I missing something?
#include "simpletools.h" // Include simple tools
#include "adcDCpropab.h" // Include adcDCpropab
int main() // Main function
{
adc_init(27, 25, 23, 26); // CS=27, SCL=25, DI=26
float v0,v1,v2,v3,v4,v5; // Voltage values
while(1)
{
v0 = adc_volts(0); // Check A/D 2
v1 = adc_volts(1); // Check A/D 2
v2 = adc_volts(2); // Check A/D 2
v3 = adc_volts(3); // Check A/D 2
v4 = adc_volts(4); // Check A/D 2
v5 = adc_volts(5); // Check A/D 2
putChar(HOME); // Cursor -> top-left "home"
print("A/D0 = %f V%c\n", v0, CLREOL); // Display volts
print("A/D1 = %f V%c\n", v1, CLREOL); // Display volts
print("A/D2 = %f V%c\n", v2, CLREOL); // Display volts
print("A/D3 = %f V%c\n", v3, CLREOL); // Display volts
print("A/D4 = %f V%c\n", v4, CLREOL); // Display volts
print("A/D5 = %f V%c\n", v5, CLREOL); // Display volts
pause(100); // Wait 1/10 of a second
}
}
Im just trying to follow one of the simplest code examples in the website. I use the Prop ASC+, so I need to change the parameters in the example because it uses diferent pins to read the analog input in the board.
My code is quite simple but Im not receiving any lecture. Am I missing something?
#include "simpletools.h" // Include simple tools
#include "adcDCpropab.h" // Include adcDCpropab
int main() // Main function
{
adc_init(27, 25, 23, 26); // CS=27, SCL=25, DI=26
float v0,v1,v2,v3,v4,v5; // Voltage values
while(1)
{
v0 = adc_volts(0); // Check A/D 2
v1 = adc_volts(1); // Check A/D 2
v2 = adc_volts(2); // Check A/D 2
v3 = adc_volts(3); // Check A/D 2
v4 = adc_volts(4); // Check A/D 2
v5 = adc_volts(5); // Check A/D 2
putChar(HOME); // Cursor -> top-left "home"
print("A/D0 = %f V%c\n", v0, CLREOL); // Display volts
print("A/D1 = %f V%c\n", v1, CLREOL); // Display volts
print("A/D2 = %f V%c\n", v2, CLREOL); // Display volts
print("A/D3 = %f V%c\n", v3, CLREOL); // Display volts
print("A/D4 = %f V%c\n", v4, CLREOL); // Display volts
print("A/D5 = %f V%c\n", v5, CLREOL); // Display volts
pause(100); // Wait 1/10 of a second
}
}
Comments
Welcome to the Forum!!
The adcDCpropab.h is designed to communicate with the ADC on the Propeller Activity board which is a "ADC124SO21" the Prop ASC+ board uses a "MCP3208"
Looking at the datasheets, the two ADC's are not compatible, so a modification to adcDCpropab would be necessary.
Reference:
http://www.ti.com/lit/ds/symlink/adc124s021.pdf
http://ww1.microchip.com/downloads/en/devicedoc/21298c.pdf