ngu
I  installed OpenPLC runtime in a Linux system, then attached an Arduino Uno R3 board as a slave device. On the Arduino board, I plugged a DS18B20 sensor module to let it monitor the temperature, once it exceeds 30 degree, the led will be on. However, the PLC program can't be compiled in OpenPLC runtime although it works in OpenPLC editor. Can anyone give some clues how to resolve it? Thanks in advance.
 
OpenPLC runtime error:
[203128%2F8267112%2Fblobid1]
The st code uploaded to OpenPLC runtime:
PROGRAM program0
VAR
Sensor AT %IX100.0 : SINT := 2;
led1 AT %QX100.0 : BOOL;
END_VAR
VAR
DS18B200 : DS18B20;
_TMP_GT14_OUT : BOOL;
END_VAR
DS18B200(PIN := Sensor);
_TMP_GT14_OUT := GT(DS18B200.OUT, 30.0);
led1 := _TMP_GT14_OUT;
END_PROGRAM

CONFIGURATION Config0
RESOURCE Res0 ON PLC
TASK task0(INTERVAL := T#20ms,PRIORITY := 0);
PROGRAM instance0 WITH task0 : program0;
END_RESOURCE
END_CONFIGURATION
 
OpenPLC editor works normally:
[203128%2F8267111%2Fblobid0]
Reply 0 0
thiagoralves
The DS18B20 blocks are supposed to be used on the microcontroller only. The Linux runtime won’t compile that
Reply 0 0
ngu
Hi Thiago,
 
Thanks.
If don't use DS18B20 blocks, is there any other way the DS18B20 temperature sensors or other sensors(such as the DHT11 one) can be used in Linux runtime?
Reply 0 0
thiagoralves
No, but since you're using an Arduino as slave, you can use these blocks on the arduino board and expose the readings on modbus located variables (for example %QW0, %QW1, etc). Then the Linux runtime can read those locations using the arduino as slave.
Reply 0 0
ngu
Hi Thiago,
 
I should have already used the block DS18B20 on the arduino slave as  the variable IX100.0 in line 3 showed, however, the function was not recognized when it's defined/called in lines 7/11, maybe it should be used in other ways. Could you help to have a double check where I can improve? Thanks a lot. 
 
1 PROGRAM program0
2 VAR
3 Sensor AT %IX100.0 : SINT := 2;
4 led1 AT %QX100.0 : BOOL;
5 END_VAR
6 VAR
7 DS18B200 : DS18B20;
8 _TMP_GT14_OUT : BOOL;
9 END_VAR
10
11 DS18B200(PIN := Sensor);
12 _TMP_GT14_OUT := GT(DS18B200.OUT, 30.0);
13 led1 := _TMP_GT14_OUT;
14 END_PROGRAM
15
16
17 CONFIGURATION Config0
18
19 RESOURCE Res0 ON PLC
20 TASK task0(INTERVAL := T#20ms,PRIORITY := 0);
21 PROGRAM instance0 WITH task0 : program0;
22 END_RESOURCE
23 END_CONFIGURATION
~
Reply 0 0
thiagoralves
You should use this block in the slave program, not in the master’s.
 
1. Create a program for the Arduino slave with the ds18b20 block
2. save the reading on %QW0
3. Set up a generic slave device on your master (don’t use the arduino template) with just one holding register read
4. your arduino ds18b20 reading will be available on your master at %IX100
Reply 0 0
ngu
Hi Thiago,
 
After burning the program with ds18b20 block and %QW0 as the output variable into the Arduino board in OpenPLC Editor, then adding the Arduino board as a generic slave device with only one holding register while without input registers on the Linux OpenPLC runtime, it works by reading %IW100. Thanks a lot for the help.
Reply 0 0
Reply