Jump to content

Looking for J1939/numerical help


Recommended Posts

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

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

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

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.   Paste as plain text instead

  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...