#### frahman3

##### Member
Hi,
Sorry for misunderstood your comment earlier. I'm not a good programmer and sorry for lack of knowledge in programming. I changed the code as advised, However when I pumped 1.2V dc voltage to ADC channel 5 and channel 6 pins they are not displaying correct values. I tested with my earlier code (printf) and it works as expected. Please advised.

frahman3

CSS:
#include <30F6014A.h>
#include <float.h>
#include <string.h>
#fuses NOWDT, NOPROTECT, PUT64, BORV27
#use delay (clock=58982400, xtal=7372800)
#use rs232(baud=9600,UART1,ERRORS)

unsigned char ert_voltages_5;
unsigned char ert_voltages_6;

{
delay_us(10);           //delay is required after setting channel and bef.read
ert_voltages_5=(ert_adc_value_5)*5000/4096;// last result of last conversion
}

{
delay_us(10);           //delay is required after setting channel and bef.read
ert_voltages_6=(ert_adc_value_6)*5000/4096;// last result of last conversion
}

void main(void)                     //void=nothing, no return value
{

set_TRIS_D(0x0000);

while(TRUE)
//if (kbhit())                      //check if a character has been received
// c = getc();                   //read character from UART
{
puts("Ch99=9999");
}//end while
}//end main

#### frahman3

##### Member
Hi,
Thanks for the advice and support. It is very kind of you to share your knowledge. At the moment I try to use the existing code although it is long but I can understand how it works. This are the display values using the above code and with '\n' after the puts function. My objective is to send continuous adc data (without blank rows) to labview. The problem is the values are still incorrect.

frahman3

Dislpayed value with putc '\n' funtion.

Dispayed value without putc '\n' function

#### rjenkinsgb

##### Well-Known Member
Hi,
no problem! Everyone learns, I've been programming for decades and I'm still learning.

If you are adding the \n to the string as part of the printf() / sprintf(), you do not need the extra putc().

The continuously varying numbers imply the ADC does not have enough settling time; try temporarily changing the delay after setting the channel to 50uS rather than 10uS and see what happens?

What results do you get with your original code?

Please also try changing all the ert_ variables from unsigned char to unsigned int, and see what results you get then?