- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
At the analog input, when vin_A = 0.80 V, when the value of ADC is 0.90 V and Vin = 1.00 V, the value of ADC is output as 1.121 V.
Although the output voltage of the ADC is converted to a pressure display, naturally, a shift occurs.
I used Cypress's sample code, but I would like to point out and give advice on where the problem lies.
void measure_pressure(void)
{
static uint8_t initialFlag = 1; /* */
ADC_DelSig_1_StartConvert();
ADC_DelSig_1_IsEndConversion(ADC_DelSig_1_WAIT_FOR_RESULT) ;
// if (ADC_DelSig_1_IsEndConversion(ADC_DelSig_1_RETURN_STATUS)) {
// ADCから電圧を取得。単位がmVなので、Vに変換するため1000.0で割る。その結果を変数voltに代入。
// volt = ADC_DelSig_1_CountsTo_mVolts(ADC_DelSig_1_GetResult16()) / 1000.0;
volt = (ADC_DelSig_1_CountsTo_mVolts(ADC_DelSig_1_GetResult16()) + 100.0) / 1000.0 ;
// 0.8~4.0の値を、0.0~5.0の範囲に線形変換する。その結果を変数pascalに代入。
pascal = lerp(0.8, 4.0, 0.0, 5.0, volt);
if (initialFlag) {
// 初回のみ、平均値(移動平均)を直接セットする。そうしないと、起動直後に0.0からゆっくり変化してしまってよくない。
setAvg(pascal);
initialFlag = 0;
}
// 平均値(移動平均)を更新。平均値は、上のほうで定義している変数avgとに代入される。
updateAvg(pascal);
pressure = pres_ramp * avg + pres_bias ;
}
void report_pressure(void)
{
// UARTへデバッグ出力
sprintf(buf, "ADC=%5.3f
print(buf) ;
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Assuming ADC_DelSig_1_GetResult16() is returning a right value, adding 100.0 make 0.80V to 0.90V.
> volt = (ADC_DelSig_1_CountsTo_mVolts(ADC_DelSig_1_GetResult16()) + 100.0) / 1000.0 ;
How about use the commented line?
// volt = ADC_DelSig_1_CountsTo_mVolts(ADC_DelSig_1_GetResult16()) / 1000.0;
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Assuming ADC_DelSig_1_GetResult16() is returning a right value, adding 100.0 make 0.80V to 0.90V.
> volt = (ADC_DelSig_1_CountsTo_mVolts(ADC_DelSig_1_GetResult16()) + 100.0) / 1000.0 ;
How about use the commented line?
// volt = ADC_DelSig_1_CountsTo_mVolts(ADC_DelSig_1_GetResult16()) / 1000.0;
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Originally,
volt = ADC_DelSig_1_CountsTo_mVolts (ADC_DelSig_1_GetResult16 ()) / 1000.0;
However, +100 was being added in the meantime.
After removing +100 and building again, the analog input value and the ADC value are equal.
This part was solved.
Thank you.
There are still three other places to rework.