DWORD tag value dividing error
I'm encountering an issue with division in my PLC program. I need to divide the data from a DWORD tag, which is assigned to an encoder module, by a constant value. The encoder module only allows the assignment of DWORD tags, so I'm receiving pulse data in this DWORD tag. However, when I try to use the division block, it doesn't show the PLC variable that I have assigned for the pulse data. Could you guide me on how to divide a DWORD tag by a constant value? DIV block not allow me to assign any DWORD tag , it allows DINT but, DWORD 7 digit value is not converting to DINT.
Comments
DWORD can indeed be converted to a DINT as both are 32bit values.
The DIV function only takes "any_num" as inputs.
On the DIV-input you can try this: TO_DINT(myDWORD), and your constant at the other input
Have you tried something like this?
SFW
Hello Steve,
Hello Fluxmodel,
I truly appreciate your support, thank you very much.
Initially, when I tried to convert a DWORD to a DINT, the output value was incorrect and appeared with a negative sign. However, after restarting the software and reading your comment that both DWORD and DINT are 32-bit, I tried the conversion again, and it’s now working correctly. I simply converted the DWORD to a DINT and assigned the DINT to the DIV block. Thanks again for your assistance.
Regards,
Ali
FYI a negative sign for a DINT is not incorrect... it ranges from
-2,147,483,648 to 2,147,483,647