thaitu09101
i have problem with analog input into arduino. I'm using lm35 to determine the temperature but what i saw is not like i expected. The value in openplcruntime was so unstable. I still don't know why and how to fix that. Can anyone has any ideal about that. I'm very appreciate that.
Quote 1 0
thiagoralves
What did you see? It is hard to help you without knowing what your wiring (circuit), program and values you’re reading look like.
Quote 0 0
thaitu09101
This is my circuit and code
As u can see, for example if the value of lm35 higher than 4000 ( which mean is 40 degree ) the light is turn on
else the light is turn off
but the value is unstable so it make the light is blinking
https://www.dropbox.com/s/4iyzw1idjvqrns1/2019-11-24_23-51-46.mp4?dl=0
u can see the video that i recorded in my laptop
So i don't know how to fixx that
btw, is it possible to scadaBr display the value which i can get by lm35 in screen?
thank you for taking your time to help me
thank you so much
Quote 0 0
thiagoralves
What made you think that 4000 means 40 degrees celsius? 4000 means 0.3V on the analog input of the Arduino (5 / 65535 * 4000). You need to use the LM35 datasheet to properly covert between the voltage value to temperature. A quick google search on LM35 brought me this: "The output voltage rises by 10mv for every 1 degree Celsius rise in temperature". If this is correct, then once you convert from OpenPLC reading (0 - 65535) to Volts (0 - 5) you need to multiply the voltage read by 100 to get the temperature in celsius.
Quote 0 0
thaitu09101
Okay i got it
and now i have another problem
It still work when i simulator in openplc editor but when i move on openplcruntim it show " Optimizing ST program...
Generating C files...
./st_files/67791.st:10-6..10-30: error: Bit size of data type is incompatible with bit size of location.
1 error(s) found. Bailing out!
Error generating C files
Compilation finished with errors!"
i think one of my location is wrong but i don't what i have to change to
Quote 0 0
thiagoralves
Locations %MD0.3.0, %MD0.3.2, etc don’t exist. You must use %MD0, %MD1, %MD2, etc with no dots. Also, a UINT is a 16-bit variable, and %MD is a 32-bit location. For UINT variables you should use %MW locations. Please refer to http://www.openplcproject.com/scada for variable locations and sizes
Quote 0 0
thaitu09101
thank you sir!
Quote 0 0