You are here

Problems with SAR ADC | Cypress Semiconductor

Problems with SAR ADC

Summary: 16 Replies, Latest post by Bob Marlowe on 07 Jul 2016 11:01 AM PDT
Verified Answers: 1
Last post
Log in to post new comments.


I'm new into PSoC and PSoC BLE.
I decided to design a PSoC Fart-O-Meter.
So far the project is quite simple: A methane sensor, powered with 5 volts, is measures the concentration of methane in the air.
The output is a voltage between 0-5 volts.
I want to convert this output value to an integer by using the SAR ADC. Using this value I want to set a servo, that is  showing the concentration on a sign.
Later I want to send the value via BLE to another PSoC BLE, as mobile display.

Unfortunately it doesn't work, I'm saving the value in a variable but when reading this variable, e.g. in debugging, it's everytime empty(0x00000000).

I added my project to this post.

I hope you can help me!

user_78878863's picture
2553 posts

You just start one conversion. And then you never wait for it to finish.

Sorry I don't get you! Thats my first post in the forum!?

user_1377889's picture
9294 posts

What hli wants to say: There is a function ADC_IsEndConversion() which you should use to wait for a conversion done. Look into datasheet, there is a parameter for the function.



Are we opening a pure German thread here?

Ah ok!
I will look it up!

A pure German thread would be perfect!

user_1377889's picture
9294 posts

hli is located in Magdeburg and I live near Bremen. Where are you seated?



In der Nähe von Freiburg, genauer Emmendingen!

D.h. ich muss, bevor ich den Wert in die Variable schreibe, prüfen, ob eine Konvertierung beendet wurde, indem ich davor ACD_IsEndConversion(ADC_WAIT_FOR_RESULT) setze?

user_242978793's picture
969 posts

I been to Freiburg nice place.  I lived in Ramstein for 3 years back in the late 1970's.

user_1377889's picture
9294 posts

Forum language is English, silvan wrote:

Namely I have before I write the value in the variable, check whether conversion was terminated by ACD_IsEndConversion (ADC_WAIT_FOR_RESULT) I place in front of it?

Yes, that's quite right!



Oops sorry!
My next question is there any possibility to view the value of  my variable "gas"?
When debugging the code, the overlay of "gas"shows 0x0000... .
Or is there a way to discover the max and min value that "gas" could assume?

I attach my latest code.

user_1377889's picture
9294 posts

I used a modification as

int16 MaxValue = 0;
int16 MinValue = 32767;


        value = ADC_GetResult16(0);
        if(value > MaxValue) MaxValue = value;
        if(value < MinValue) MinValue = value;

and I got different values for Min amd Max.



Log in to post new comments.