Writing OpenPLC drivers using PSM - DS18B20 on Raspberry Pi
HTML-код
- Опубликовано: 17 сен 2024
- How can you read temperature on a Raspberry Pi with no analog inputs? Today you will learn how to use OpenPLC's Python SubModule (PSM) to easily write hardware drivers to interface unsupported sensors with OpenPLC. On this video you will see a step-by-step example application adding support for the DS18B20 digital temperature sensor on a Raspberry Pi. Other sensors and hardware peripherals can be added using the same principles with PSM.
Enabling 1-Wire on the Pi 03:22
Wiring 04:15
Testing on terminal 05:25
Testing on Python 08:15
Enable PSM driver 10:52
Writing PSM code 12:40
Creating test project 19:12
Testing 22:45
Thanks Thiago!
After finally escaping from a two-year long sidetrack into cybersecurity, I used this tutorial to get the PSM OpenPLC runtime peer-to-peer started.
Now, an OpenPLC runtime instance can connect to other OpenPLC runtime "peers", read their coils, discretes, input and holding registers, and update the variables within the "client" instance of an OpenPLC runtime!
The primitive code I have entered into the PSM can connect to multiple peers (my "heaviest" OpenPLC runtime client connects to 13 peers), and reads of discrete inputs and coils are successful, but that's only for a single PLC so far.
The PSM "peer-to-peer" code is still too rough to release, but as soon as I get connection monitoring, read cycle throttling, and exception handling fleshed out a little better, I'll post it in the OpenPLC "projects" forum.
I am so proud of you Thiago! You are superb! I always metion you as my best intern ever!
Thank you Djim! It was a pleasure working with you guys way back then
On Windows 10, the editor does not start. If there are non-English folder names in the folder path.
Make the choice of install rather than default no choice.
I’ll work at fixing this bug
Hi Thiago, congratulations for your work!!
What a great project !!!
How to use socket CAN with openplc on raspberry pi ???
OpenPLC does not support CAN bus yet.
sir tell us please how can we get pulse output in openplc for running stepper or servo motor
thanks
Stepper and servo motors require a more precise timing, and that can be tricky to achieve with just ladder logic. You can use PWM capable outputs (for the boards that have them) with OpenPLC. OpenPLC treats them as 16-bit analog outputs, where the PWM duty-cycle is directly proportional to the analog value you place on them (0 to 65535)
Very well explained! At the moment the problem is to have one raspberry 3 at hand.... It works on raspberry 4? I think yes because it seem OpenPlc runtime was written in python....
OpenPLC works with any Raspberry Pi, from the very first model to Pi 4
Hi and thanks for all the great video tutorials they are very useful. Can I ask if there is a way to view the status of registers/ memory allocations in Open PLC ?
If you’re using the Linux/Windows runtime then you can simply click on Monitoring to see the current status of all located variables. For the micro runtime (runtime running on microcontrollers) you will have to use a Modbus tool like Radzio Modbus to read the registers
@@openplc Very Much Appreciated 👍
Hello very good job , it's possible give me some program to test openplc on raspberry and esp 32,thanks !
You can find examples on the OpenPLC Project website in the Documentation section
Hi, I am using arduino nano clones which have the CH340G usb chipset and seems like openPLC doesn't upload the code I don't get any blink on pin13 the upload window does say that the upload is done but when uploading the pin13 the inbuilt led blinks for a few milli seconds and the rx tx leds don't light up and yes I have selected the correct pin %QX0.3 for nano and the correct com port too seems like the program only resets the arduino nano when uploading doesn't actually upload the program. This is only problem for the clone nano's I have tried it on Uno (original), Arduino Micro, and esp32 all of them works but not the clone which uses CH340g can you please add support for the ch340g too.
Most likely you will have to update the Arduino bootloader on your clone board
Hi
Thanks alot for this greet project and thank you for making it open source.
I want to use an ESP32 with open plc but it seems like open plc can't interact with it is there anyway i can connect it?
Thanks in advance
Just select "ESP32" from the upload window as your target board and you will be good to go.
Hello sir your videos are great..can you please give tutorial to connect LCD to ARDUINO by plc programming to display counter value.
Friends, I am also interested in lcd readouts. With scadaBR a $67 chrome book could replace all push buttons and lcd screen? Which is a good price point, if your machine can physically support it
OpenPLC Runtime does not support connecting to an LCD directly like that. You will need a proper SCADA solution like ScadaBR or FUXA
Sir I want to download OPENPLC editor but I am unable to download and install it because after installation it opens as s pycarm project
please make a video on how to download and install it
please
and best of luck
That's one of the first videos I made: ruclips.net/video/QcP2dZATJ8Q/видео.html
Friends,
Am I wrong that python brings us away from ladder logic which I like? Can you still program with ladder logic? Is this just a work around for miss compatible hardware?
Not exactly. PSM was not intended to be used as a logic programming tool. The logic must still be written in PLC languages. PSM should only be used to write the code for the hardware interface (I/Os)
is there any demo shows OPEN PLC works with servr motor ? EtherCAT servo motor.
The platform is wery well written. The only big problem for me is the installation in my school where we don't have the access as root. I managed to start The editor struggling with windows but for the run time i have a very big problem. Do you have some workarounds to solve the problem? Thanks
The editor is a portable application. You can copy OpenPLC_Editor folder from one computer to another and it will run. No need for admin access and no need to go through full installation process. For the Runtime, running without admin is tricky. The Runtime on Windows relies on Cygwin. So if you can manage to install a portable version of Cygwin, you should then be able to install OpenPLC Runtime following the manual installation procedure
I'm thinking in alternative to install a Linux machine configured in a virtual box. But at the moment i'm not so sure It Will work...
@@boardsdiscovery5803 You can definitely use a VirtualBox VM with OpenPLC Runtime. I would recommend keeping the Editor on Windows as it requires a GUI to run. I did exactly that when I built the SCADA Security Lab at UAH. A clean Debian VM with no desktop environment works best as it is super lightweight. OpenPLC Runtime doesn't need any GUI to run. The good thing about this approach is that you can replicate the VM multiple times to have a virtual environment with multiple PLCs. Each VM with OpenPLC Runtime installed behaves as an individual PLC.
@@openplc is a server! :) I had not tought about that! Great guy! Thanks!
Thanks for the great video!
What if I want to use more than one DS18B20 sensor?
Use the block with 2 or more outputs
Hello Thiago!
Will there be a continuation of such useful work???
I might add a couple more videos soon :)
How to connect a temperature sensor to the Arduino
You can use one of the DS18B20 blocks for that
Hello Thiago!
How are You? Congrats for Your work!!
We are an electronics industry in Brazil and would like to discuss a project with you. How can we get in touch?
`sudo pip3` breaks my heart
Which company making open plc products
Automation Direct P1AM, Controllino and Arduino (Opta) are a few examples. There are other non-official ones added by the community as well