Thanks DTJ and dannyf.
I knew about the coding practices having minimal code in a header file but just wanted to get away from the hi-tech version that had 3 .h files and 2 .c files while the whole thing had some major problems that even I as a newbie could see.
max delay of 255 ms and less for micro seconds and having to use the delay.c file just to use milli seconds.
See my post from Yesterday at 12:12:31 PM
The note was taken from the delay.h file
Ian.m recommended to look at an instruction Manual Yesterday at 11:47:43 AM
See
http://www.gamedev.net/page/resources/_/technical/general-programming/organizing-code-files-in-c-and-c-r1798I have downloaded it into a Word document which will allow me to easily add notes etc for future reference.
There is a link to an updated version but it looks the same except diagrams are now in B/W instead of colour / color ?? why change it when it was ok ??
and a couple of places I found quote marks " " added
kept the original version.
DTJ.
I will try putting a while(1) into the code and see what happens.
tick tick tick "time passing" tick tick
No different, only getting "DC VOLTs = +02.5"with about 4.72V applied
and "DC VOLTs = +01.8" with 3.269 volts applied.
grounding the input gives "DC VOLTs = +00.0"
The error is non linier.
The values I gave last night were after I had modified the code to try to get more accurate values.
I have since changed back to original values
Volt_Char[0] = DisplayVolt/1000 + 48; // I had changed 1000 to 500
Volt_Char[1] = (DisplayVolt/100)%10 + 48; // I had changed 100 to 50
Volt_Char[3] = (DisplayVolt/10)%10 + 48; // I had changed 10 to 5
but other similar examples I found were using the 1000, 100, 10
can anyone tell me what the purpose of the % is for???
here is the code I'm using
//********************** READ AND DISPLAY ADC VALUE ****************************
else if (FAULT_7==0)
{
char Volt_Char[5], DisplayVolt, InVolt; // sample code didn't have this line but i get errors if I take it out.
ADC_Init(); // Volt_Char[5] is the 5 correct. I substituted [2] and it still worked .
InVolt = ADC_Read(0); //Read Analog Channel 0
DisplayVolt = InVolt *2;
Volt_Char[0] = DisplayVolt/1000 + 48;
Volt_Char[1] = (DisplayVolt/100)%10 + 48;
Volt_Char[3] = (DisplayVolt/10)%10 + 48;
Lcd_Init(); // initialize LCD
Lcd_Clear(); // clear LCD
Lcd_Set_Cursor(1,1);
Lcd_Write_String ("DC VOLTs = + "); // DISPLAY TO READ
Lcd_Set_Cursor (1,13); //"DC VOLTS = +00.0"
Lcd_Write_Char(Volt_Char[0]);
Lcd_Write_Char(Volt_Char[1]);
Lcd_Write_String(".");
Lcd_Write_Char(Volt_Char[3]);
DelayMs(500); // Hold for 500 ms
while(1); //Infinite Loop
}
//********************** END READ AND DISPLAY ADC VALUE ************************
I'm currently using
Product Version: MPLAB X IDE v2.10
would it be an advantage to go to MPLAB IDE v8 or at my level of non expertise stick with what I have for the moment.
Thank you for all your help so far and in the future.
BILL.