muna
could you help me, please? 

I connect temp 36 analog sensor with ADC (MPC 3002), and led. with python code all work good. but when I want to connect it with openplc ... there is error in compiled 

./st_files/738768.st:3-6..3-31: error: Bit size of data type is incompatible with bit size of location.
./st_files/738768.st:4-6..4-23: error: Bit size of data type is incompatible with bit size of location.


I connect sensor on % IX0.2
and LED on %QW0

I changed them many time but the same error 
Quote 0 0
thiagoralves
%IX0.2 is a digital input, it won't accept an analog sensor. %IX inputs only accept digital (0 or 1) values, and therefore must be BOOL variables. That's why you're getting data type incompatibility errors. Unfortunately the Raspberry Pi board does not have any analog input, and OpenPLC does not natively support the MPC 3002 chip. What you can do is use an Arduino board connected to the USB port of you Raspberry Pi and then connect the sensor to one of the Arduino analog input pins.
Quote 1 0
muna
Right. so, could you suggest any link or documentation help in performing this, please? 
Quote 0 0
thiagoralves
http://www.openplcproject.com/getting-started-arduino
Quote 1 0
muna
thanks a lot 
Quote 0 0
muna
I connected raspberry pi with aurdino and everything work well, I wrote python code read sensor values from aurdino using serial communication in rasoberry pi. In openplc I connected everything and the program is compiled successfully. however, I think it doesn't work, I cant figure out if it works or not. the Led doesn't switch on, I changed the set point to the 8353 ( even I don't how much exactly in cellious.) and the function is greater than. I don't know what is the problem. the sensor take room temperature which is between (20-25). could you help me, please?

I connected temp36 without resistor in aurdino ( 5 V) , but led with 330 om resistor in raspberry pi  (5 V). 


I have just figured out this error 



OpenPLC Runtime starting...
Interactive Server: Listening on port 43628
Device slave_mega is disconnected. Attempting to reconnect...
Connected to MB device slave_mega
Modbus Read Discrete Input Registers failed on MB device slave_mega: Invalid data
Modbus Write Coils failed on MB device slave_mega: Invalid data
Modbus Read Input Registers failed on MB device slave_mega: Invalid data
Modbus Write Holding Registers failed on MB device slave_mega: Invalid data
Modbus Read Discrete Input Registers failed on MB device slave_mega: Invalid data
Modbus Write Coils failed on MB device slave_mega: Invalid data
Modbus Read Input Registers failed on MB device slave_mega: Invalid data
Modbus Write Holding Registers failed on MB device slave_mega: Invalid data
Modbus Read Discrete Input Registers failed on MB device slave_mega: Invalid data
Modbus Write Coils failed on MB device slave_mega: Invalid data
Modbus Read Input Registers failed on MB device slave_mega: Invalid data
Modbus Write Holding Registers failed on MB device slave_mega: Invalid data
Modbus Read Discrete Input Registers failed on MB device slave_mega: Connection timed out
Issued start_modbus() command to start on port: 502
Modbus Server: Listening on port 502
Modbus Server: waiting for new client...
Issued start_dnp3() command to start on port: 20000
DNP3 ID manager: Starting thread (0)
DNP3 ID DNP3_Server: Listening on: 0.0.0.0:20000
Modbus Write Coils failed on MB device slave_mega: Connection timed out
Modbus Read Input Registers failed on MB device slave_mega: Connection timed out
Modbus Write Holding Registers failed on MB device slave_mega: Connection timed out
Modbus Read Discrete Input Registers failed on MB device slave_mega: Connection timed out
Modbus Write Coils failed on MB device slave_mega: Connection timed out
Modbus Read Input Registers failed on MB device slave_mega: Connection timed out


what does this mean?
Quote 0 0
muna
I delete slave and create new one, further I complied the open plc mega again. after that, is the same error but with invalid CRC  and somtimes invalid data instead of connection time out
Quote 0 0
muna
I noticed when change the baud rate  (put it as 115200) in my python code without openPLC. it also stop to  receive data from aurdino. I think the problem is baud rate. can I change it in openplc code (define it as  directly 9600 then compiled it ) or not ?
Quote 0 0
muna
OpenPLC Runtime starting...
Interactive Server: Listening on port 43628
Device Slaveve is disconnected. Attempting to reconnect...
Connected to MB device Slaveve
Issued start_modbus() command to start on port: 502
Modbus Server: Listening on port 502
Modbus Server: waiting for new client...
Issued start_dnp3() command to start on port: 20000
DNP3 ID manager: Starting thread (0)
DNP3 ID DNP3_Server: Listening on: 0.0.0.0:20000


does this means it works? the Led dones't switch on . could you help me how can we define the setpoint in case of temp 36 analog sensor ? we can put the volte directly or we should change it 
Quote 0 0
thiagoralves
I don’t understand why you are using Python with this. All you need is the OpenPLC firmware for your arduino and OpenPLC server on your Pi. It should work with the default settings. 

A good way to test if you’re reading data correctly from arduino is by using Radzio Modbus. It allows you to connect to OpenPLC and read its registers. Look for data in Input Registers at address 100 to see all the analog values read by the arduino board
Quote 0 0
muna
I have not used python with PLC, I used python a lone to test aurdino with rasp. I dont know what is the problem as it sometime work and suddenly it stops. it gives connection timeout, or inavlid CRC..
Quote 0 0
thiagoralves
Are you communicating with the Arduino through the USB port or are you using direct serial cable?
Quote 0 0
thiagoralves
By serial cable I mean connecting Arduino and Pi's Rx/Tx pins together. If you're using USB you shouldn't be getting these errors. About the addressing, as stated on the website: "The table was built for OpenPLC v2, but it is still valid for OpenPLC v3, except that the slave address on v3 starts at position 100 (e.g. %IX100.0, %IX100.1, etc)". I don't know why you are getting these invalid message errors. One thing you can try is to reduce the Interval of your PLC program task. To do that, open your PLC program on PLCOpen Editor, and on the left side panel, go to Config0, and double-click Res0. Then check the interval for the "Tasks" listed. Increase it to something like 500ms or so, and then check if you're still getting these errors.
Quote 0 0
muna
Thanks a lot 
Quote 0 0