cody.moser
Hello i have a few questions about getting ScabaBR to interface with OpenPLC. I have a Raspberry Pi with an Arduino Uno slave device for remote I/O. I have ScadaBR downloaded and i am trying to add some new data points. Keeps saying there was a problem testing the locator.

Am i going to have to switch from modbus port 502 on Arduino? If so what do i switch it to.
What do i put for host, the IP address to get onto ScadaBR? (172.16.1.91)
By typing sudo ifconfig on the Raspberry Pi i found the IP address to be 172.16.1.88. So is the slave device just 88?
Thanks for the help.
Reply 0 0
Baxter666666
Hi Thiago,

I have been having difficulty over the past 2 weeks from trying to convert my PT1000 sensor input readings to a correct Degrees Celsius reading. I want to be able to show the Temperature of my System from my sensor on ScadaBR. For example: I know at room temperature (23 Degrees using a thermometer), my analogue value will be 6272 and I have been unable to show 23 Degrees on ScadaBR. Any information will be helpful. 

Thanks
Reply 0 0
thiagoralves
Reading PT100 or PT1000 sensors is not a trivial task. They have a logarithmic scale and you need to use a set of equations to get the temperature out of the measured value. This article ( https://learn.adafruit.com/thermistor/using-a-thermistor 😉 has some explanation about it. Just keep in mind that this article uses Arduino ADC readings, which is max out at 1023. For OpenPLC, the max ADC reading is actually 65535. So, you will have to use 65535 instead of 1023 on the equations.

Use the proper equations to convert 6272 to the correct temperature in Celsius in your PLC program. Then store this value on a holding register (%MW0 for example). If you want to keep the decimal value as well, you can store it on a double register (%MD0 for example). Once the calculated temperature is stored in a register, you can simple read the register from ScadaBR to get the correct value.
Reply 0 0
lc625

Hi Thiago, Hi Baxter6x6,
that goes along with my experience. At the beginning it seems a bit complicated to implement them into OpenPLC. On the other hand they are the industrial standard and provide excellent and reliable measurements. They have an almost linear temperature - resistance dependency. For my applications I use three different methods of reading values from PT's (or KTC's):
1) Using a simple voltage divider (https://en.wikipedia.org/wiki/Voltage_divider). I use a high precision resistor with 0,1% tolerance. You read the raw data from the analog pin according to Thiagos explanation. After that it is easy to calculate the actual resistance and than the temperature. Function blocks with the equitations are to find in the OSCAT Libs. Please refer to the function blocks section in this forum. Of course this is the most imprecise but cheapest way. 
2) There are small boards with a MAX 31865 chip available which are using the SPI Bus (https://www.adafruit.com/product/3328). You have to do some changes in the OpenPLC Arduino firmware. I posted a  firmware for Arduino UNO in this forum. The advantage is, that you can use PT100 and PT1000 as well and probes with 2,3 or 4 wires depending on your application. According to my experience the acuracy is pretty good.
3) You can use "resistance to voltage" converter like this: https://de.aliexpress.com/item/32867455650.html?spm=a2g0o.productlist.0.0.40fa654fWDkzcF. Usually designed for 3 wire probes. The biggest advantages are that they fit the head of industrial probes and that you "convert" the PT signal into a voltage or current near the probe.

Hope that helps a bit

Reply 0 0
Baxter666666
Thanks for the reply's Guys!

I will try to find the resistance value from my circuit through the use of the analogue value. I made my first attempt of trying to convert the analogue value from the article provided, only I will be trying to do it in Ladder Logic. From trying to calculate the resistance value I have encountered the following error. Any help would be great.
Resistance.png 

Thanks Guys!
Reply 0 0
thiagoralves
Input and Output classes only make sense inside Function or Function Blocks. Also, it would be more appropriate if you convert your raw PT1000_Value to REAL before making the calculations. If you make them as INT there will be huge error on the output and a big chance of it just being equal to zero.

Note: Just keep in mind that just changing PT1000_Value to REAL will give you a compilation error. You will actually have to create another variable of type REAL (like PT1000_real) and use the conversion blocks to convert PT1000_Value to PT1000_real

Note2: You should change your PT1000_Value type from INT to UINT to avoid getting wrong negative results.
Reply 0 0
Baxter666666
So, in the case of changing my PT1000_Value to REAL via a conversion block, does that mean that I will have to change ADC, Resistance (changing class from Output to Local) and Series_Resistor to REAL as well via conversion blocks?
Reply 0 0
thiagoralves
Since these variables are just used in your calculations, you don't have to convert them to REAL, just declare them as REAL and make sure you use numbers such as 65535.0 instead of 65535 to avoid compilation errors.
Reply 0 0
Baxter666666
Thanks Thiago for the help.

Its still giving me the same error message.

Resistance.png    
Reply 0 0
thiagoralves
Try renaming this variable to something else, like PT_RES. I’m under the impression that either “resistance” is being used somewhere else or it is a reserved word
Reply 0 0
Baxter666666
Thanks Thiago that resolved the issue. Moving on from converting the resistance value to Temperature now. 
Reply 0 0
Baxter666666
Thiago,

This is a question regarding ScadaBR.

Once I have my temperature value, (I'm having trouble converting my resistance value to Degree Celsius), my threshold point for my motor to operate will be 20 Degrees. However I am wondering, does ScadaBR give the user the option to change the threshold of the operating point (say to 30 Degrees) when the PLC is running? This would be to add additional functionality if possible.

Thanks
Reply 0 0
lc625
Hi Baxter6x6,
1) Your first question ("I'm having trouble converting my resistance value to Degree Celsius"): Go there: https://openplc.discussion.community/post/oscat-basic-333-oscat-building-openplc-10284818 download the ZIP-File. Unzip the file. Open OSCAT Basic 3.33-20 Sensors with OpenPLC. Search the block TEMP_PT (as long as you have a PT probe; use the adequate block if you use different probes). copy-paste the block into your program (and dependent blocks if necessary). RES = Your resistance of the probe; R0 = Resistance of the probe at 0°C. That's all and you have a precise Temp value.
Further on the ZIP file contains detailed descriptions of all provided blocks
2) Yes, I'm sure that you can change values via ScadaBR. The original (Brazilian) manual in German translation: https://openplc.discussion.community/post/scadabr-manual-in-german-10256420?highlight=scadabr+deutsch&pid=1309405176 (perhaps it helps).
Reply 0 0
lc625
Hi Baxter,
I realized this moment, that you sent me a personal notification 2 days ago. Anyway I think I answered your question by chance in the post above. And yes, the block covers both (or better say all) PT's. RES0 depending of the probe: PT100 = 100R; PT1000 = 1k. At 100°C PT100 = 139R; PT1000 = 1385R.
Reply 0 0
Baxter666666
Thanks for the help lc626. I'll give it a go! 
Reply 0 0
thiagoralves
About your ScadaBR question, this is more dependent on how you write your PLC program. If you declare your operating point as a variable, and locate this variable in a region accessible through Modbus (e.g. %MW0, or %MD0 depending on your variable type), then all you have to do is add this point in ScadaBR (%MW0 = holding register address 1024) and make sure you selected the "writable" checkbox. Then from your graphical display, after adding your point, if you hover the mouse over it you can modify its value. The change is written back to the PLC and your program proceeds with the logic changes.
Reply 0 0
Reply