sicamxdf
Hi i have trouble when i try to generate the program  if i use block DIV o when compile when use / simbol in both cases the operands are dword / const

Thanks for your attention

openplc_error1.png 
openplc_error2.png
Reply 0 0
thiagoralves
The red line indicates an error on the block. For the arithmetic blocks (DIV, ADD, etc) all the variables on the input and on the output must be of the same type. You have a DWORD connected to IN1 and a "1000" constant that probably is interpreted by the compiler as INT connected to IN2. Also, your OUT is connected to another INT variable. To fix it, you can either change your DWORD variable to INT or change your INT variable to DWORD. Another option is to use a conversion block from DWORD to INT on the output and one from INT to DWORD on the input IN2
Reply 0 0
sicamxdf
Thanks for your great effort and fast response  i made the changes but the trouble is the same any idea? openplc_error3.png 
Reply 0 0
thiagoralves
Why did you declare your variables as "external"? Is this code inside a function or functionBlock? Some things you can try is to put the variables as internal and close the circuit for the DIV block on the ENO pin. You can also try your code on the earlier version of the editor (PLCopen Editor v1.04). I'm pretty sure DIV blocks work with that version.
Reply 0 0
sicamxdf
I use the variables as external since they come from another POU, I try with the variables as local and I try with the previous version thousand thanks for your support


Reply 0 0
skv
thiagoralves wrote:
You can also try your code on the earlier version of the editor (PLCopen Editor v1.04). I'm pretty sure DIV blocks work with that version.

Thiago, please, don't recommend to use old version of PLCopen Editor. It's unmaintained and contains tons of bugs.
Reply 0 0
skv
sicamxdf wrote:
I use the variables as external since they come from another POU, I try with the variables as local and I try with the previous version thousand thanks for your support

Don't use old version of PLCopenEditor!
If you find an error in PLCopen Editor and want it to be fixed, please report it to Beremiz (PLCopen Editor is part of Beremiz) mailing list at beremiz-devel@lists.sourceforge.net.

To your problem I can say, that this is not a bug. According to IEC65131-3 section 2.5.1.5.2 Numerical functions   function DIV is defined only for ANY_NUM operands, but BYTE, WORD, DWORD, LWORD are part of ANY_NBIT family. Therefore you've got an error. Use INT types or convert WORD to INT.
Reply 0 0
thiagoralves
Skv, thank you for your comments. About the DIV block, since it doesn't accept BYTE, DWORD, WORD, etc, per IEC standard, I think a good improvement for the next versions of PLCOpenEditor would be to have the line that connects to the block painted red (just as when you connect an invalid type) when the user use these types of variables.
Reply 0 0
Reply