Oops! It appears that you have disabled your Javascript. In order for you to see this page as it is meant to appear, we ask that you please re-enable your Javascript!

Reply To: ADC Files causing issue

Home Forums MPLAB XC8 Project Discussions ADC Files causing issue Reply To: ADC Files causing issue


Bitahwa Bindu

Found few problems:

  1. The main problem is your circuit diagram: You didn’t connect Data D5 pin of the LCD. In 4bits mode, you must use D4, D5, D6 and D7. Move the line connected to D4 to D5 and the line connected to D3 to D4.
  2. To create a delay of 1 second, you must loop 20 times a delay of 50ms (1 000ms =20*50) and not 20 times 100ms, this will give you a delay of 2 Seconds but at the same time give you an error of too large argument in the delay, so always use a small delay number and increase the loop number to achieve the required delay when using the old compiler. This bug has been fixed in latest XC8 compilers, now you can use a large delay directly without looping.
  3. Change: voltage = (ADCResult*5)/1024; to voltage = (ADCResult*5.0)/1024; Don’t multiply by 5, this will be give you an integer voltage, all the decimal point will be rounded of, multiply by 5.0 this will tell the compiler that this is a decimal calculation.
  4. lastly change the void DelayFor18TCY (void)
  5.  to: void DelayFor18TCY (void)
    Delay10TCYx(20) ;
Select your currency
EUR Euro
USD United States (US) dollar