Beginner PSoC Creator 4.1 Questions - CY8CKIT042-BLE - ADCs + IDAC

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hello Cypress community!

I recently started experimenting with the CY8CKIT-042-BLE (CY8C4247LQI-BLE, to be specific) for a small R&D project in the office. Without going into too much detail, we're trying to accurately measure the resistance of a variable resistor. In particular, I'm measuring the resistance of 9 separate resistors in this application.

I've attached the Project file I've managed to cobble together that seems to work at the moment (please excuse poorly written code and badly configured diagrams, still new here). I've declared the proper analog pins that one end of the sensors are connected to, while the grounded end of all the sensors are connected together to GND on J1. The TopDesign.cysch connects the sensors to an AMux, which uses a combination of the IDAC and ADC blocks to inject a small amount of current to each of the analog pins, and then ADC measures the voltage drop across each resistor. From this, I can take the known current and measured voltage and (V = IR) calculate the resistance of the sensor at that point in time.

There's a little more to the design file, but most of it is to 1) accurately timestamp the collected data, and 2) create a UART connection such that I can print the values over terminal and capture them to a text file on my PC.

Okay, a couple important questions:

1) What is the maximum voltage I should expect into the ADC? The ADC block had Vref connected to VDDA, and the single-ended negative input is also set to Vref. This sets the "Single ended mode range" to "Vdda (3.3 V) to 0.0", and, when I disconnect the sensor entirely from the board, I see 3.301643 volts printed to the terminal (open connection). I know these are quite close, but they're not quite the same. Is this discrepancy normal?

2) I've got the ADC configured to be 12-bit, which should be 4096 counts full range. When I increase the resistance of my sensor, I can get it as high as ~8200 counts, which just exceeds 13 bits. Do I have my ADC configured incorrectly?

3) I've noticed that occasionally some of the voltages reported by the ADC for an individual sensor will "blip" up by a few 1000 counts before coming back down to the nominal level of the other sensors. I've reached out the sensor vendor, and after confirming that I've connected a battery to the kit to stabilize the board voltage (it was just powered off the USB cable before) they've commented that something could be going on with the inherent capacitance of the ADC relative to the timing of my ADC readings. Does anyone have any insight into how I can quantify this and change my timing to accomodate?

Apologies for the long read, any comments are greatly appreciated! If this is posted to the wrong section please point me in the right direction.

Thank you!

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

I did some additional tweaking with my project and figured out a couple things that greatly help improve things, mainly by tweaking the AMux module.

1) First, when trying to read one, and only one, channel at a time via the AMux, you can configure the AMux to do so by enabling the "AtMostOneActive" feature in its block in the .cysch file. By using this, in combination with calling the correct function in my code (now use "_FastSelect()" instead of "_Select()") ensures that only one channel is being connected by the AMux at a time. Essentially, what was happening previously was that the AMux wasn't properly disconnecting the old channel before connecting the new channel, causing multiple voltages to be read through the AMux and being converted by the SAR ADC. This greatly cleared things up. I also increased the allowable ADC cycles for the SAR ADC to convert the signal, giving it sufficient overhead to be safe.

2) After iterating through the sequence of channels, and prior to iterating again, I also had to add a second function call of "_FastSelect()" in order to ensure that the proper channel was being read on subsequent loops. This could also be a bug in my own code, by I'm ok with this band-aid in my project for now.

I also added a nifty while() inside my main for(;;) that dynamically changes the current being set in the IDAC prior to converting the voltage on the ADC. This greatly increases my measurement range for my resistive sensors, now with a range from as small as 100s of ohms, to up 2.5M ohms. Definitely a plus for this type of hardware over a more conventional voltage divider circuits.

View solution in original post

0 Likes
2 Replies
RyanZhao
Moderator
Moderator
Moderator
250 sign-ins First question asked 750 replies posted

Suggest removing all digital blocks just leave analog blocks, have a debug to monitor if the result is correct. - Guarantee the issue is not caused by system/code/isr....

Then debug step by step, to double-check if the result is reasonable. - Is the issue caused by IDAC + ADC ?

How about using an external VDD+pull-ups on sensor channels?

Thanks,

Ryan

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

I did some additional tweaking with my project and figured out a couple things that greatly help improve things, mainly by tweaking the AMux module.

1) First, when trying to read one, and only one, channel at a time via the AMux, you can configure the AMux to do so by enabling the "AtMostOneActive" feature in its block in the .cysch file. By using this, in combination with calling the correct function in my code (now use "_FastSelect()" instead of "_Select()") ensures that only one channel is being connected by the AMux at a time. Essentially, what was happening previously was that the AMux wasn't properly disconnecting the old channel before connecting the new channel, causing multiple voltages to be read through the AMux and being converted by the SAR ADC. This greatly cleared things up. I also increased the allowable ADC cycles for the SAR ADC to convert the signal, giving it sufficient overhead to be safe.

2) After iterating through the sequence of channels, and prior to iterating again, I also had to add a second function call of "_FastSelect()" in order to ensure that the proper channel was being read on subsequent loops. This could also be a bug in my own code, by I'm ok with this band-aid in my project for now.

I also added a nifty while() inside my main for(;;) that dynamically changes the current being set in the IDAC prior to converting the voltage on the ADC. This greatly increases my measurement range for my resistive sensors, now with a range from as small as 100s of ohms, to up 2.5M ohms. Definitely a plus for this type of hardware over a more conventional voltage divider circuits.

0 Likes