I am going to ask some questions that may help (or provide laughter).
1) What voltage are you running the PSoC Pioneer Kit at - on the PSoC 4 processor? It is jumper configurable to run at either 3.3V and 5V - and comes default at 3.3V. If you are running at 3.3V - could that cause the issues you have?
2) In the Creator 3.0 - the tab with the .cydr extension - there is the processor setup. (I don't know the technical terms - bear with me). At the bottom are another set of tabs. One is labeled 'System'. The last set of information is 'Operating Conditions'. I believe this is defaulted to 3.3V for Vddd & Vdda. If you change this to 5.0V - does this help?
Oops - (fingers typing too fast...) in the above the .cydr should be .cydwr.
Creating a "Workspace Bundle" and upload the resulting file will help us to find any settings that will hinder the precise AD-conversion. The hint with the supply voltage is probably the cause, settings of the ADC usermodule might be another one.
Setting the voltage in the .cywr-file will only affect the calculation for ADC-counts to volts by the appropiate APIs.
Hi I have uploaded my workspace bundle.. Thanks for the quick replies, hopefully someone will be able to spot my mistake.. The board as powered with 5V and VDD was set to 5V already in the system config..
ADC5V.Bundle01.zip 553.3 K
Just a guess: you run with Vcc=5V, have configured the ADC to use Vdda/2 as Vref, and the result format is signed? Then you would get exactly what you described. The ADC datasheet explains nicely on pages 6+7 why.
Otherwise, when you cannot post the complete project, please explain at least how you configured the ADC.
Oh, I should check for replies before answering a post which sits open in a tab for one hour :(
Some thoughts -
1) You do not observe the needed delay for reference startup discussed in datasheet.
2) In your tight for() loop you do not test each time for end of conversion.
OK, after looking at the project: I'm right about the signed result format - that explains why you get at most 2047 as result. Change that to unsigned and you should get 4095.
Looking at your external circuit: try and drop R3. The input resistance of the ADC is specified as 2.2k (4200 family data sheet, page 20), so you have a nice voltage divider there... Or you add an OpAmp as voltage follower to get high input impedance.
Regarding the need to wait for EOC: the SAR ADC on the PSoC4 use double buffering for the result, so one should not get invalid / intermediate values. (Just have read the whole section on the TRM :)
The EOC insures you are not re-reading an old value. In some applications
where sample values in real time are importent the non-relevant result is to be
Of course in these cases an ISR driven read probably more effective.
But I suspect in most applications double buffering is preferred, simply not a cure all
Okay so I am back with further findings.. the values I am getting from the ADC still look messed up but the interesting thing is that if I use the ADC_CountsTo_Volts(0, ADCResult); function then it reads the correct voltage.
I am going to give you every bit of info I have, hopefully someone can point where I am going wrong..
So I ditched the LDR and decided to just wire a jumper from the ADC pin to the 5V,3.3V,0V lines on the PSOC 4 pioneer itself as can be seen in this photo (note the jumper J9 in the 5V position)
So here are my results.
As you can see it reads 2047 and not 4096 but the counts to ticks function gives me 5V? how is this working?
Not exactly 3.3V but meh close ish..
This one confused me a lot.. as you can see it is reading 65535 for 0V.. not ...0.
This couldn't get any more basic, I am wiring a wire from the voltage rail straight into the ADC pin.
You guys have been so helpful up to now, hopefully someone can put me right. I have attached my project too.
5V ADC Measurement.Bundle01.zip 561.5 K
Just some further information on things I have changed.
i.imgur.com/KrEhBHX.png <<This is my source code, I added a delay in as someone said that I could be reading too fast.
i.imgur.com/6kt0IOH.png << This is my system config file, I have changed both to 5V now.
i.imgur.com/C0YVPZT.png << My Shematic.. now the most simple schematic in the world
and finally i.imgur.com/yDOb3TP.png << my ADC config, now has UNSIGNED as the data type..
You could have seen all of this yourselves obviously but I thought if someone has hover zoom they might be able to quickly spot the mistake if I gave you loads of images
As I already said: since you set the ADC result to be 12bit, signed, its maximum value is 2047. The conversion routines know about that, and give you the proper voltage. If you want better resolution, set it to unsigned (then the maximum value is 4095).
For the zero value: the ADC actually measured a negative value. This can happen due to noise. Since the result is signed, it really is a -2 in that case. But you did convert it to an unsigned value, and therefore see its twos-complement.
Please read the ADC data sheet about how the ranges and the result can be configured, and what these settings affect.
Hi, Thanks for the insight but in my last image I have shown my ADC config and it is set to "unsigned"? is there somewhere else you are talking about?