VoltVolt
Junior Member level 1
- Joined
- Sep 15, 2013
- Messages
- 15
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 124
Hi all,
I'm try to use array to store voltage read from ADC module...
But it seems some logical errors...
Desired result: voltage[0] = xxx, voltage[1] = xxx ,voltage[2] = xxx......
Thank you...View attachment Test Program.X.rarView attachment Test Program.X.rar
I'm try to use array to store voltage read from ADC module...
But it seems some logical errors...
Desired result: voltage[0] = xxx, voltage[1] = xxx ,voltage[2] = xxx......
Code:
void main() {
LCDinit();
init_ADC();
delay_ms(10); //idle period
while (1) {
int adc_eqn;
float voltage[16];
char strStore[16];
for (int channel = 0; channel < 10; channel++) {
if ((channel == 1) || (channel == 5) || (channel == 9)) {
//AN0 CHANNEL
ADCON0 = channel;
for (int i = 0; i < 3; i++) {
//ADC start
GO_DONE = 1;
//wait for ADC to complete
while (GO_DONE) {
continue;
}
//retrieve adc equavalent value
adc_eqn = ((ADRESH << 8) | ADRESL);
voltage[i] = (float) (adc_eqn * 5.0 / 1023);
sprintf(strStore, "ADC %d %f V", i, voltage[i]);
LCDWrite(strStore, 10, 0, 0);
delay_ms(1000);
}
}
}
}
}
Thank you...View attachment Test Program.X.rarView attachment Test Program.X.rar