Over Serial Configuration - Sketch 2.2
This article is for sketch RPICT7V1 version 2.2.
Serial utility
To configure the RPIct7V1 (version 2) or RPICT8 over serial a serial terminal tool should be used.
There are two possible ways that we recommend.
Using plink
Install plink as indicated here.
Then start the comms with the board with the command below:
$ plink -serial /dev/ttyAMA0 -sercfg 38400
This will open a session ready to send commands. Enter any commands from the table below and press return.
Using stty, cat, echo.
This method does not require any installation. Two terminal windows will be opened (ssh, putty etc...). One for reading the other for sending commands.
On the first terminal configure the serial like so:
stty -F /dev/ttyS0 raw speed 38400
Then start reading the data from the rpict board:
$ cat /dev/ttyAMA0
On the second terminal command can be sent to the serial port using the echo command. For example:
$ echo "a_command" > /dev/ttyAMA0
This will send the command a_command to the serial port.
As the RPICT7V1 continuously send current/power/voltage data at regular intervals we need to interrupt the board first. The "x" command is used for this. This will instruct the rpict7v1 to stop sending data and listen for commands. We will call this the interactive mode.
$ echo "x" > /dev/ttyAMA0
Command list
The table below shows all available commands.
Command | Description | Parameters value/range | Example |
---|---|---|---|
x | Enter/exit interactive mode. | None | x |
Prints entire configuration | None | ||
polling <interval> | Change the polling interval. | <interval> in seconds in the range 0 to 255. | polling 5 |
format <f> | Modify the output format. | <f> is 0 or 1. 0: CSV. |
format 0 |
id <nodeid> | For Emoncms format only. Modify the Emoncms node ID. | <nodeid> in the range 0 to 255. | id 11 |
vcal <vcal> | Modify the voltage calibration coefficient. | <vcal> can be any floating point number. | vcal 548.0 |
ical <ical> | Modify the current calibration coefficient. | <ical> can be any floating point number. | ical 83.33 |
addnode <current_pin> <slave_pin> <voltage_pin> <slave_pin> | Add an additional node for computing power with a given current/voltage combination. See below for further details on pins number. | <current_pin> and <voltage_pin> must be one of 1,2,3,4,5,6,7,8. <slave_pin> must be one of 10,6,7,8,9. |
addnode 8 6 1 10 The above will use current on ct1 on slave1 computed against voltage1 on the master board. |
addchannel <combid> <type> | Add an output channel. <comid> is the combination node id calculating the data. Use print to find out. <type> is the type of data (real power, vrms, etc..). | <comid> is a number from 0 to 255. <type> is a number from 0 to 5. 0: None 1: RealPower 2: ApparentPower 3: Vrms 4: Irms 5: EstimatedPower |
addchannel 0 3 this example add a realpower channel computed from combination id 0. |
rmnode | remove the last combination node | None | rmnode |
rmchannel | remove the last channel | None | rmchannel |
zero | remove all combination nodes and channels | None | zero |
vest <vest> | setup voltage for estimated power. (usage without voltage sensor). Must be set to zero if using voltage sensor (vest 0). Only Irms and Pest are avaible if vest is enabled. | <vest> is an integer. | vest 240 |
A print example
This is an example of what the print command output looks like:
# # Polling: 5 # Format: 0 # Emoncms ID: 65 # VCAL: 548.00 # ICAL: 83.33 # Vest: 0 # # Nodes # id sct sla vol sla # 0 8 10 1 10 # 1 7 10 1 10 # 2 6 10 1 10 # 3 5 10 1 10 # 4 4 10 1 10 # 5 3 10 1 10 # 6 2 10 1 10 # # Channels # n id type # 0 0 1 # 1 1 1 # 2 2 1 # 3 3 1 # 4 4 1 # 5 5 1 # 6 6 1 # 7 0 4 # 8 1 4 # 9 2 4 # 10 3 4 # 11 4 4 # 12 5 4 # 13 6 4 # 14 0 3
Combination nodes
Combination nodes are small programs in the microcontroller that computes power given a current/voltage couple.
When configuring the board with addnode the four given parameters are the pin numbers where to find the current and voltage and also which slave (or master) is to be used.
For example
addnode 8 6 1 10
will use current ct1 (8) on slave 1 (6) computed against voltage1 (1) on master board (10).
The tables below gives all pin assignment:
Pin number | RPICT7V1 | RPICT8 | RPICT4V3 |
---|---|---|---|
1 | V1 | CT8 | V3 |
2 | CT7 | CT7 | V2 |
3 | CT6 | CT6 | V1 |
4 | CT5 | CT5 | nc |
5 | CT4 | CT4 | CT4 |
6 | CT3 | CT3 | CT3 |
7 | CT2 | CT2 | CT2 |
8 | CT1 | CT1 | CT1 |
Pin number | Board type |
---|---|
10 | Master |
6 | Slave 1 |
7 | Slave 2 |
8 | Slave 3 |
9 | Slave 4 |
Channels
We are refering as a channel here a data stream to be sent out. For example Vrms and Realpower derived from a same sensor will be two different channels.
These are configured with the addchannel command. Two numbers must follow. The first one is the combination id defined above. The id is given when issuing a print command. The second number identifies the type of channel. For example:
addchannel 0 3
Add another channel using voltage/current combination node id 0. Channel type 3 which is Vrms (as the table below describes).
The table below shows the convention being used:
code | Channel Type | Description |
---|---|---|
0 | None | |
1 | Real Power | Real Power in Watts |
2 | Apparent Power | Apparent Power in Watts. This is Irms*Vrms |
3 | Vrms | Rms Voltage in Volts |
4 | Irms | Rms current in milliAmps |
5 | Estimated Power | Estimated Power in Watts. This is Irms*Vest. |
Using Configuration file
To automate the configuration without having to enter the commands one by one one can save all these above commands in a file and execute them together using a simple Linux (bash) command.
For example this is the content of a single RPICT7V1 in single board usage configuration file. We use filename 1xrpict7v1.conf for the example.
x print zero vest 0 addnode 8 10 1 10 addnode 7 10 1 10 addnode 6 10 1 10 addnode 5 10 1 10 addnode 4 10 1 10 addnode 3 10 1 10 addnode 2 10 1 10 addchannel 0 1 addchannel 1 1 addchannel 2 1 addchannel 3 1 addchannel 4 1 addchannel 5 1 addchannel 6 1 addchannel 0 4 addchannel 1 4 addchannel 2 4 addchannel 3 4 addchannel 4 4 addchannel 5 4 addchannel 6 4 addchannel 0 3 print x
To execute them use the command shown below. Make sure this is done out of interactive mode. i.e. data are being displayed.
$ while read line; do echo $line > /dev/ttyS0; sleep 0.1; done < 1xrpict7v1.conf
If using another configuration only replace the filename 1xrpict7v1.conf as appropriate.
We have preconfigured some usual configurations below and summarised them in a table.
Filename | Description |
---|---|
1xrpict7v1.conf | Single board. 7 channels of realpower. 7 channels of Irms. 1 channel of Vrms. |
2xrpict7v1.conf | 2 boards. One master and one slave. 1 channel of Vrms. 14 channels of realpower. |
5xrpict7v1.conf | 5 boards. One master and four slaves. 1 channel of Vrms. 35 channels of realpower. |
1xrpict7v1_est.conf | Single board. 7 channels of estimated power. Using 240V. For use without voltage sensor. |
1xrpict8_est.conf | Single board. 8 channels of estimated power. Using 240V. For use with RPICT8. |
Restore Default Config
If things go wrong it is possible to reinstate default configuration as shown below.
RPICT7V1
$ wget http://lechacal.com/RPICT/7CT1V/1xrpict7v1.conf $ while read line; do echo $line > /dev/ttyAMA0; sleep 0.1; done < 1xrpict7v1.conf
RPICT8
$ wget http://lechacal.com/RPICT/7CT1V/1xrpict8_est.conf $ while read line; do echo $line > /dev/ttyAMA0; sleep 0.1; done < 1xrpict8_est.conf