m4nu12
Hey I´m new in the Open PLC world. Together with a friend we want to rebuild an existing application with a Controllino Mega PLC. We need to meassure 7 temperatures to control a heating system. In the past this was done with a Siemens Modul "6ES7331-1KF02-0AB0" and 7 PT100 sensors. Because of the common problems with PT100 sensors and the associated "circuit effort" we want to switch to DS18B20 sensors. Is it possible to use 7/8 DS18B20 with the existing function blocks? In the editor I only found a block with 5 DS18B20:
[203128%2F8525933%2Fmceclip0]
 
Thank you for your answers!
Reply 0 0
thiagoralves
I haven’t tested it but I believe that if you use two blocks on different pins it might work
Reply 0 0
m4nu12
I have just tried it and it doesn't seem to work.
[203128%2F8531041%2Fmceclip0]
I don't get any errors when compiling, but when debugging remotely I get errors (see logs)
When connecting both sensors via one pin and using the DS18B20_2_OUT
it is working. But in this way I´m limited to use only up to 5 OneWire Sensors (with the DS18B20_5_OUT)
Start build in C:\Users\....\Projekte\Sandbox\build
Generating SoftPLC IEC-61131 ST/IL/SFC code...
    Collecting data types
    Collecting POUs
    Generate POU OneWire1
    Generate POU OneWire2
    Generate POU program0
    Generate Config(s)
Compiling IEC Program into C code...
Extracting Located Variables...
C code generated successfully.
PLC :
   [CC]  plc_main.c -> plc_main.o
   [CC]  plc_debugger.c -> plc_debugger.o
py_ext :
   [CC]  py_ext.c -> py_ext.o
PLC :
   [CC]  Config0.c -> Config0.o
   [CC]  Res0.c -> Res0.o
Linking :
   [CC]  plc_main.o plc_debugger.o py_ext.o Config0.o Res0.o -> Sandbox.dll
Successfully built.
PYRO connecting to URI : PYROLOC://127.0.0.1:61439
PLC did not provide identity and security infomation.
Latest build does not match with connected target.
This project does not match the program running on target. Upload the project to target and try again.
Couldn't stop PLC !


Reply 0 0
m4nu12
I have also noticed that it is difficult to configure the correct pin on the Controllino Mega, for example. Only I16, I17 and I18 (pins 38, 39, 40) are possible. A5-A15 cannot be set because the FB requires a SINT at the input. Therefore Ax cannot be set:
[203128%2F8531045%2Fmceclip0]
Reply 0 0
thiagoralves
You can use any pin you want. SINT is for the type of variable that holds the pin number. If you take a look at an Arduino Mega pinout diagram you will see that even the "Ax" pins have a number related to them.
 
The fact that the debugger didn't work most likely is related to the long time the DS18b20 block takes to run (as these temp sensors are pretty slow). Using two of them might be affecting the debug messages timing causing timeouts. Check if the program actually runs by placing the temperature reading in a %QW variable and then read that value through Modbus using Radzio Modbus or something similar.
Reply 0 0
m4nu12
Thank you for your fast reponses!
 
You are right that the Ax pins has numbers. But with the help of the Controllino Mega pinout I was not able to to find a working solution for the Ax pins:  https://www.controllino.com/wp-content/uploads/2023/05/CONTROLLINO_MEGA_Pinout_Table.pdf
As you can see there is that we need the blue pins e.g. for Input 16 it is Pin=38 or Input 17 it is Pin=39. But for the Ax Inputs there are still A1....Ax in the "blue field" the other Pin number in the grey field does not work. Perhaps I have made a misunderstanding here but anyway in my project Input 16, 17 nd 18 are not used so for the moment it works for me using these pins.
 
I have already set the cycle time to 1 second and more. That was necessary to get a value for one sensor at all. I was using Radzio but I was not able to see a value for the temperature there.
 
Based on the explanations in the documentation, I have now simply extended the existing DS18B20 blocks and added the following blocks.
[203128%2F8532562%2Fmceclip0]
I have already compiled the code and also simulated it beforehand and I did not get any errors. Unfortunately, I currently only have 2 physical sensors here, but these two are working without any problems.
[203128%2F8532563%2Fmceclip0]
 
How can I merge these changes into the official editor?
Maybe somebody else needs this.
Reply 0 0
thiagoralves
Thanks, that seems valuable, but I will ask you to hold it for now. I'm thinking about making some fundamental changes to the way DS18B20 works under the hood to support more sensors and have a faster response time. The way it works now, the block delays the scan cycle until a response is received from the sensor, which kinda sucks. Ideally it should just read the latest value from a buffer and return. No delays. No waiting.
Reply 0 0
CR
Has anything moved on this file since the January 2024 post? I'm struggling with the DS18B20_5_OUT function referencing pin 40 of a Controllino Mega. It sees the first of five sensors for a few seconds on boot then it is 0 across the board.    Pullup resistor 4700 ohm in place.
 
[203128%2F9367402%2Fmceclip0]
Reply 0 0
thiagoralves
Turns out I never made the changes I was planning to make. @m4nu12 if you still have your fixes, you could open a PR on GitHub to merge them.
Reply 0 0
CR
Thanks for your quick reply. You talked about the response time issue in an earlier post.  Is a suitable fix for the problem to put the DS18B20 block in a separate program with a long cycle time?
Reply 0 0
thiagoralves
Thanks for your quick reply. You talked about the response time issue in an earlier post.  Is a suitable fix for the problem to put the DS18B20 block in a separate program with a long cycle time?
Yes, that alleviate the problem significantly.
Reply 0 0
Reply