RPICT Full Output Firmware
Installation
We assume here the Raspberrypi has been prepared with the guide below.
Howto_setup_Raspbian_for_serial_read
We also assume the packages to flash the Arduino have been setup.
Upload_Arduino_sketch_from_Raspberrypi_to_RPICT
Get the firmware:
wget lechacal.com/RPICT/sketch/RPICT_FULL_OUTPUT_001_v4.1.0.ino.hex
Flash it with:
lcl-upload-sketch.sh RPICT_FULL_OUTPUT_001_v4.1.0.ino.hex
Configuration
The configuration mechanism remain the same as for the default factory firmware.
Over_Serial_Configuration_-_Sketch_4
The web tool can be used in exactly the same way.
Only one thing differ. The section 'Output Channels' can be left empty as the full output firmware will not use this and have its own control of the output.
The use lcl-rpict-config.py command line tool can also be used with this firmware.
Usage
Plain output
When using the lcl-run command produces the following output.
lcl-run
The output format is described in detail in the next part of this guide.
There is one line per computation node.
Decoded Output
We have created a small python library to decode the data.
The zip package downloaded above contains a very simple example usage.
import rpictpylib as rpict
import serial
if __name__ == "__main__":
ser = serial.Serial("/dev/ttyAMA0", 38400)
ser.flush()
while True:
try:
line = ser.readline().decode().strip()
dec = rpict.decode_full_output(line, ['rpict4v3'])
if dec != None:
print("---------------------------------")
print(dec)
except KeyboardInterrupt:
ser.close()
break
except UnicodeDecodeError:
pass
The serial port is read and stores each received line in the 'line' parameter. The parameter 'dec' is the decoded information in the form of a python dictionary.
decode_full_output() function is used to decode the line. It takes a list of the stack of RPICT cards used which is a list composed of any 'rpict7v1' 'rpict8' 'rpict4v3'.
Run it using
python3 fulloutput-demo.py
This prints out python dictionary containing the data like below.
Clearly this is not the most human readable form. This is why we have created a couple of additional functions.
- print_sequential(dec)
- display_matrix()
Sequential Print Out
We invite you to look inside the python script called lcl-fulloutput-decode.py which demonstrate how these are used.
To present the data in sequential form you can run
lcl-fulloutput-decode rpict4v3 -s
(replace rpict4v3 with whatever you have. If you have a stacked setup use for example rpict4v3,rpict8)
The text below will be shown.
This is a little bit easier to read and you can see the complete information. Note for example that you can see the time which is the time since the microcontroller started.
In the above command replace rpict4v3 with the card model that is used. For example if a stacked system is used one would run
lcl-fulloutput-decode rpict4v3,rpict8 -s
Matrix Print Out
The matrix display is certainly the most comfortable for real time monitoring. The time information disappear as several computation output are shown and are not from the same computation time.
Just use the command without the -s option.
lcl-fulloutput-decode rpict4v3
Output Format
The output format generally follow the following rule.
{node_type}{coordinates}{time}{data}
- node_type is an id describing the type of computation used. See table below.
- coordinates provides information on which ports are used.
- time gives the start and end time since mcu boot.
- data are all usual data like Irms Vrms Active Power etc.
Node Types
We call a node a single computation performed by the mcu. They are all listed below.
code | Node Type | Description | |
---|---|---|---|
2 | snode | Signal Node. | Compute RMS only of a single channel. Efficient and lightweight computation. |
3 | pnode | Power Node. | Computes all power related values of a current/voltage pair. Requires definition of both current and voltage sensor ports. |
4 | fnode | Frequency Node. | Computes frequency only on a given sensor port. |
5 | tnode | Three Phase Node. | Same as pnode but for three phase. |
Using the very first output we see on this page (plain output) we can see the first code for each line is 2 4 4 4 and 5. This means we are using one single signal node then three frequency node and one 3phase node.
Coordinates
The coordinates are used to point to the ports used to read the signals. For example CT1 on slave 1 and V1 on master card.
We call CT1 CT2 V1 V2 etc 'ports'.
We call slave 1 slave 2 master etc 'levels'.
In the output they are given as integer with a specific code shown in tables below. Each node type has different coordinates structure.
- Single Signal node: port level
- Power node: port_I level_I port_V level_V
- Frequency: port level
- 3phase: port_I1 level_I1 port_V1 level_V1 port_I2 level_I2 port_V2 level_V2 port_I3 level_I3 port_V3 level_V3
Codes are given below.
Pin number snode_pin/pnode_pinI/pnode_pinV etc... |
RPICT7V1 | RPICT8 | RPICT4V3 |
---|---|---|---|
0 | V1 | CT8 | V3 |
1 | CT7 | CT7 | V2 |
2 | CT6 | CT6 | V1 |
3 | CT5 | CT5 | nc |
4 | CT4 | CT4 | CT4 |
5 | CT3 | CT3 | CT3 |
6 | CT2 | CT2 | CT2 |
7 | CT1 | CT1 | CT1 |
Pin number HWMCPSCT/HWMCPVOL |
Board type |
---|---|
10 | Master |
6 | Slave 1 |
7 | Slave 2 |
8 | Slave 3 |
9 | Slave 4 |