Jump to content

Recommended Posts


I need to read  32bits number from servo register. In order to do that I use  FB "Read Holding Register" and  wherein I set ML type for "Master:Start of Vector" and "Vector length" is equal 4. That works

but I wonder if is there any other solution to read 32bits number or this way is ok?




Link to comment
Share on other sites

Alternative to this is using "Struct" function. This is how I see it, someone correct me if I'm wrong.

Vector length is number of 16 bit registers that is taken in memory, MI is 16 bits long. So length 4 means 4 MIs will be written into. In your case you write into ML which is 32 bits, so you are overwriting 2 consecutive MLs.

I guess that is happening, because when I do it I read all needed into MIs and use "Struct" function to pack read registers and form what I need. This way is maybe better in some cases because you have control over the data you read. ML register are signed, so if you read the number of pulses or whatever from your servo that is always positive you can overflow it and go into negatives for large numbers, in that case you need DW register as your destination ("Master:Start of Vector"). I use this method when reading floats from power meters, because you can't write directly into MF.

If your method works and gives you what you need than it is correct and you don't need to change anything and complicate things.

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.

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