DC relay control¶
This page describes how to toggle DC relays in ASS enclosure. A similar procedure will be used to toggle DC relays in the APS, likely this will be incorporated into the same piece of code at a later date and will work in exactly the same way whether it's run on the ASS or APS computer.
Warning: There is functionality here to turn off the ASS and APS computers, or the ASS WAN. Make sure you don't do this unless you have a plan - you can't toggle any relays if you turn the computer or the internet. If you need to power cycle one of the computers, in the first instance you would do a remote software restart. The other computer (APS / ASS) should be available and connected to the network so that it can take over control, and can be used to toggle the relays in either the APS or ASS if neccessary.
Hardware set up¶
The control device used to toggle the relays in both the APS and ASS is an Avantech ADAM-6052 16-ch Source-Type Isolated Digital I/ O Module with 8 x digital input ports and 8 x digital output ports, with communication using modbus protocol.
Since the maximum load on each DO port is 1A per channel, we are using the digital outputs to toggle electromagnetic latching relays (by OMRON, part number MY2K-US24VDC). Each relay is wired with throw-back diode to prevent inductive kick-back. These relays are "dual-pol, dual-throw", so they need to be sent a pulsed "Set" command to switch in one direction, and a "Reset" command to be returned to the original position. In all cases the relay will remain in it's most recent position, so although all the relays were initally wired with the "Reset" position (devices on) as default, it is nesseccary to be able to keep track of the relays position. We're doing this using the Adam units digital input channels, which are wired to 'high' if the relay is in it's "Reset" position (device on) and 'low' if the relay is in it's "Set" position (device off). Note that the ASS DI's are wire as wet contacts and the APS ones are dry - this wasn't a particular design choice, it was just different people doing the wiring indepentendly and makes no differences from a high level perseective.
A descision was made to wire all devices in the same way (Reset = "On") to simplify things.
Because each relay needs a 'Set' and a 'Reset' channel, each relay needs two DO channels, so each 8 channel Adam unit can toggle four relays. The ASS contains two ADAM-6052 Units:
| Host name | IP address | MAC address |
|---|---|---|
| ass-adam-1 | 192.168.1.16 | 74-FE-48-AE-1E-E4 |
| ass-adam-2 | 192.168.1.17 | 74-FE-48-AE-1D-C0 |
They are wired in the follwing way:
| Adam device | Channel | Modbus address | Control |
|---|---|---|---|
| ass-adam-1 | DO0 | 16 | CR1000Xe set |
| ass-adam-1 | DO1 | 17 | CR1000Xe reset |
| ass-adam-1 | DO2 | 18 | OnLogic set |
| ass-adam-1 | DO3 | 19 | OnLogic reset |
| ass-adam-1 | DO4 | 20 | Met set |
| ass-adam-1 | DO5 | 21 | Met reset |
| ass-adam-1 | DO6 | 22 | Smartflux set |
| ass-adam-1 | DO7 | 23 | Smartflux reset |
| ass-adam-1 | DI1 | 1 | CR1000Xe status |
| ass-adam-1 | DI3 | 3 | OnLogic status |
| ass-adam-1 | DI5 | 5 | Met status |
| ass-adam-1 | DI7 | 7 | Smartflux status |
| ass-adam-2 | DO0 | 16 | GoPro set |
| ass-adam-2 | DO1 | 17 | GoPro reset |
| ass-adam-2 | DO2 | 18 | WxCam set |
| ass-adam-2 | DO3 | 19 | Wxcan reset |
| ass-adam-2 | DO4 | 20 | WAN set |
| ass-adam-2 | DO5 | 21 | WAN reset |
| ass-adam-2 | DO6 | 22 | -- |
| ass-adam-2 | DO7 | 23 | -- |
| ass-adam-2 | DI1 | 1 | GoPro status |
| ass-adam-2 | DI3 | 3 | WxCam status |
| ass-adam-2 | DI5 | 5 | WAN status |
| ass-adam-2 | DI7 | 7 | -- |
Software packages¶
The Adam units can be confirgured initially using the Windows Software Adam/Apax .NET Utility which is installed on the ASS windows VM. This required enableing Net Framework 2/3 on the windows machine. We shouldn't need to use this software for anything other than initial configuration and troubleshooting. The default password for the ADAM units is 00000000.
For modbus communication we're using the pymodbus package version 3.12.1
Software control¶
The python script to operate the relays is ~/scripts/adam/adamtoggle.py:
adamtoggle.py:¶
Function:¶
Uses Pymodbus to toggle a device wired into the ADAM-6052 either on or off, by first determining the status on the DI port, then checking 'set' (reset) is off, then pulsing 'reset' (set)
Usage:¶
Arguments: '-n', '--name', metavar='str', help='name of device' '-on', '--toggleon', action='count', help='toggle on named device' '-off', '--toggleoff', action='count', help='toggle off named device' '-s', '--status', action='count', help='query the status of the device on the port'
Current options for 'named devices' are: 'cr1000xe', 'ass-onlogic', 'met', 'smartflux', 'gopro', 'wxcam', 'wan'
Examples:¶
Get the current status of all devices:
adamtoggle.py -s
Turn the met station on:
adamtoggle.py -n 'met' -on
To / issues:¶
- What happens if you activate "Set" and "Reset" at the same time? The relay probably won't like this, but is it disasturous?
- Need to add in APS Adams