Over Serial Configuration - Sketch 2.1: Difference between revisions
(44 intermediate revisions by the same user not shown) | |||
Line 18: | Line 18: | ||
This will send the command a_command to the serial port. | 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. 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. | 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/ttyS0 | $ echo "x" > /dev/ttyS0 | ||
Line 26: | Line 26: | ||
{| class="wikitable" | {| class="wikitable" | ||
|+ | |+Command list | ||
|- | |- | ||
!Command | !Command | ||
!Description | !Description | ||
! | !Parameters value/range | ||
!Example | !Example | ||
|- | |- | ||
| x | | x | ||
| Enter/exit interactive mode. | | Enter/exit interactive mode. | ||
| None | | None | ||
| | | x | ||
|- | |- | ||
|print | |print | ||
|Prints entire configuration | |Prints entire configuration | ||
|None | |None | ||
| | |print | ||
|- | |- | ||
|polling <interval> | |polling <interval> | ||
Line 55: | Line 53: | ||
|<f> is 0 or 1.<br>0: CSV.<br> 1: Emoncms | |<f> is 0 or 1.<br>0: CSV.<br> 1: Emoncms | ||
|format 0 | |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. <br> <slave_pin> must be one of 10,6,7,8,9. | |||
|addnode 8 6 1 10<br><br> 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.<br> <type> is a number from 0 to 4. <br>0: None<br>1: RealPower<br>2: ApparentPower<br>3: Vrms<br>4: Irms | |||
|addchannel 0 3<br><br> 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 | |||
|- | |||
|} | |||
==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 | |||
# 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: | |||
{| class="wikitable" | |||
|+current_pin voltage_pin | |||
|- | |||
!Pin number | |||
!RPICT7V1 | |||
!RPICT8 | |||
|- | |||
|1 | |||
| V1 | |||
| CT8 | |||
|- | |||
|2 | |||
|CT7 | |||
|CT7 | |||
|- | |||
|3 | |||
|CT6 | |||
|CT6 | |||
|- | |||
|4 | |||
|CT5 | |||
|CT5 | |||
|- | |||
|5 | |||
|CT4 | |||
|CT4 | |||
|- | |||
|6 | |||
|CT3 | |||
|CT3 | |||
|- | |||
|7 | |||
|CT2 | |||
|CT2 | |||
|- | |||
|8 | |||
|CT1 | |||
|CT1 | |||
|- | |||
|} | |||
{| class="wikitable" | |||
|+slave master pins | |||
|- | |||
!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 shown in the table below. | |||
The table below shows the convention being used: | |||
{| class="wikitable" | |||
|+ | |||
|- | |||
!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 | |||
|- | |||
|} | |||
==Using Configuration file== | |||
Here is a great feature. All these commands can be saved in a file and executed together using one simple Linux (bash) command. | |||
For example this is the content of a single RPICT7V1 in single board usage configuration file: | |||
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 | |||
Lets save these commands in a file called 1xrpict7v1.conf. 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. | |||
{| class="wikitable" | |||
|+ | |||
|- | |||
!Filename | |||
!Description | |||
|- | |||
|[http://lechacal.com/RPICT/7CT1V/1xrpict7v1.conf 1xrpict7v1.conf] | |||
|Single board. 7 channels of realpower. 7 channels of Irms. 1 channel of Vrms. | |||
|- | |||
|[http://lechacal.com/RPICT/7CT1V/2xrpict7v1.conf 2xrpict7v1.conf] | |||
|2 boards. One master and one slave. 1 channel of Vrms. 14 channels of realpower. | |||
|- | |||
|[http://lechacal.com/RPICT/7CT1V/5xrpict7v1.conf 5xrpict7v1.conf] | |||
|5 boards. One master and four slaves. 1 channel of Vrms. 35 channels of realpower. | |||
|- | |- | ||
|} | |} |
Latest revision as of 20:51, 9 December 2016
This article is for sketch RPICT7V1 version 2.1.
Note a web interface page will be develop in a close future.
Preliminaries
To configure the RPIct7V1 (version 2) over serial a serial terminal tool is required. We recommend using simple Linux terminal command (stty, cat, echo).
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/ttyS0
On the second terminal command can be sent to the serial port using the echo command. For example:
$ echo "a_command" > /dev/ttyS0
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/ttyS0
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. 1: Emoncms |
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 4. 0: None 1: RealPower 2: ApparentPower 3: Vrms 4: Irms |
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 |
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 # 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 |
---|---|---|
1 | V1 | CT8 |
2 | CT7 | CT7 |
3 | CT6 | CT6 |
4 | CT5 | CT5 |
5 | CT4 | CT4 |
6 | CT3 | CT3 |
7 | CT2 | CT2 |
8 | 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 shown in the table below.
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 |
Using Configuration file
Here is a great feature. All these commands can be saved in a file and executed together using one simple Linux (bash) command.
For example this is the content of a single RPICT7V1 in single board usage configuration file:
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
Lets save these commands in a file called 1xrpict7v1.conf. 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. |