Electronics > Beginners

Arduino-based SCADA guidelines

(1/7) > >>

Dannyx:
Good day everyone. I hope I'm posting in the right place, since this topic may very well fall into other categories as well, but I thought I'd go with the beginners section, because that's what I'd be called in this situation :D

Here's the deal: I'm trying to design (although "design" is a bit too ambitious at the moment) a system to monitor some remote stations which are out in a field somewhere. These stations are some very small sewage treatment gadgets which pass water through some filters with the help of air to essentially separate the solids from the water which is then sent on its way to a bigger plant of facility or whatever - doesn't matter. The operation of the stations themselves is also beyond the purpose of discussion at the moment, so why am I doing this ? These stations are completely "dumb", meaning there's no monitoring of anything at all: no sensors, no control panel or display, no PLC, nothing. Just an air pump plugged into a wall socket with an MCB ! That's it: it just pumps away constantly until either a worker comes by to shut it off or until the pump's diaphragms give in. My idea is to smarten these up a bit to both learn something new and valuable in the process (SCADA) and make life easier for the crew who has to periodically check on them. There's 12 of these all together in various locations around the county and they're spread over a very large area too, so that comes down to a lot of gas mileage...

At the very least, I intend to add to each box two temperature sensors as well as an airflow meter to the output of the pump. The temperature sensors would read both the temperature inside the box as well as of the outside air (for reference) and turn on a fan when the box gets too hot inside. The pump is a medium-sized pump (brand name "Secoh" if you want to search for pictures, for reference) inside this box which gets scorching hot in the summer when the sun is beaming down directly on it in the middle of nowhere ! The airflow meter would report when the pump has stopped for whatever reason. The possibilities are endless really.

How do we achieve all this ? Surely there's off the shelf solutions out there already doing this sort of SCADA, but I want it to be both DIY as well as budget friendly, so I thought an Arduino might be ideal.

Now here's why I said it may be too ambitious: I DO know my way around the Arduino to a degree. I have built some small projects with it and am familiar with the interfaces and some of the commands, so that is the easy-ish part. I don't know squat about programming though ! The HMI (the PC program the user looks at and sees all the values and controls) is what brings me to my knees in this whole deal: I have no idea where to start really. I need the Arduinos in each station to read some pins and report the values back to a DIY program on a remote computer....yikes :| We start off small, on the workbench of course. You can't expect it to work straight away without thorough testing...

That is what I DON'T know how to do. What I AM willing TO do is learn just that. Trouble is I'm not entirely sure WHAT I should learn...there's so many resources and possible versions of this project that I really don't know which way to look ! Most seem to revolve around around C#, something I've never worked with unfortunately. I don't think it's feasible for me to start learning C# from the absolute beginning hoping that I'd eventually gain enough knowledge to design something like this, so my idea is to find a pre-made program and adapt it to suit my needs....not sure. Like I said, VERY intimidating stuff. So many protocols too ! RS485, Modbus....man ! Makes your head spin, especially since there's no universally agreed on version ! Every time I think I'm about to stick to an idea someone demonstrates, ANOTHER one pops out and makes me think "hmm...yeah, this one's even better" and by the time I finish looking into that one, ANOTHER one comes up....

THIS one comes rather close to what I'm trying to do, but the HMI part is lacking, since it's made in that third party tool the guy shows, which although makes it easier, doesn't look like there's a way to expand it and make it "multi-client", though I haven't looked into it. Seems that "MUDBUS.H" is also a popular library to add to the Arduino to do this.


I'd like some pointers or ideas about how I should go about achieving this. I'd mean a lot to me. Thank you.

rstofer:
The only way to eat an elephant is one byte at a time.  Start somewhere and keep going until it is done.

I think MODBUS is as good as any and, specifically, MODBUS RTU using RS485 as the link layer.  You will have to find examples of this using Arduinos.  You obviously need a master node in the office (I would use a Raspberry Pi because it has networking and a disk) and then some number of Arduinos for the slaves.

If you wish, you can use the Arduino MODBUS Library with wired Ethernet or WiFi.

So, build up a couple of slaves and a master and get them talking to each other.  That's step 1.

