|
|
View previous topic :: View next topic |
Author |
Message |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Nov 20, 2006 12:30 pm |
|
|
Your test program is too complicated. Try this simple program
and see if it works.
Code: |
#include <18F6527.h>
#device adc=10
#fuses HS, NOWDT, PUT ,BROWNOUT, NOLVP
#use delay(clock=10000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
//===================================
void main()
{
int16 result;
setup_adc_ports(ALL_ANALOG);
setup_adc(ADC_CLOCK_DIV_8);
set_adc_channel(0);
delay_us(20);
while(1)
{
result = read_adc();
printf("%lx \n\r",result);
delay_ms(500);
}
} |
|
|
|
Ttelmah Guest
|
|
Posted: Mon Nov 20, 2006 3:30 pm |
|
|
You have a huge amount of stuff in your code, that has been remarked out. Remove this, and repost, _showing the declarations of the variables used to hold the ADC valuea_. Also use the 'code' buttons to post.
Also, consider using an array, or struture to allow the whole thing to be done with one loop. Something like:
Code: |
structure values {
int16 threeDC;
int16 fiveVDC;
int16 fiveVRef;
int16 fortyeightVDC;
int16 PPDDetect;
int16 OpAmpPwr;
}
union {
int16 readings[6];
stucture values ADC;
} VIN;
void read_volts(void) {
int8 ctr;
for (ctr=0;ctr<7;ctr++) {
set_adc_channel(ctr);
delay_us(20);
VIN.readings[ctr]=read_adc();
}
}
//Then in your main:
while (true) {
read_volts();
printf("Three V line is at %d\n\r",VIN.ADC.threeDC);
delay_ms(500);
}
|
Just showing how this would work for one value (but reading six).
A lot smaller, simpler to read etc. etc..
Best Wishes |
|
|
bill conley Guest
|
|
Posted: Mon Nov 20, 2006 9:17 pm |
|
|
Thanks Guys...I think I have it working. It wasn't the firmware, it was the hardware.
- |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|