RPICT Full Output Firmware
The Full Output Firmware provide the most complete and accurate way to use the RPICT card. The differences to the factory firmware are:
- Serial data do not have an output rate but are streamed out as soon as a sampling & computation is performed.
- All computed values are sent out.
- Field format differ line to line depending on the type of computation performed.
- Each line provide the coordinate of the reading (i.e. which sensors are involved)
- Some extra fields are computed like E+ E- and Total Power in 3 phase.
We assume the Raspberrypi has been prepared with the guide below.
We also assume the packages to flash the Arduino have been setup.
Get the firmware:
Flash it with:
The configuration mechanism remain the same as for the default factory firmware.
The web tool can be used in exactly the same way.
The use lcl-rpict-config.py command line tool can also be used with this firmware.
The section 'Output Channels' in the web tool can be left empty as the full output firmware will not use this and have its own control of the output. In the actual configuration file this corresponds to parameters CHID CH_node_type CH_field_type.
The parameter output_rate has no effect on this firmware. Data are sent out as soon as computation is done. Only the number of cycles Ncycles affects how long a computation last.
The lcl-run shows the plain output of the serial port.
The output format is described in detail in the next part of this guide.
There is one line per computation node.
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
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.
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.
The library is imported using
import rpictpylib as rpict
This function decodes the data from the RPICT serial stream and convert each line into a dictionary.
dec = decode_full_output(line, model_list)
line is the text string string received by the serial port obtained with serial.readline().
model_list is the list of RPICT model used. This must be a list and it defaults to ['rpict8']. The list must contain any of rpict7v1 or rpict4v3 or rpict8. If using a staked system the parameter could be for example ['rpict7v1', 'rpict8'].
The function returns a dictionary. The content of the dictionary depends on the computation node type used.
Note all the e_plus and e_minus above are only created once the update_storage() function has been used. See below.
The function prints out the decoded data in a nice humen readable way.
The decoding function explained above only decode the data but does not have any storage functionality. We have created a class to store the latest data received. This is handy to display the data on demand and calculate energy.
rt_data = rpict.realtime_storage()
This creates an instance of realtime storage called rt_data.
This function takes the decoded data as input and update it in the realtime storage class.
This function also computes accumulated energy using previous power and time data.
Displays the realtime storage in a matrix way.
The output format follow the following group rule.
- 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.
We call a node a single computation performed by the mcu. They are all listed below.
|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.
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.
This is the time in milliseconds since MCU boot of the beginning and end of the computation.
Note the time return to zero after 4'294'967 seconds. This is about 49 days and 17 hours.
These are the physical data being measured and computed. The format depends on the type of node type.
- Single Signal node: Irms estimated_power
- Power node: Irms Vrms active_power apparent_power reactive_power power_factor
- Frequency: frequency
- 3phase: Irms1 Irms2 Irms3 Vrms1 Vrms2 Vrms3 active_power1 active_power2 active_power3 apparent_power1 apparent_power2 apparent_power3 reactive_power1 reactive_power2 reactive_power3 power_factor1 power_factor2 power_factor3