I've gotten the basic functionality of my Secure Entry project working, so it's time to look at implementing the "low power" element. Modus Toolbox provides the capability to implement low power applications of the PSoC 6 with wifi-bt by using the Low Power Assistant Middleware (LPA) Library - https://github.com/Infineon/lpa .
The Modus Toolbox has a WLAN Low Power example application that is accessible from the Quick Panel New Application Menu. The application is on github: https://github.com/Infineon/mtb-example-anycloud-wlan-lowpower .
Basic operation of the example is that after a period of network inactivity the WLAN device is put into a power save mode, suspends the network stack and puts the host MCU in a wait state. During this wait state, the host MCU enters a low-power state and wakes up on any network activity detected on the MAC interface. I'm going to use this example to test out the library and then try to integrate it into my project.
To observe the effect of the power save mode I am going to measure the MCU VDD current. The PSoC6 board has a various header locations where you can insert an ammeter to measure power supply currents:
The location of the header is shown below.
To log the current measurements I am going to use a Nordic Power Profiler Kit II in ammeter mode.
Output from PuTTy serial terminal while program is running:
=============================================================== CE230106 - WLAN Lowpower =============================================================== WLAN MAC Address : C4:AC:59:9C:6A:F6 WLAN Firmware : wl0: Apr 26 2021 04:04:15 version 13.10.271.265 (aa096f9 CY) FWID 01-29e05f8 WLAN CLM : API: 18.2 Data: 9.10.0 Compiler: 1.36.1 ClmImport: 1.34.1 Creation: 2021-04-26 04:01:15 WHD VERSION : v2.0.0 : v2.0.0 : GCC 9.3 : 2021-10-05 12:02:55 +0000 Offloads not configured ===================================================== Network is active. Resuming network stack Network Stack Suspended, MCU will enter DeepSleep power mode Resuming Network Stack, Network stack was suspended for 482ms ===================================================== WHD Stats.. tx_total:98, rx_total:136, tx_no_mem:0, rx_no_mem:0 tx_fail:0, no_credit:0, flow_control:0 Bus Stats.. cmd52:2534, cmd53_read:679, cmd53_write:690 cmd52_fail:0, cmd53_read_fail:0, cmd53_write_fail:0 oob_intrs:130, sdio_intrs:284, error_intrs:0, read_aborts:0 ===================================================== Network is active. Resuming network stack Network Stack Suspended, MCU will enter DeepSleep power mode Resuming Network Stack, Network stack was suspended for 478ms ===================================================== WHD Stats.. tx_total:104, rx_total:143, tx_no_mem:0, rx_no_mem:0 tx_fail:0, no_credit:0, flow_control:0 Bus Stats.. cmd52:2543, cmd53_read:719, cmd53_write:704 cmd52_fail:0, cmd53_read_fail:0, cmd53_write_fail:0 oob_intrs:138, sdio_intrs:300, error_intrs:0, read_aborts:0 ===================================================== Network is active. Resuming network stack Network Stack Suspended, MCU will enter DeepSleep power mode Resuming Network Stack, Network stack was suspended for 480ms ===================================================== WHD Stats.. tx_total:110, rx_total:151, tx_no_mem:0, rx_no_mem:0 tx_fail:0, no_credit:0, flow_control:0 Bus Stats.. cmd52:2552, cmd53_read:754, cmd53_write:717 cmd52_fail:0, cmd53_read_fail:0, cmd53_write_fail:0 oob_intrs:145, sdio_intrs:314, error_intrs:0, read_aborts:0 ===================================================== Network is active. Resuming network stack Network Stack Suspended, MCU will enter DeepSleep power mode Resuming Network Stack, Network stack was suspended for 481ms ===================================================== WHD Stats.. tx_total:116, rx_total:158, tx_no_mem:0, rx_no_mem:0 tx_fail:0, no_credit:0, flow_control:0 Bus Stats.. cmd52:2561, cmd53_read:814, cmd53_write:735 cmd52_fail:0, cmd53_read_fail:0, cmd53_write_fail:0 oob_intrs:157, sdio_intrs:338, error_intrs:0, read_aborts:0 ===================================================== Network is active. Resuming network stack Network Stack Suspended, MCU will enter DeepSleep power mode Resuming Network Stack, Network stack was suspended for 488ms ===================================================== WHD Stats.. tx_total:122, rx_total:183, tx_no_mem:0, rx_no_mem:0 tx_fail:0, no_credit:0, flow_control:0 Bus Stats.. cmd52:2570, cmd53_read:883, cmd53_write:751 cmd52_fail:0, cmd53_read_fail:0, cmd53_write_fail:0 oob_intrs:167, sdio_intrs:382, error_intrs:0, read_aborts:0 ===================================================== Network is active. Resuming network stack Network Stack Suspended, MCU will enter DeepSleep power mode Resuming Network Stack, Network stack was suspended for 471ms ===================================================== WHD Stats.. tx_total:129, rx_total:190, tx_no_mem:0, rx_no_mem:0 tx_fail:0, no_credit:0, flow_control:0 Bus Stats.. cmd52:2579, cmd53_read:923, cmd53_write:766 cmd52_fail:0, cmd53_read_fail:0, cmd53_write_fail:0 oob_intrs:175, sdio_intrs:398, error_intrs:0, read_aborts:0 ===================================================== Network is active. Resuming network stack Network Stack Suspended, MCU will enter DeepSleep power mode Resuming Network Stack, Network stack was suspended for 480ms ===================================================== WHD Stats.. tx_total:135, rx_total:198, tx_no_mem:0, rx_no_mem:0 tx_fail:0, no_credit:0, flow_control:0 Bus Stats.. cmd52:2588, cmd53_read:968, cmd53_write:781 cmd52_fail:0, cmd53_read_fail:0, cmd53_write_fail:0 oob_intrs:184, sdio_intrs:416, error_intrs:0, read_aborts:0 =====================================================
As a sanity check before connecting the Power Profiler, I just inserted my DMM in ammeter mode to verify the connection was correct. Not too useful, but shows the toggling between power states.
Then I attached the Power Profiler and got the following result. I wasn't exactly sure what to expect, but it looks like the initial short current interval appears to be the mcu waking up and the longer interval that follows is the WLAN interface alive. The inactivity timeout is set to 300ms. I'm not sure what network activity is waking it up as I'm not doing anything explicitly, but it's occurring faster than once a second. The current draw when the WLAN interface is running is about 2.8 mA.
I'm a bit confused by the power modes:
POWERSAVE_WITHOUT_THROUGHPUT,
POWERSAVE_WITH_THROUGHPUT,
POWERSAVE_DISABLED
because the default was running with POWERSAVE_WITH_THROUGHPUT which waits for the inactivity timeout which seems to correspond to the plot, but when I switched to POWERSAVE_DISABLED - I didn't see any change.
I did see an effect when I extended the inactivity timeout interval to 1 second as shown below, the WLAN stays active for that extended time. The operational current stays the same.
The next data is looking at what my Secure Entry program is currently doing. I took a snapshot of 2 minutes of activity. There are 3 periods of extended current draw (as indicated by the white gaps of current above 10 mA). The first one is when the MQTT interface is initializing, the second is the response to the "Motion Detected" message and the third is in response to the "Area Secure" message. It also shows that I am picking up the LED current between those 2 messages. It's interesting that there is a lot of low duty-cycle activity also - the average current for this period is 1.67 mA although there is lots of activity with current > 15 mA.
So, start to zoom in on the initial period by factors of 2.
One minute interval
30 second interval
Then a 2 second interval that details the "Motion Detected" message period. The current is up around 14 mA and the duration is around 800 mS.
And a zoom to 50 mS interval that shows detail of the high activity period prior to the "Motion Detected" message. Current is at 15 mA, but the duty-cycle is only about 10% (1mS/10mS) - so the average current for this period is only 1.55 mA.
So, there's the question of how much using the Low Power Assistant Middleware(LPA) Library would reduce the power in my application. The current during the messaging phase is 14 mA in my application. How much of that is WLAN power? In the WLAN Low Power Example, the current was 2.8 mA when the WLAN was active.
Next step is to try to incorporate the LPA library in my application...