Attiny Over Serial Configuration A1

From lechacal
Jump to: navigation, search

Overview

RPICT board using Attiny microcontroller can be configured over serial using a utility written in python.

Current version allows changes of

  • Output format (csv Emonhub Emoncms)
  • Nodeid (emoncms only)
  • Polling (polling interval of data)
  • Ical (current calibration value)
  • Vcal (Voltage calibration value)
  • Phasecal (Phase calibration)
  • Vest (estimated voltage for power estimate)

Note this applies for boards RPICT3T1 RPICT4T4 RPICT3V1

It does not apply for boards RPICT3, RPICT7V1, RPICT8, RPICT4V3.

RPICT Configuration tool

The configuration tool can be downloaded directly from the raspberrypi:

$ wget lechacal.com/RPICT/tools/lcl-rpict-config.py.zip
$ unzip lcl-rpict-config.py.zip

Reading current configuration

Using the configurator without option only read the configuration stored in the board.

$ ./lcl-rpict-config.py

This yields

# RPICT Configuration Utility
# Read only
# Now reset RPICT hardware

Once the board has received the reset the configuration will be shown. How to reset the board

# 
# Configuration in memory:
# 
# Structure: 0xa1
# Format: 3
# NodeId: 11
# Polling: 5000
# KCAL:   83.3300018311  83.3300018311  83.3300018311  1.0  1.0  1.0  1.0  545.0
# PHASECAL: 1.200000
# VEST: 240.000000
# 


Note. Every time the configuration is read from the board it stores a config file in /tmp/rpict.config.

Modify the configuration

To change the values the configurator must be fed with a file containing the new values. We will use the example of a RPICT3T1. Such file looks as below.

[main]
format = 3
nodeid = 11
polling = 5000
kcal = 83.33 83.33 83.33 1. 1. 1. 1. 545.
phasecal = 1.2
vest = 240.0

We save this file in rpict3t1.conf. Then we can now start the configurator with the -w option.

$ ./lcl-rpict-config.py -w rpict3t1.conf

Once reset the configurator will read the old config then write the new config and display the newly stored one again.

# RPICT Configuration Utility
# Configuration will be overwritten (Ctrl C to cancel)
# Now reset RPICT hardware
# 
# Configuration in memory:
# 
# Structure: 0xa1
# Format: 3
# NodeId: 11
# Polling: 5000
# KCAL:   83.3300018311  83.3300018311  83.3300018311  1.0  1.0  1.0  1.0  545.0
# PHASECAL: 1.200000
# VEST: 240.000000
# 
# Writing configuration with file new_rpict3v1.conf
# 
# Configuration in memory:
# 
# Structure: 0xa1
# Format: 3
# NodeId: 11
# Polling: 5000
# KCAL:   83.3300018311  83.3300018311  83.3300018311  1.0  1.0  1.0  1.0  545.0
# PHASECAL: 1.200000
# VEST: 110.000000
# 


The configuration file

The configuration file fed into the utility must have the format below:

[main]
format = 3
nodeid = 11
polling = 5000
kcal = 83.33 83.33 83.33 1. 1. 1. 1. 545.
phasecal = 1.2
vest = 240.0

format indicate which format output will be used. Must be an integer number.
0 - CSV
1 - Emoncms (will be deprecated)
2 - Emoncms as float (must have datatype f setup in emonhub config) (will be deprecated)
3 - Emonhub (recommended)

nodeid Only used in emoncms/emonhub format. Will set the node id.

polling Number of milliseconds between each data to be sent to the raspberrypi.

kcal ical or vcal values. The first three are ical for ct1,ct2,ct3. The last one is vcal for V1.

vest Voltage to compute estimated power. Usually 240V or 110V. Must be present even is not used. Set vest=1 to obtain output as ampere instead of watts. Set vest=1000 to get milliampere.

Restore Default Config

If things go wrong it is possible to reinstate default configuration as shown below.

Restoring the configuration will be necessary if you have just uploaded a new sketch.

RPICT3V1

$ wget lechacal.com/RPICT/config/A1/rpict3v1.conf
$ ./lcl-rpict-config.py -w rpict3v1.conf

RPICT3T1 & RPICT4T4

$ wget lechacal.com/RPICT/config/A1/rpict3t1.conf
$ ./lcl-rpict-config.py -w rpict3t1.conf

How to reset the board

Use a small jumper to link the reset pin with the ground. This can be found on the 3x2 6 pin ISP connector. Isp reset.png

Make contact with the two pins then remove the jumper. This will reset the board.