Zigbee - Connectports - All works
-
Hi Guys,
I have been experimenting with Connecting Arduino to SCADA systems vis Xbee for the past year and would like to pass on some info.
I have just finished installing and setting up MANGO, and have the following up and working:
Arduino with 6 Analog inputs, 6 Digital inputs, 4 Digital outputs and 2 Analog outputs.
Connected to a DFRobot IO Expansion shield V5 with a Digi Xbee Series 2 Radio.This communicates AS a slave with Modbus RTU, however, this is where it gets better...
I then use my Digi Connectport X4 Gateway's Industrial Automation(IA) capabilities to convert this to Modbus TCP.
The X4 has a built in Xbee S2 and Ethernet.
Then, the Mango data source simply points to the IP address of the X4 Gateway on port 502, Slave ID 1.
This means that I can can connect to this data from anywhere and not limited to a serial connection.And it gets better even still...
I can set up lots of these Arduino nodes. I just set a new slave ID in the Arduino code, say 2, set a new table entry in the X4
with a new port, say 503, then direct Mango to the X4 address, 503 and Slave 2.Analog sensors I have used include, LM35 temperature, light, voltage divider, Pots, sound, current.
I have a fan hooked up to one of the analog OUTPUTS via a MOSFET that I can set the speed from within Mango.
All this over a Digi Xbee Series 2 Mesh up to 3 kilometres (theory) away!The code Arduino code size is only 6.9K, and I can have as many registers as I want, limited by the speed of the Xbee mesh.
From my understanding, you could also use a Connectport X2, which has just the Xbee radio, and Ethernet, but has firmware
available for flashing that includes Modbus. (Check before purchase, as I do not have one)So lets look at the price:
Arduino/compatible $25 (DFRobot)
Xbee/expansion shield $20 (DFRobot)
Xbee Series 2 $45 (DFRobot)
Connectport X2 $139 (Sparkfun) (X4 $400+)
Mango $FreeSo once you have an X4/2 the node cost is only $90, plus sensors of course.
OK so what Arduino libraries you ask???
http://code.google.com/p/arduino-modbus-slave/
I AM having one problem that hopefully someone can help me with.
I cannot get the Digital outputs to stay on in Mango. After a couple of reads they go off. I have tried just about every setting,
but have come to the conclusion that it is the Arduino code. I also use ADAMView(advantech), and it also turns off the outputs,
but only when you stop the service, not WHILE IT IS RUNNING like Mango.Attached Arduino INO. Get the library from the above link.
Enjoy!
Attachment: download link
-
Sounds like a nice setup. Thanks for sharing.
Re the problem you have, is there a way that you can make something accessible via the internet so that i can experiment? PM me with deets if so. Perhaps what is needed is some kind of continual reminder to the point to stay on. Without a test bed i'd just be guessing as to what the problem could be.
-
Thanks for the reply.
I have outputs staying on now, after trying just about every setting in Mango and the gateway.
The system is operating without errors now, which I think is pretty good considering the low tech
Arduino hardware and basic Modbus RTU slave code.I can give you access (assuming you are from Infinite Automation), but I am running the free Mango version, and is working on only one client IP
address.I also use Advantech ADAM-6000 Modbus TCP modules with Mango and they are working flawlessly.
Mango is such a great package. I am starting a Environmental monitoring/automation business and after the testing I have done
so far with Mango, this is what I will be running with.Hayden
-
Ok, well, if it's working for you now, there's no need for me to have access. What are the settings that got it working though?
-
The main problem I had initially was timeouts, so I increased to 5 seconds, but probably could go to 10.
Also, I have the character timeout in the gateway set at 5 now, but this seems to be a grey area according to my
research. And then there is the Xbee radio paketization timeout, which I have set at 5 also, in the co-ordinator
and the end node radios, another grey area. Have not used a router in between at this stage, but may slow things
down a bit with more hops. The Arduino is sending data via its end node at only 9600! I think by adjusting the arduino
MODBUS slave library to accommodate a higher baud rate would really help.Definitions:
Packetization Timeout
The number of character times of inter-character delay required before transmission. If set to zero, characters are
transmitted as soon as they arrive instead of buffering them into one RF packet.Character Timeout
Specifies how long to wait for additional message data before discarding a partially received message.I am still learning a lot about Xbee, but it appears now to transport MODBUS very successfully, especially
seeing as it it getting translated from TCP to RTU and vica versa in the gateway. My test node is pulling
4 analog values and sending one digital output every 5 seconds, but is capable of 6AI, 2AO, 6DI and 4DO.
This is all the pins used up on a Arduino UNO. You could also change the combinations if you like.I would be happy to pass on any knowledge I have about this subject.
Below is the Mango Data source for the Arduino/Xbee node:
{ "xid":"DS_101326", "type":"MODBUS_IP", "alarmLevels":{ "DATA_SOURCE_EXCEPTION":"INFORMATION", "POINT_READ_EXCEPTION":"INFORMATION", "POINT_WRITE_EXCEPTION":"INFORMATION" }, "purgeType":"YEARS", "updatePeriodType":"SECONDS", "transportType":"TCP_KEEP_ALIVE", "encapsulated":false, "host":"10.1.1.12", "port":502, "contiguousBatches":false, "createSlaveMonitorPoints":false, "discardDataDelay":2500, "logIO":false, "maxReadBitCount":2000, "maxReadRegisterCount":125, "maxWriteRegisterCount":120, "multipleWritesOnly":false, "quantize":false, "retries":2, "timeout":5000, "updatePeriods":5, "enabled":true, "name":"Arduino1", "purgeOverride":true, "purgePeriod":1 },
Cabinet Temperature data point:
{ "loggingType":"INTERVAL", "intervalLoggingPeriodType":"MINUTES", "intervalLoggingType":"AVERAGE", "purgeType":"YEARS", "pointLocator":{ "range":"INPUT_REGISTER", "modbusDataType":"TWO_BYTE_INT_UNSIGNED", "writeType":"NOT_SETTABLE", "additive":0.0, "bit":0, "charset":"ASCII", "multiplier":0.488, "offset":3, "registerCount":0, "slaveId":1, "slaveMonitor":false }, "eventDetectors":[ { "xid":"PED_959001", "type":"HIGH_LIMIT", "alarmLevel":"CRITICAL", "limit":45.0, "durationType":"MINUTES", "duration":1, "alias":"" } ], "engineeringUnits":"Degrees celsius", "plotType":"STEP", "chartColour":"", "chartRenderer":{ "type":"IMAGE", "timePeriodType":"HOURS", "numberOfPeriods":8 }, "dataSourceXid":"DS_101326", "defaultCacheSize":1, "deviceName":"Arduino1", "discardExtremeValues":false, "discardHighLimit":45.0, "discardLowLimit":5.0, "enabled":true, "intervalLoggingPeriod":15, "name":"Cabinet Temperature", "purgeOverride":true, "purgePeriod":1, "textRenderer":{ "type":"ANALOG", "format":"0.00", "suffix":"°C in Pole Cabinet" }, "tolerance":0.25, "xid":"DP_144357" },
-
Just as an update on this post.
Although I would recommend setting packetization and character timeouts as above, this was not the underlying problem.
zzzz....zzzz....zzzz WAKE UP!!! Can't respond to MODBUS polls when it is asleep!
I thought the router or coordinator the bee was attached to would buffer the request and then send it on when it wakes,
but I could not get it to do this. even with short sleep/wake cycles under the poll timeout value.So I made sure all my nodes are running ROUTER firmware, so the do not go to sleep.
You could run end device firmware and set the sleep mode to "Pin Sleep" and then wire
the sleep pin permanently LOW, but using ROUTER firmware allows the radio to participate in the MESH. -
Thanks for posting your findings. Very interesting. Have you gotten a chance to experiment with Mango Automation yet? (newer version that has DGLux and modular architecture) You can have a map overlaid with your zigbee nodes and do some really cool stuff - hover over to bring up a drill down window, etc.
I'm interested in talking with you more about this project. I will message you.
Cheers,