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

myDVM Done Dirt Cheap - Part 1

ScottK_91
Employee
First solution authored 10 sign-ins 5 sign-ins
Employee

myDVM Done Dirt Cheap - Part 1

Fall time seems like a good time to focus on cleaning out clutter, doesn’t it? 😄 Well, while doing that I found a box of used AA batteries from Halloween string lights. I really didn’t want to get rid of them because they might have enough life left for a mouse, a keyboard, or the many remotes around the house.

Since my basement is cluttered (polite term for it), naturally I can’t put my fingers on where I placed my old DVM to measure the battery voltage.  In the box where I thought I placed the old DVM, I found a PSoC 63 CY8CPROTO-063-BLE proto board. 
Hmm…I guess I could always make a new DVM.  Sounds like something an engineer might do.  It’s a purpose driven life, right? 😉

This low-cost prototype board features the Infineon AIROC CYBLE-416045-02 certified EZ-BLE Creator module based on CY8C6347BZI-BLD53 MCU silicon.  I see in the module datasheet, a 12-bit 1 Msps SAR ADC is available that I can use to measure the AA battery voltage.  I know what to do with the 12-bit voltage DAC later.

It’s easy to start and finish my new DVM design using ModusToolbox 3.0 It has many configuration tools and plenty of code examples.  I will be able to measure my AA batteries quicker than I can find my old DVM in my basement!  Actually…much quicker.

After downloading, installing, and launching ModusToolbox 3.0, I start a “New Application” within the Quick Panel to launch the Project Creator tool and pick the CY8CPROTO-063-BLE Board Support Package (BSP.)

The CY8CPROTO-063-BLE documentation in the Quick Panel will help me understand the hardware configuration for the board.

ScottK_91_0-1669124096896.png

 

I have a long list of example applications to choose from.  The “ADC_basic” application description states, “this example demonstrates use of the ADC (Analog to Digital Converter) HAL driver to perform voltage measurements.”  Yep, this is what I need to measure AA batteries.  Having an example code will get me to the finish line faster.  I will change the default application name to ‘myDVM’ and create my firmware.

 

ScottK_91_1-1669124096902.png

 

ScottK_91_2-1669124096908.png

 

 

Like on my misplaced DVM, I will need a method to display the measured battery voltage.  By default, the example code configures one ADC channel in single ended mode and prints the conversion result through the debug UART for viewing on a terminal program using cy_retarget_io_init API found in main.c, line 205.

ScottK_91_3-1669124096914.png

 

Default configuration

ADCs need a voltage reference (Vref) and I see on line 145, main.c, the ADC Vref is configured to VDDA through the CYHAL_ADC_REF_VDDA define in the cyhal_adc_config_t structure.  

ScottK_91_4-1669124096922.png

     

What is VDDA set to?

The Quick Panel BSP documentation tells me VDDA on the proto board is set to 3.3V.

ScottK_91_5-1669124096927.png

 

This can be verified on the CY8CPROTO-063-BLE schematic found on Infineon’s website.

 

Software modification  

Measuring a 1.5V AA battery within a 0 to 3.3V range does not provide the accuracy an **bleep**-retentive engineer, like me, desires.  But, since Vref is wired to VDDA, I can’t make a hardware change.  Hmmm…

Combing through the HAL documentation at the Quick Panel link, I see that I have an option to divide the ADC VDDA Vref by two.  3.3V/2 = 1.65V provides a tight range perfect for a 1.5V battery.

ScottK_91_6-1669124096935.png

 

At line 145 in main.c, I’ll change “CYHAL_ADC_REF_VDDA” to “CYHAL_ADC_REF_VDDA_DIV_2”.  

ScottK_91_7-1669124096942.png

 

Hardware modification

I need to solder a couple of lengths of wire on the prototype board to function as probes:

  • J2-21 (GND for the negative probe)
  • J2-10 (ADC input on Port 10.0 verified as positive probe from line 72, main.c)

ScottK_91_8-1669124096945.png

After connecting the prototype board to the PC and going through USB enumeration, I found the COM port.  I use CoolTerm for my terminal program and configure the COM port for:

  • 115,200 Baudrate
  • 8-N-1

All set to build and program the proto board using the ‘myDVM Program (KitProg3_MiniProg4)’ launch option found under the Quick Panel ‘Launches’ heading. 

ScottK_91_9-1669124096949.png

Once done, you will see the terminal update with the message on line 217, main.c (see below.)

Time to test

While connecting my AA battery to myDVM probes, I remember Woody’s quote from Toy Story when the toys were placing the batteries back into RC’s remote-control unit, “PLUS IS POSITIVE!  MINUS IS NEGATIVE!” Sorry, I love that movie…Now, I can see the first AA battery I picked out of the box looks good enough to use again.  On to the next battery…

ScottK_91_10-1669124096953.png

 

ScottK_91_11-1669124096986.jpeg

 

What about the DAC I mentioned earlier? – you will find out in Part 2 of this blog series.
Stay tuned!

0 Likes
48 Views