krolikbest Posted March 27, 2020 Report Share Posted March 27, 2020 Hello, 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? Regards, Martin Quote Link to comment Share on other sites More sharing options...
Isakovic Posted March 28, 2020 Report Share Posted March 28, 2020 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. Quote Link to comment Share on other sites More sharing options...
krolikbest Posted March 30, 2020 Author Report Share Posted March 30, 2020 Thanks for the response. I dont't remember where but i'm pretty sure I saw already similar to your idea. So ok, will take into knowledbase Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.