newbie here.
I work in a factory that produce electric cables.
I'm trying to build a web application that will handle production processes. For this i need some real time data. There are multiple types of machines , some of them are older and uses a lot of digital counters like this on: https://mirror2.mixtronica.com/42248-superlarge_default/h7cx-aud1-n-contador-omron.jpg . Some of them are newer and have plc's ( siemens s7-1200 , s7-1500 and others ).
I have 0 experience with plc and plc programming. From what I saw from my research is that newer plc like s7 have a option "WEB SERVER", if that's enables i may be able to send data from counters and other stuff to a web page that is automated generated from that option. Folks on the internet uses software like Tia Portal to connect to them. My question is : if i try to connected at them with TIA-PORTAL and ethernet cable is there any possibility that i will corrupt something ? Tia-portal will recognize the program that's running (it was not uplouded by me ) ?
Is there any way that i can make that digital counters transmit data on a raspberry pi or similar device. If not , what are my options there , is there any product intergrated with iot that i can use ?
I also have some industrial scales but those have rs 232 interface and that was prrety smooth to make them talk with my pi.
From what I understand you want to read and send data to the machines, correct? Because there are some simpler approaches than having to build an IoT application from scratch.
Recently I've been studying solutions like this and the best alternative I've looked at is using Thingsboard (which can be installed locally or using the remote platform) or other platforms like Losant... This avoids creating a lot from scratch (storing data, create charts...), however, in a way, is limited in a few things and a gateway may be needed to handle the conversion of data from devices to platform. I'm still learning how to use it, but I think it's worth leaving it as a tip if your case is more about collecting and dislay data or creating simple actions or logic.
About connecting the devices:
For machines with PLC I recommend that you research OPC-UA or MQTT, they are protocols that will facilitate communication and it seems that these versions of the Siemens S7 have OPC-UA.
For machines without PLC and without any communication port you may be forced to install a "gateway", an Arduino, ESP32 or another Raspberry PI may facilitate things, or even a small PLC, to collect the discrete data and convert them to Modbus, MQTT, OPC-UA, or another way that you can send it to your server... The concern here would be with electromagnetic interference, but that will depend on your equipment (with industrial equipment validated as a PLC you won't have these problems).
This is not a complete answer, but I believe it will help you to develop the solution :)
Related
I have two python scripts which need to get data from the same modbus server.
However they cannot be simultaneously connected to the same modbus server, so I am looking for a "proxy" software.
This proxy will then sequentially transfer the modbus queries to the modbus server.
Solution should run on debian 11 lite.
Thanks!
I have the same challenges before and ended up with Modbus-to-MQTT bridge solution, because each protocol has its limit, Modbus is designed for master-slave poll in nature and MQTT is good for multiple clients/subscribers.
Modbus + MQTT, such a combination is just nice and could be very powerful in modern IoT applications. You can try modpoll, which is a python-based Modbus tool and can run as a Modbus-to-MQTT bridge in your case.
Assuming you are dealing with Modbus TCP you can try modbus-proxy:
Many modbus devices support only one or very few clients. This proxy
acts as a bridge between the client and the modbus device. It can be
seen as a layer 7 reverse proxy. This allows multiple clients to
communicate with the same modbus device.
When multiple clients are connected, cross messages are avoided by
serializing communication on a first come first served REQ/REP basis.
EDIT: According to your comment below:
...it is RTU over a linux file descriptor /dev/ttyS1
That seems to me a not-so-straightforward way of saying that you are dealing with a serial link.
If that's the case I'm afraid you need to go back all the way to the physical layer.
If you have a point-to-point serial connection (no matter the voltage levels you have, they can be TTL 3.3VDC or RS-232) there is no way you can have more than one Modbus client connecting to the same server.
For a serial link to have more than two devices (two or multiple clients sending queries to a Modbus server, for instance) you need a way for the devices to take control of the bus when they communicate and let go of it when they are idle. An RS-485 multipoint serial link is the most frequent solution to this problem.
If you follow the link you will find many resources and documentation. That might be a bit overwhelming but it is actually very easy: instead of connecting RX to TX as you'd do for a normal serial port you will have two cables for each device (they are called A and B or D+ and D-) that you can put together. And you only need to add a TTL to RS-485 transceiver in between each device and the bus (or RS-232 to RS-485, depending on your devices).
There are a couple of nuances:
You might need terminating resistors, but that should only be the case if your devices are far away (more than several meters) from each other.
If you go for the cheapest transceivers you might end up being forced to toggle the bus in your software, which is not a good solution. See my answer here for more details. And better aim for something with automatic TX enable.
The most complete reference on all these topics I know of is Jan Axelson's book Serial Port Complete. It's a bit old (the last edition was released in 2007) but still very relevant. And you can find older editions secondhand for next to nothing. If you need to work with serial ports, this book will be a very valuable companion.
Final note: if you are not able or willing to mess with the phy layer, you might, of course, find other solutions that are more palatable. You might, for instance, implement a software forwarder to take queries from your clients and convert them to Modbus RTU to be sent to your server. Pymodbus includes an example, but since you did not elaborate much I'm not sure it will be useful for your situation.
I'm on a team working on a non-profit, open-source project and we're creating a web-based configuration tool to control a piece of custom hardware on a Raspberry Pi, using the "Web Bluetooth API".
Packets over the BLE connection are limited to 512 bytes, so we seem to need a transfer protocol layer to assist communication with the Pi.
We do not want a UART implementation, as we want transmission guarantees.
Does such a transfer protocol layer exist, ideally implemented in Python?
Or is there a simple way to generate a python implementation of a transfer protocol layer, that would work with 512byte packages?
Your question is a little too broad to be able to give any kind of specifics.
The official profiles that are available with Bluetooth are documented at: https://www.bluetooth.com/specifications/specs/
Custom services can be created fairly easily if you have control over both ends of the Bluetooth link. The Nordic UART Service is one that appears to be quite common and there are various apps around that understand it to make testing of your peripheral easier.
Creating a custom service that minimises the amount of data sent over the Bluetooth link is usually the goal. There are various guides around that can help.
One of the better guides for creating a Bluetooth Peripheral with BlueZ and Python, is this one https://punchthrough.com/creating-a-ble-peripheral-with-bluez/
There are also Python examples in the BlueZ source tree
And for completeness the BlueZ API's are documented at: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc
I am trying to connect to an existing network of devices communicating via RS485 (HMI + PLC, the communication protocol is Fatek's own protocol). I have no problem connecting directly to the PLC (I can read and write registers), but I have to leave the HMI<>PLC connection. When connecting directly to the line between HMI and PLC (via an FTDI USB<>RS485 adapter) I can't read or write registers from the PLC (I don't receive proper responses).
From I've gathered, it's possible to connect multiple devices on one RS485 line, provided they have their addresses set. And here's the problem: I can't see where to set this address. Is it included in every "frame" sent? Is it set somewhere in the driver of the USB<>RS485 adapter? Is it hardcoded in the adapter?
Thank you in advance,
MichaĆ
Usually in serial communications, either 1:1 or 1:N, there can only be one master (in your case the HMI is the master) and one or more slaves that respond to requests from the master, and the master must always wait to receive the response before submitting a new request.
If you connect a second master you are creating collisions on the network, RS-485 has no way to manage those collisions.
Only one master can exist on the serial network.
If you want to overcome these limitations think about replacing that network with Ethernet and TCP/IP
As the Wikipedia article below, RS485 is an electrical specification with no default software or protocol.
The mechanism for handling the device address must be created by yourself or by selecting a protocol having such a function and applying it.
RS-485 - Wikipedia
RS-485 only specifies electrical characteristics of the generator and the receiver: the physical layer. It does not specify or recommend any communications protocol; Other standards define the protocols for communication over an RS-485 link. The foreword to the standard references The Telecommunications Systems Bulletin TSB-89 which contains application guidelines, including data signaling rate vs. cable length, stub length, and configurations.
For example, isn't Modbus often used?
Modbus -Wikipedia
Modbus is a data communications protocol originally published by Modicon (now Schneider Electric) in 1979 for use with its programmable logic controllers (PLCs). Modbus has become a de facto standard communication protocol and is now a commonly available means of connecting industrial electronic devices. Modbus is popular in industrial environments because it is openly published and royalty-free.
There are also some python packages.
minimalmodbus 1.0.2
pymodbus 2.3.0
How to set the device address will need to be done according to the specifications of the package to be adopted.
In Addition:
By the way, if you are using a manufacturer's proprietary protocol for a PLC device, it is likely that you will be using such multi-drop for that device and protocol.
It seems that the first way to do this is to contact the manufacturer's support desk.
Or even if this site is a manufacturer support location, you will need to add information such as what equipment you are trying to connect and in what configuration.
HMI_Support & PLC_Support
HMI_Products & PLC_Products
It looks like your system is using "Fatek communication protocol" which is documented in Appendix 1 of the FB user manual. (Download here)
That protocol looks like many such protocols typical of industrial PLC controllers. However, it is a bit complicated by the number of message types. Without looking too deeply, it seems practical to implement the logic in a few days. Or there is likely an open source implementation somewhere (though I didn't search).
I'm currently making a small hobby project where I use a Raspberry Pi Zero to control a set of RGB LED's.
I've got a basic python app so far that is built on Flask that allows me to set up a web server so that the LED colours can be set remotely.
My main concern is that I'm self-taught as far as programming goes and I don't know squat about security.
The plan is essentially to be sending any port 80 traffic to the raspberry pi on my home network and give friends my IP. I may eventually get a domain name to simplify things.
Should I have any security concerns when I set this up live full-time? I don't know if it's possible to access my private network via the raspberry pi or if I'm just being paranoid.
You can try putting your Raspberry PI on separate vlan and put your home devices on another vlan. Please note you need a router which supports vlan and configure it in a way that the both vlans cant talk to each other
Also, try using HTTPS for your webserver and don't run the webserver process as root user. If you want to go more crazy you can put a firewall.
These are generic suggestions for hardening the security for any web app.
If your experimenting and learning... might be a great opportunity to try out something called wire-guard, if you don't have the network equipment to support vlans.
https://engineerworkshop.com/blog/how-to-set-up-wireguard-on-a-raspberry-pi/
You and your friends can directly connect to the pi, add some appropriate iptables firewall, and you can restrict them just to that machine.
If you want learn more about secure coding, there are tons of resources. Maybe even get you and your friends 'to capture the pi' .... and learn from each other!
What ever you do , keeping hacking away, and keep having fun....
Is there a way I can hack somehow an xbox controller to send custom signal or clone the protocol with a usb dongle.
Basically a way I can use my pc as a controller for xbox console.
I am trying to develop an AI that plays FIFA and all the processing is made on PC. I can't find how to send the signal, corresponding to the action the AI has decided to make, to the xbox console.
Thank you in advance
No, xbox controller wireless protocol is proprietary and nobody reverse-engineered it yet AFAIK.
To use a real xbox wireless controller on a PC (the opposite of what you want) you need an adapter, which is sold separately, and most USB XBOX code we have published is dedicated to make those adapters work on linux. The actual protocol of wireless communication between the adapter and the controller is a mystery. It is not normal wifi so you can't use any wifi adapter available in the market to mimic it.
Another option is to crack open an xbox controller and connect the components (using arduino maybe?) directly to the PC.
There's a work around solution to your problem. The Xbox app for Windows allows you to play games via streaming over a local network. The quality is imperfect, but if you have access to the console's actual video output you can set the stream quality to the lowest setting to minimize latency.
Streaming via the Xbox app for Windows will allow you to emulate a controller via any of a number of methods that convert various signals to X-input. I personally have tested this with a Dual Shock 4 controller and InputMapper. For your purposes, you may want to try EventGhost.
People shouldn't just throw shade automatically because you're designing a bot. There are plenty of respectable reasons for doing so, particularly academic ones. I hope you're not just trying to cheat, but if you are, it's an impressive way of going about it, at least.