- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
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!
Solved! Go to Solution.
- Labels:
-
BLE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You just start one conversion. And then you never wait for it to finish.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You just start one conversion. And then you never wait for it to finish.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry I don't get you! Thats my first post in the forum!?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Bob
Are we opening a pure German thread here?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ah ok!
I will look it up!
A pure German thread would be perfect!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hli is located in Magdeburg and I live near Bremen. Where are you seated?
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I been to Freiburg nice place. I lived in Ramstein for 3 years back in the late 1970's.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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!
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok, but I can I read out the actual value of the ADC?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
but I can I read out the actual value of the ADC? According to my experiences: Yes
A tip: when debugging and a breakpoint (BP) is reached the CPU halts. That's quite normal so far.
But the internal hardware keeps on running, so generating interrupts, overflowing counters, keeping PWM outputs running and so on. This means that the next result of an ADC conversion after a BP will be wrong. So in your case I would set a BP at the IsEndConversion() line and so observing the previous result.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My problem is, that I can't check, which value is actually written in the variable...
Like I wrote before, I want to read out the value of "value"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Set a breakpoint. When reached, hover with the mouse cursor over your variable. A window will pop-up that shows value and address as long as the variable is not optimized-out into a register. In that case you will have to open the disassembly window and inspect the registers.
I cannot see any reason why you weren't able to watch a variable.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I did this and the value of my variable was always 0x0000... .
To check it I put 5 volts at the port of the ADC, in my case 2(4).
I would appreciate if you could check, if I set up the ADC correctly?
My current project was uploaded a few posts before.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content