Ben Posted January 25, 2011 Report Share Posted January 25, 2011 Hi all I'm currently working through my first project using a Vision PLC, although I have worked with some other controllers. I was hoping I could get some help on an issue that has stumped me. The problem I am having relates to using a J1939 CAN to read values from a tilt sensor. I am able to read the 4-byte values from the sensor into 2 MIs, which is where the problem comes in. The PLC interprets both values (the least significant byte is the biggest problem for me) as signed/"2s complement" integers, when I want it to be an unsigned integer so I can combine the values inside the PLC. The only data types I seem to be able to put the J1939 values into are MI and XI, so I can't put them into a DW, which would solve the issue if it were possible. If I try to move the MI value into a DW, it stays as a negative number, i.e. with leading (hex) Fs. In the documentation for MI numbers, it says it can be used as a 16-bit signed or unsigned integer, however I can't see a way of making the PLC view it as an unsigned integer. Does anyone have any ideas about how i might solve the problem? Can these PLCs treat integers as unsigned? Can they convert 2 side-by-side MIs into a DW? Any help would be greatly appreciated. Thanks. Link to comment Share on other sites More sharing options...
Ofir Posted January 25, 2011 Report Share Posted January 25, 2011 Hi Ben, If you wish to convert the number in MI to DW then you need to use the function "Copy Memory". This function copies the bitmap of the number and you will get the right value as unsigned. You can find this function under Vectors menu --> Use Offset --> Copy memory Link to comment Share on other sites More sharing options...
Ben Posted January 26, 2011 Author Report Share Posted January 26, 2011 Hi Ben, If you wish to convert the number in MI to DW then you need to use the function "Copy Memory". This function copies the bitmap of the number and you will get the right value as unsigned. You can find this function under Vectors menu --> Use Offset --> Copy memory Excellent! Thankyou very much. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now