Bantham, wireless energy meter

For users of Matrix Multimedia Electronics software to discuss projects, circuits and any other electronics concepts.

Moderators: Benj, Mods

Post Reply
User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

Bantham, wireless energy meter

Post by fotios »

Bantham_Moment_Moment.jpg
Bantham_Moment_Moment.jpg (105.5 KiB) Viewed 5948 times
The two boards are identical, the left is configured as energy monitor and transmitter and the right as the receiver.
The host micro is a PIC16F18877 with dual SPI bus. One bus is allocated to the polyphase energy monitor ATM90E32AS of Microchip, and the second to the LAMBDA62 LoRa (Semtech SX1262) transceiver module.
Split-core current transformers are used in the energy board for easy clamping on mains power cables.
The energy board can be used to either monitor a 3-phase mains power line or to monitor 3 single-phase power lines, coming from 2 different power sources like the mains and a domestic PV or wind generator and feeding the third line which is the consumer unit inside the home. With the appropriate program code, this system can balance the amount of power from the mains that will supplement the free of cost power provided by the green energy sources. In my case, it will be used as a companion of the EVSE that I have in development, to offer in the user the possibility of making an economy when charges an electric vehicle.
LCD indication description:
Upper line: Voltage
Second line: Amperage
Third line: Wattage
Lower line: 32-bit randomly generated number used for the pairing of LoRa transmitter - receiver.
The small difference in indications is owed to the Tx-Rx cycle of LoRa modules which is usually finished within 1 to 1.5 seconds (some times 2 sec).
The program code has been obtained with the use of Flow Code FC7 at whole, with a little help from Benj and medelec35 in two instances.

You can watch a clip with the two boards in action, as well as the pairing process.
https://www.youtube.com/watch?v=Z3ZHO5LrukQ&t=73s

The FC for the LoRa and for the ATM90E32 will be available in a few days.

Thanks
Last edited by fotios on Mon Feb 10, 2020 5:57 pm, edited 1 time in total.
Best Regards FOTIS ANAGNOSTOU

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Bantham, wireless energy meter

Post by Benj »

Wow looks impressive there, good job and thanks for sharing :D

Looking forward to seeing the code, LoRa is something I've still not managed to dabble with yet.

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

Re: Bantham, wireless energy meter

Post by fotios »

Looking forward to seeing the code, LoRa is something I've still not managed to dabble with yet.

Yes, I know, the same applies to myself. Lot of work, no time :lol:
Here is the schematic
LoRa_SX1262_TX.jpg
LoRa_SX1262_TX.jpg (127.88 KiB) Viewed 5868 times
LoRa_SX1262_TX.pdf
(47.12 KiB) Downloaded 254 times
I'm working to modify a bit the FCF, basically to remove some custom variables.
Best Regards FOTIS ANAGNOSTOU

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

Re: Bantham, wireless energy meter

Post by fotios »

So, here we go.
Attached is the Transmit FCF. I tried to separate the code related to ATM90E32AS energy meter but proven quite difficult as the LoRa TX-RX packet length is configured to carry out 40 bytes. The time delays within the main Loop are critical and have been calculated by experimenting to provide enough time margin for the completion of each transmission cycle. If the packet length is reduced, then new experimenting is necessary. The 4 first bytes is the pairing number. The rest 36 are the Voltage, Current, Power, 12 bytes per each phase (the system is configured for 3-phase mains power).
The new Semtech SX1262 is quite different from the old SX1272. Instead of register addresses, opcodes are used and that simplifies a lot the code development.
The Busy output of the LoRa module is mandatory (it notifies if it has finished its internal process and is free to receive new data from the host MCU).
The TX Done is not necessary and is not used as both the TX Done and TX Timeout interrupt flags are read through polling within the macro TX_MODE.
In the current application, are not necessary. If the TX Timeout flag occurs, simply the transmitter proceeds in the next set of values taken from the ATM90E32AS.
The pairing of transmitter and receiver is necessary to not receive data from foreign LoRa modules as their range is up to 24Km (as it claims RF solutions) and is some tricky. When the related switch is pressed, the PIC requests from LoRa to generate the random 32-bit number, which in the sequence is stored into PIC ROM. If you press again and again the switch, the same 32-bit number is always generated. To get a different number, you should reset (POR) the board, as the LoRa retains the first generated number as long as it is powered.
Next, the PIC sends the text Matrix TSL (for the instance :D ) in ASCII format followed by the pairing number to LoRa and then a payload of 14 bytes is transmitted (4 bytes the pairing number + 10 bytes the ASCII formatted Matrix TSL text).
The host PIC of LoRa receiver has been programmed, if it detects the text Matrix TSL to proceed in the storage of the number that follows.
After that, each time a new set of values is transmitted, the pairing number is set as a header on the payload and the receiver proceeds in the reception only if it matches its unique stored number.
Finally, any variable or macro related to LoRa begins with LR, while if it is related to ATM90E32AS begins with AT.
That's to the present. If I forgot something, I will edit the post to add it.
The receiver FCF will follow in the next post.
Thanks
LoRa_SX1262_TX.fcfx
(198.05 KiB) Downloaded 253 times
Best Regards FOTIS ANAGNOSTOU

User avatar
fotios
Posts: 458
Joined: Mon Feb 08, 2010 10:17 am
Location: Greece
Has thanked: 109 times
Been thanked: 117 times
Contact:

Re: Bantham, wireless energy meter

Post by fotios »

Hi
Just now I found in my HD two debugged FCFs exclusively for LoRa SX1262 TX and RX. The macros for ATM90E32AS are not included. The pairing process is also not included.
LoRa_1262_TX v1.0.fcfx
(66.68 KiB) Downloaded 326 times
LoRa_1262_RX v1.0.fcfx
(89.15 KiB) Downloaded 302 times
Thanks
Best Regards FOTIS ANAGNOSTOU

Post Reply