Getting a sensor and an MCU to communicate reliably can be a challenge—especially if you are new to the MCU. When you just want to quickly evaluate a sensor, or something else, the best solution is a fast way to configure the peripherals (an ADC in this case), and capture the effects of the different sensors.
To illustrate this, I designed an experiment to test a flex sensor with the Silicon Labs EFM8 Sleepy Bee SB1 8-bit MCU. I chose the EFM8 Sleepy Bee MCU because my (fictional) target application will run on a battery and needs to be ultra-low power.
EFM8 Sleepy Bee EVB
Sleepy Bee a great fit for this application because the ADC operates in configurable low power modes, which is a feature that is hard to find in a low cost MCU. The ADC will support 12-bit ADC with 75ksps or 300ksps with 10 bit mode, which I chose to take many rapid readings from the sensor.
Next I selected the sensors I wanted to evaluate. I chose a couple of different sensors. One from Spectra Symbol part number SEN-08606. And one from Flexpoint Sensor Systems part number 176-3-001.
Flex Sensor Options from Spectra Symbol and Flexpoint
Each sensor can be powered by 5V or 3.3V, depending on performance and signal coming from the MCU. They work as a variable resistor, so as the bend of the sensor changes the resistance changes as well, altering the voltage across it. This voltage drop corresponds to the bend or arch the sensor is. I used 3.3V for this design to reduce power consumption. So the sensor divides this and returns a voltage somewhere in the 0.5-2.5V range.
Next I needed to configure the ADC on the MCU. For this, I downloaded Simplicity Studio which includes a free IDE and compiler.
Simplicity Studio also includes an ADC reference design, which made getting the ADC up and running superfast. Loading the reference design was simple and it had the ADC configured with the settings I needed above.
Simplicity Studio ADC Input Pin Dialog Box
Simplicity Studio ADC Configuration Dialog
Once I finished configuring the ADC settings and pins, the Simplicity Studio reference design spit out code for me too. In other words, I had to write no code to evaluate these sensors. All I had to do was select configuration options and check boxes.
Simplicity Studio Code Snippet
Next I configured the set up on my desktop. In the sensor set up image, the red wire runs 3.3V to the sensor. The green wire is the input to the ADC. And the brown wire goes to a potentiometer and then to ground so I can alter the pot’s resistence to create the largest voltage swing.
The last step was to see if my set-up worked, and to take some power measurements.
As I bent the sensor, the voltage drop increased and the voltage read back decreased. Success! My set-up was working.
Output of Voltage Readback from Sensor
Now to Test power consumption. Simplicity Studio’s Energy Profiler allowed me to see the auto-generated code’s power consumption in real-time.
Simplicity Studio Energy Profiler Power Consumption Readings
Energy Profiler also allows the code to be broken down to provide insight into where the most power is consumed. This is a simple example where I am reading the ADC so the current consumption is relatively flat. When I am ready to develop the application further this will be a powerful tool to extend my battery life.
10 minutes is all it took to evaluate two sensors and compare their current consumption. EFM8 Sleepy Bee is super flexible and has a perfectly suited, low-power ADC. And Simplicity Studio has a ton of EFM8 examples that make it easy to configure and utilize its functionality including its ADC, SPI, LCD, and many more.