cancel
Showing results for 
Search instead for 
Did you mean: 

Code Examples

Doorknob
Contributor

I am using the PSoC 4000S device in a product I am working on and I need to use a thermistor to measure temperature.  I do not see the thermistor component selection available in Creator for this device. Is this component not available in the PSoC 4000S?  If it is not available how best can I use a thermistor on a 4000S device?

Thanks

Scott

0 Likes
1 Solution
MotooTanaka
Esteemed Contributor

Dear Scott-san,

So I posted the version which uses ADC_CSD and runs on CY8CKIT-149 there.

Just in case, let me attach it here, too 😉

Best Regards,

13-Jun-2019

Motoo Tanaka

View solution in original post

0 Likes
11 Replies
Vasanth
Moderator
Moderator

Hi Scott,

Unfortunately the thermistor component is not available for 4000s device. If you want to port the code please the thermistor.c file in a project with a supported PSoC4 device(eg: PSoC 4200).  In the component you can obtain the temperature through Equation or LUT. The tradeoffs between the two methods are memory, speed, range, and resolution. The Equation method is more accurate and has a fixed range and accuracy. The Equation method uses more memory because it requires the floating point math library. The LUT uses less memory and has a faster response time. You can see how it is implemented in both cases.

Best Regards,
Vasanth

0 Likes
Doorknob
Contributor

Vasanth,

I was able to get some great feed back from Motoo Tanaka and odissey1 but I am stuck on getting an actual ADC count reading on the 4000S.  As i read the datasheet on the 4000S ADC component, the API only returns a mVolt value and not an actual ADC count value.  I could calculate count using the LSB but I believe it would not be as accurate sense it involves Vref.  It would be nice to utilize the components calibration ability, at least as i understand it.  Anyway is there a way to get a ADC_count instead of a ADC_mVolt reading?

I will attach my work sheet i did for AD conversions that helps me to understand whats behind the hood, my be helpful to others.

Thanks

Scott

0 Likes
MotooTanaka
Esteemed Contributor

Dear Scott-san,

It was somewhat difficult for me to make the ADC_CSD work as I expected.

But I think I could make it with CY8CKIT-149 at

Thermistor (103AT-11) Sample Project

Would you check it, if it works for you?

Best Regards,

13-Jun-2019

Motoo Tanaka

0 Likes
Doorknob
Contributor

Motoo,

Yes I tried it on my favorite prototyping board CY8KIT-043 that has a 4200M part on it and it works fine.  My issue is i need to use the 4000S part that has the ADC_CSD for cost reasons.  This particular part is only about 50 cents and this project is very cost sensitive!

I am presently stuck sense the API of the ADC_CSD only returns mV and not a count.

Thank you for your support!!

Scott

0 Likes
MotooTanaka
Esteemed Contributor

Dear Scott-san,

So I posted the version which uses ADC_CSD and runs on CY8CKIT-149 there.

Just in case, let me attach it here, too 😉

Best Regards,

13-Jun-2019

Motoo Tanaka

View solution in original post

0 Likes
Doorknob
Contributor

Motoo,

In my system my Vref or in this case as you call it VDDA is a bit shady.  I am using a high voltage buck converter IC (HV9910) which has a built in reference so I can produce 4 to 5 volts (from 9V to 450V DC input voltage) to power my PSoC device for free.  Its regulation is not the greatest based on the current from the PSoC and an indicator LED I need to use.

     Anyway what do you think of me measuring the VDDA just prior to doing the thermistor measurement so my thermistor temperature would be more accurate.  I don't need supper accuracy in this application I just need to do some thermal compensation by adjusting my PWM from my PSoC to on my Buck regulator IC.

Anyway thanks so much for your help

Scott

0 Likes
MotooTanaka
Esteemed Contributor

Dear Scott-san,

As far as the MCU is running with 5V VDD, it should behave just like my CY8CKIT-149.

So why don't you copy my project and change the device and pins to match with your system and give it a try?

As I need to go out now, my next response may not be prompt.

Best Regards,

13-Jun-2019

Motoo Tanaka

0 Likes
MotooTanaka
Esteemed Contributor

Dear Scott-san,

As I was quite occupied by making the ADC_CSD to work, I overlooked your message about the reference.

Although we don't have the Thermistor Calculator component in the 4000S device, we can utilize the idea of the component, which is what you are trying, right?

000-therm-calc.JPG

So if you measure Vhi, VT, Vlow with three ADC_CSD's input channels,

you should be able to do the same calculation.

May be you've already gone above this level,

but if not, referencing the datasheet of Thermistor Temp. Calc might give you some hint.

Best Regards,

13-Jun-2019

Motoo Tanaka

0 Likes
Doorknob
Contributor

Motoo,

Just before i left the office yesterday to head out to see my new granddaughter in Texas, which i am very excited to see!  I was able with your help to get my thermistor routine running.  I will attach a copy for review if you would like to see were I left off.  I was able to add a measurement of VDDA to the routine. I also included the fast log calculation.

With the device i am suing i only have 16k of flash and had to remove the UART section of code so i could get it to run. I used the debugger to see if i was getting the correct readings on the CSD.  I did not have time before i left to see how accurate the temperature is with the current code i was able to get running.  My code writing skills are at a beginner level at best but i love learning.  At this point i believe it should work well but i am very concerned about the memory it is taking up just to read my thermistor.  In my project i also have to read battery voltage, a mode level pin as well has control the PWM on my buck converter and all the other code need to make it all operate properly.  I can go to a 32k device if needed but i was hoping to use the 16k device.

Your mention of the thermistor calculator which I have reviewed does both a floating calculation and a table version calculation which uses a lot less memory.  If i read that data sheet right that particular component uses the math to do a differential measurements of the voltages.  The ADC_CSD does not have this ability.  At the moment i am not sure how to do the math correct so i can do a simular approach using the ADC_CSD.  I hope over the weekend to review the math so i can see if i can give this type of approach a go also.  I have never done a table kind of table reading in C before so this should be interesting. 

I want to thank you for your kind attention and time you have helped me ... Thank you very much.

MotooTanaka
Esteemed Contributor

Dear Scott-san,

Congratulations!

For both your granddaughter and the started working project!

Yes, for a memory tight device  the fast log, which I learned from oddisey1-san must be more practical.

Best Regards,

14-Jun-2019

Motoo Tanaka

0 Likes
MotooTanaka
Esteemed Contributor

Hi,

I tried with 4200M (CY8CKIT-044), may be portable to 4000s.

Thermistor (103AT-11) Sample Project

moto