Jump to content

Recommended Posts

Posted
you have to be more specific... what plc and what number formats (in and out)? for example, plc is FX2N, input is something like "123.45" and output should be integer 12345 or maybe float 123.45
Posted
According to SH(NA)080039, section 7, Q plcs (except basic models) come with HEX, HEXP instructions as well. If you have to use such CPU you can make your own function to do this.
Posted
Try to use the instruction EVAL -> conversion from string to real (floating point). This function can be used on the basic models of the system Q CPU. Take a look at the programming manual for a detailed explanaition. Be aware to check the serial number on the PLC CPU (first 5 digits must be 04122 or later.
Posted
mmervenne, To convert the ASCII to numbers directly, you can simply subtract H30 from the D register values. If you receive the data in 16-bit form, you will need to split the word into the two bytes, then subtract the constant (H30). Then proceed by multiplying the split bytes with their base values. Receiving "123.45" Translated as H31 H32 H33 H2E H34 H35 (These values are typically stored in D registers when you received the data (D0 D1 D2 D3 D4 D5 for 8 bit comms; D0 D1 D2 for 16 bit comms). for 8 bit If you Sub D0 H30 D100 - (Do this to the rest) D100 will contain the value '1'. Result will be D0= '1', D1= '2' D2= '3', D3='-1', D4= '4', D5= '5'. Now, you can simplify it for yourself. I would try and not transmit the "." via the comms. Just receive "12345"- only if you know that the value will always contain two decimal places. Multiply D0 with K10000; D1 * K1000; D2 * K100; D4 * K10; D5 * K1. Add all these new values together and you will have the value recreated in the PLC. This might be the long way round, but it works....

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...