ADC does't work

Status
Not open for further replies.

Tymoty

New Member
Hi, I try convert voltage from MMA7260Q and show on lcd but it doesn't work. this is my code


and before this in main.c

ADCON0=0x00;
ADCON1=0x0D;
ADCON2=0x95;

and on senzor is voltage about 1,65V(axes x,y) and when i connect mcu voltage is cca 0,2V. i don't know why
 
Assuming you are using my GLCD code, you have a few problems here. The PutMessage routine only works with strings that are stored in ROM, your 0azX is not a string and is not stored in ROM. The way to fix this is to write a new function that will print an integer.

A simple version would be,
Code:
void PutInt(unsigned int num){
    PutChar((num/1000)%10+0x30);
    PutChar((num/100)%10+0x30);
    PutChar((num/10)%10+0x30);
    PutChar((num)%10+0x30);
}

I have not checked your ADC code but it looks like you don't leave enough acquisition time.

Mike.
 
adc 10bit 1010110101
ADRESH*256 + ADRESL = ?
xxxxxx10 in adresh = 2 = 2*256 = 512
10110101 in adresl = 181 + adresh "512" = 693
so 10 bit adc result from 1010110101 = 693


Csaba
 
Thank you pommie, your code running great. I had mystake in configuration of trisa (i use ra0 and ra1 and i had ra6 and ra7).

and pommie I hope that I can use your glcd routine. I use this for my school project and of course I write you like author. but I need some info about you, I can't write to my project - routine from some forum from pommie
thank you
 
Feel free to use my code, it is in the public domain and so that should make it acceptable. If you have any problems with citation then I can give you additional information.

Mike.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…