luffy

Convert SINT to DINT

7 posts in this topic

Hi guys 

I am still learning my ways around Allen Bradley plc. So at the moment I am in need of a solution ASAP.

One of the PLC is currently sending values in SINT data type and on the other PLC I have to convert the SINT data type to DINT data type. The 1st plc is sending values in a SINT data type and the second one should read those values in a DINT data type. 

So I am currently struggling with the conversion of the two data type. I want to convert SINT to DINT. 

I would really appreciate your response. Thank you in advance 

Share this post


Link to post
Share on other sites

You can't convert in the message. One processor or the other needs to make another tag, matching the datatype in the other.  Then the message will work tag to tag.  The value can be converted in the one processor by simple assignment (ladder logic MOV instruction).

Share this post


Link to post
Share on other sites

@Sparky thank you for your response. If I may, can you please send an example of how the ladder logic should look like.

I do understand what you're saying, so I am trying to figure how will ladder logic look like. I would really appreciate it and I hope I'm not taking a lot of your time. 

Share this post


Link to post
Share on other sites

Dev tool not handy over the weekend, but the code is just one instruction "MOV someSINTtag someDINTtag".  Allen-Bradley processors automatically convert datatypes when moving or assigning into a different type.

Share this post


Link to post
Share on other sites

Alright, Thank you for the information. I will give a try tomorrow. 

I really appreciate it.

Share this post


Link to post
Share on other sites

Keep in mind when using mov, -1 sint value (all 8 bits = 1)  moved to dint would be all 32 bits = 1.

Share this post


Link to post
Share on other sites

Yes, Allen-Bradley integers (at least up to recent firmwares) are signed.  Moving to a larger register size performs sign extension.  This is all documented in the instruction set manual.  The simplest way to avoid that would be to use AND instead of MOV.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now