makeju
Hi.
I have just started testing OpenPLC and Editor and have some questions about variable declarations.

for example if i use same I/O point in several programs do i have to declare it in every program i write or can i declare it globally so that i can just add it to my program.

second issue is memory bytes.
there is memory MWxx, MDxx and MLxx but not for byte/bit like %Mx.x.
for example if i want to control some bit from scada or hmi i have to use %QXx.x data point.

I have worked with siemens PLC.

hope that you understand what i ment....

T:Jukka
Reply 0 0
thiagoralves

You can declare a global variable on your Resource configuration (left panel -> Config0 -> Res0). Then you just click on the first add sign on the top and fill out with the information about your global variable (Name, Type and Location). Then, for each program that you want to use that variable, just add a variable with the same name and select External for the Class. Make sure that the type also matches your global variable otherwise you will get a type mismatch error during compilation.

Unfortunately there aren't any memory bits implemented in OpenPLC yet. I figured out we would need them after I had finished implementing the whole Modbus address space. So, for now, what users usually do is use disconnected I/O points as memory bits, i.e. %QX99.0, %QX99.1, ...

Reply 0 0
diegohap
How should be the ladder diagram to Read an ADC input ??
Reply 0 0
thiagoralves
I already answered your question about how to read ADC in here: https://openplc.discussion.community/post/adc-open-plc-with-arduino-nano-9299300?pid=1301807550

But if you want an example, here is a simple one
Capture.PNG

This block compares the value read from the LDR_sensor, and if it is less than 50000 (the maximum value for any ADC reading is always 65535), then it turns on the light.  
Reply 0 0
Reply