Then build out the slaves in terms of sensors and the ability to report specific measurements in response to specific request.

It doesn't look like there is a TCP version of MODBUS for the Pi but I didn't look all that hard
https://www.instructables.com/id/How-to-Use-Modbus-With-Raspberry-Pi/

Here's an Instructable for the Arduino:
https://www.instructables.com/id/How-to-Use-Modbus-With-Arduino/

There's a lot of info on the Internet but the two Instuctables will probably get things talking.

For the Arduino:
https://www.arduino.cc/en/ArduinoModbus/ArduinoModbus

More for the Pi
https://jacekhryniewicz.wixsite.com/website/raspberry-pi-with-modbus-tcp

The nice thing about wired Ethernet is that the TCP protocol guarantees a clean packet but you need one network cable per gadget.  RS485 is just a pair of wires (and shield) strung between the devices.  WiFi has the advantage of being, well, wireless.  This helps prevent ground loop issues or differing ground potentials along the route.

The question with WiFi is whether it is close enough to the master or to some access point.

Lots of decisions to make...

Finally, teach the Pi what questions to ask of each slave and them decide what to do with the data.  Archive it in a file?  Present it on a web page?

This project is going to take a while!

rstofer:
If RS485 is practical, that's probably the way I would go.  It's simple, there is an add-on board for handling it and the Arduino library already exists.  I would string 3 or 4 Arduinos together with perhaps 1 meter of cable between them.  I guess I would stick them down to the bench so they didn't flop around.  You will be programming them individually so I would connect them all to a powered hub.  I would figure out which COM port each slave used so I would know which port to select in the Arduino IDE.  To program a different device all I would have to do is change the COM port.  Simple!

On the Pi, I would probably be using the command line for everything so a simple Telnet session should work fine.  PuTTY seems to work pretty well for me.  If you want to use gedit, you need to use the Pi console, Telnet won't handle it.

Here's something cool!  If you use a Raspberry Pi as the master, you can install the Arduino IDE and libraries and use the master to program all the slaves.  The whole project and all the development tools run on the Pi.  The new 4GB Raspberry Pi 4 makes a terrific development platform.  I use it as my preferred desktop when I am using Linux.  It's pretty darn fast!

https://www.amazon.com/gp/product/B07TXSQ47L

Scroll down a bit and pick up the entire package for $82

RoGeorge:
For the HMI side, could be:
- MyOpenLab (a very light alternative to LabView)
- Scilab/Xcos (a light alternative to Matlab + Simulink)
- Node-RED (a more recent platform)
- Python (runs on almost any OS and and on almost any machine including Raspberry Pi, has plenty of modules about anything one can imagine, probably the best option)

There are some other free open source platforms out there, some are intended for SCADA, some already have (or are built around) a Modbus server, etc. but last time I searched (some years ago) couldn't found any to remember.

Dannyx:
Thanks for the nice pointers. It really helps.

No, I don't think RS485 is possible in this case because from what I understand, RS485 is used to connect a master to a slave. In this case, it would connect the Arduino with the sensors on it to the Pi or whatever on the HMI side. Trouble is, if I understand it correctly, RS485 is a wired-type connection, requiring 3 wires at the very least. This obviously won't work in our applications because the stations are miles away from each other and from where the operator watching the HMI will sit, so wires won't work here - we have to go "cellular" (though this may be the wrong term for it).

It just so happens this company I work for also manages some other remote stations, in the form of shipping containers housing some industrial equipment which also talk to a head office to report various water parameters and the way they did it there was via a GSM modem with a SIM card in it which essentially connects the container to the internet. The head office probably has a VPN setup to these to access the different devices there as if they were part of the LAN so this is what I'm thinking of doing as well: hook up the Arduino to the internet via its Ethernet shield right at the box where the pump is and then VPN to that network to make the Arduino feel as if it were sitting next to my HMI (Pi, PC, other Arduino whatever the "base station" may be), so to simulate this, I first need to get the sensors and the TCP connection going on the bench and THEN worry about deploying it in the field as described...I have an Arduino Mega on hand, but don't have a shield for it. Guess it's Aliexpress time and....well...... I'm just going to go for it - the only way to do it is to just...do it :D

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod