Hi to All,
I come to the emonLibCM and this forum while investigating how to start implementation of my idea for Multichannel Home Electricity Monitoring System (https://www.radevs.net/chradev/projects/Multichannel_Home_Electricity_Monitoring_System.pdf). The idea in the beginning was to use Atmega32u4 and its feature for differential inputs and built-in OP with configurable gain which can be used to connect directly (without voltage offset) up to 9 CTs. The main advantages are no necessity of DC compensation, possibility to amplify the signal for measuring of low currents more precisely and possibility to use emonLibCM and related staff with small or no changes. In such a case it will be feasible to scan single voltage and up to 9 even more (if single ended inputs are also used) current sources. Of course the report period will be seconds but enough for home monitoring system.
While reading the forum I realize that the precision is mainly limited by the value-dependent phase errors and lower computational resources of the MCU used.
That is why I started to think about possibility to move to powerful MCU like Cortex-M4 based once. My experience in using STM32 MCUs took me away to look at STM32F405 and STM32L412 MCUs well supported by STM32Cube, ChibiOS, Arduino core support for STM32 based boards (GitHub - stm32duino/Arduino_Core_STM32: STM32 core support for Arduino) etc. STM32F405 is most standard and has 3x 12-bits ADCs with DMA and work in many different modes including simultaneous scanning of sequences of external inputs. STM32L412 low power MCU and has 2x 12-bits (up to 16-bits with oversampling) ADCs with DMA also having the same simultaneous scanning modes. Both they have FPU, DSP instruction, 5+ Msps maximum conversion rate with full resolution, fast / slow channels and many other excellent features.
Other advantages are bigger RAM, FLASH and wide communication options including USB even high speed (up to 480 Mbps) if ULPY PHY is used with STM32F405. Availability of Arduino port for these devices will make it easier to port emonLibCM for them.
Of course, the other big advantage could possibility to divide ADC sampling and RMS calculations and process them in parallel. Calculation of RMS values can be done in parallel with ADC sampling combined with DMA to a dual value ring buffer together with sequential simultaneous scanning of voltage and current source sequences. Ring buffer calculations can be combined with dynamic phase correction simply multiplying voltage and current values with value correlated offset. And the cherry of the cake will be if DSP instructions are used for the calculation. From the communication point of view the high speed U(S)ARTs and USB both working with DMA can be used to unload CPU for calculations and other activities. Other option is to use multi-threaded RTOS with good synchronization between calculations and transfer functionality.
One disadvantage of using STM32F4 MCUs is that no internal gain control to differential input option.
My question: What is more important: to use Atmega32u4 adding differential and gain control or to move to STM32F4 alternative for solving phase error issue where differential option is possible without gain control.
Best regards
Chris