Arduino/C++, Python, & LabVIEW interfaces for controlling ADAM industrial Controllers using Ethernet/TCP/ModBus
NOTE: This will be simplified when I have time to reflect JUST the Arduino library & example adamController-example
- Electronics:
- Arduino Mega 2560 development board
- Arduino Ethernet Shield 2
- 2x ADAM 6052 Advantech Data Aquisition Module (DIO)
- 2x ADAM 6271 Advantech Data Aquisition Module (AI)
- Network Switch
- 3x DPDT Relays, 24v coil, 240VAC Switching
- SBC (Single Board Computer) Raspberry Pi/Odroid or similar
- For detailed wiring diagram see ******
- Arduino Ethernet sheild can now be mated to Arduino Mega 2560 development board
- Connect Arduino Mega 2560 to SBC using USB cable
- Connect Arduino Ethernet Shield to Network Switch using Ethernet Cables
- Connect 4x ADAM modules to Network Switch using Ethernet Cables
The experimental hardware can now be controlled using JSON formatted commands sent over Serial USB or UART connection to the Arduino.
- Arduino will report system status including all sensor data every 1000mS in JSON format
To setup experiment for basic operation, use the following commands:
list of suitable commands (Examples, not exhaustive)
{"valve":1, "state":0}
{"valve":2, "state":0}
{"valve":3, "state":0}
{"valve":4, "state":0}
{"valve":5, "state":0}
{"valve":6, "state":0}
{"valve":7, "state":0}
{"valve":1, "state":1}
{"valve":2, "state":1}
{"valve":3, "state":1}
{"valve":4, "state":1}
{"valve":5, "state":1}
{"valve":6, "state":1}
{"valve":7, "state":1}
{"fans":0}
{"fans":1}
{"comp":0}
{"comp":1}
{"mode":"stop"}
{"cmd":"fans","param":0}
Python3
External modules used:
pyModbusTCP
numpy
I believe this was all that was nessissary to install to run the software on RPi Ubuntu
- Ensure that
testCommandServer.py
HOST variable is set to loopback address127.0.0.1
OR address of server host. - Ensure that
testReportingServer.py
HOST variable is set to loopback address127.0.0.1
OR address of server host. - Ensure that
commandClient.py
HOST variable is set to same address as server - Ensure that
reportingClient.py
HOST variable is set to same address as server - If testing without hardware, ensure that
simulate_hardware = True
set inacUnitGlobals.py
- Run
testCommandServer.py
andtestReportingServer.py
on host server - Run
main.py
on client server (raspberrypi/SBC in final implementation) It should connect to server with no issues
- Enter commands as prompted in
testCommandServer.py
CLI. Track changes in state and function using CLI formain.py
. view logfile during operation for debug messages, based on logging level set ininit_logging
inacUnitGlobals
- Ensure that JSON messages reported by
testReportingServer.py
display "correct" values (if simulated hardware these values somewhat random and static at the moment
- NOTE: 1st command sent from
testCommandServer.py
causes websocket to loose connection & reset. All commands after this should be handled normally.
{"cmd":"set","{item}":"{state}"}
{"cmd":"set","V1":"open"}
{"cmd":"set","V2":"open"}
{"cmd":"set","V3":"open"}
{"cmd":"set","V4":"open"}
{"cmd":"set","V5":"open"}
{"cmd":"set","V6":"open"}
{"cmd":"set","V7":"open"}
{"cmd":"set","V1":"close"}
{"cmd":"set","V2":"close"}
{"cmd":"set","V3":"close"}
{"cmd":"set","V4":"close"}
{"cmd":"set","V5":"close"}
{"cmd":"set","V6":"close"}
{"cmd":"set","V7":"close"}
{"cmd":"set","W1":"on"}
{"cmd":"set","W1":"off"}
{"cmd":"set","W2":"on"}
{"cmd":"set","W2":"off"}
{"cmd":"set","fans":"on"}
{"cmd":"set","fans":"off"}
{"cmd":"set","comp":"start"}
{"cmd":"set","comp":"stop"}
All the following words evaluate to True:
"open","opened","on","true","high","start"
All the following words evaluate to False:
"close","shut","closed","off","false","low","stop"