flylikechris Posted November 19, 2013 Report Posted November 19, 2013 (edited) Hi guys, do you know of a way I could accomplish a BMOV of a ZR register with an offset of 8 bits? I am not concerned with the first byte of the starting word. This is a problem I have come across quite a few times while working with Mitsubishi because everything seems to be word based. I have a barcode reader populating an array of words. The first 3 bytes are control characters, while the data I'm after is starting on the fourth byte. You can see where my problem is. The data to be compared is coming from a script in a GT16, which is a bit less flexible. This is why I prefer to accomplish the offset of 8 bits here in the PLC. I have tried ZR1000.8 , ZR1000.b8 with a BMOV but nothing will compile. I have also attempted using SFTB and SFTW, but neither will work properly. SFTB doesn't allow bits in word devices to be manipulated, while SFTW doesn't allow for a 1/2 word transfer. Any input is appreciated, thanks! Edited November 19, 2013 by flylikechris
flylikechris Posted November 19, 2013 Author Report Posted November 19, 2013 I could try seperately batch moving the upper and lower 8-bit data to separate buffer areas, and then repackage it afterwords, but that seems like a bit of a hack. The cleaner way would be some sort of FB or Function, if you guys know of one. I've been looking for a while, but haven't come across anything.. Thanks again-
Sergei Troizky Posted November 19, 2013 Report Posted November 19, 2013 (edited) BMOV the source area to buffer area starting from M(n)K4. Then BMOV from buffer area starting from M(n+8)K4 to the destination area. Of course, the buffer area must be of sufficient length, and not affected accidentally by anything else in the program. Edited November 19, 2013 by Sergei Troizky
Gambit Posted November 20, 2013 Report Posted November 20, 2013 Why don't you just swap the bytes and then filter the upper byte. SWAP ZR1000 WAND ZR1000 H00FF ZR1000
Mitsu Posted November 20, 2013 Report Posted November 20, 2013 (edited) In cases like this where you need byte access, WTOB and BTOW are very useful. In your case, you could dissamble the message into bytes (WTOB) and then reassemble the bytes into words again (BTOW). When re-assembling, you can decide to omit the bytes you don't need (in this case, the first byte). This solution is most useful if the data you need to process isn't too long or in general, if you need byte access in a word device. There are other solutions, like Sergei's method of moving to bit device memory and then moving again to word device. I don't think there is any real clean solution since you can't address bytes directly as offset in typcical move instructions like BMOV. It would be interesting to know if there are nicer solutions. Edited November 20, 2013 by Mitsu
flylikechris Posted November 21, 2013 Author Report Posted November 21, 2013 Thank you so much for the input! This is exactly what I am doing now. It seems unfortunate to be wasting so many upper bytes of these word registers, but it should work nicely! The good thing is the data I'm after is not too significantly large. Sergei: I really appreciate your input, this is not something that I am comfortable with right at this moment. I will be taking the PLC home tonight and experimenting with the method you've described. Hopefully I can learn something new from this. Many thanks guys-
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