I am using PSoC CY8C29466's DelSig and Triple input incremental ADC. Both ADC is set to data format as signed. The data input into ADCs is from sensor which the sensor itself have output value between 1V to 4.9 V.
Delsig is set to 3 MHz clock frequency and Pulse width is 10. Triple input ADC is set to ADC resolution of 13 bit, Calc time 400, 3 MHz clock frequency.
I want to know what is the C code to change the ADCs value into decimal value ( base number of 10).
There are a couple of possibilities to do that:
Do it yourself: when you divide the number by 10, the remainder will give the last digit (0..9), repeat until nuber is zero
Use itoa macro
Use Print-function of LCD-module
What is itoa macro? Can somebody elobrate?
Another addition thing is that the ADCs output values which is converted to decimal values;this decimal values is used as data to calculate the measured value of the sensor. I have done the calibration, and acquired the equation to convert the measured voltage into measured pH value. For example, the pH sensor, when the output of the reading is 3V, it represent pH 12.
So, I am wondering do the codes below can get my measured voltage value from ADC? Since I am using the measured voltage of sensor to calculate the measured sensor value, I am wondering whether the codes can get back the measured voltage value.
The pH sensor can detect pH 0 to pH 14, sensor voltage output values is 1.04 V to 4.94 V with the lowest voltage represent pH 0 and highest pH represent the higherst voltage.
pH_adc = TRIADC_1_iGetData2(); // read data from ADC
pH_dec=(pH_adc)*0.001221001221; // convert the data from ADC to decimal values
pH = (3.683 * pH_dec)-4.403; // calculate the measured pH value from decimal values
I cannot test your calibration-numbers (although there might be some error) but you forgot to wait for a sample beeing ready. Depending on your ADC it will be something like ADC_fIsDataAvailable() and ADC_GetDataClearFlag(), contact the datasheet.
For the Math: you have got a linear function which is f(x) = ax +b. So you have to evolve a and b. One multiplication and one addition will give you the desired Ph. As far as I know the voltage is temperature-dependent which might bring in another term.
When later everything works, think of a calibration-routine and storing the parameters in EEProm.
Sorry, forgot itoa.
Contact your C-compiler handbook (Help -> Documentation... -> Compiler and Programming Documents -> C Language Com...
In the PDF search (CTRL-F) for "atoi"