Sign in to follow this  
Followers 0
Van

2Qs: Adressing and Moving a BYTE of data

8 posts in this topic

Question 1: How do you address just one-half (i.e. one byte) of a word? For example, D100 addresses an entire WORD (i.e. 16 bits or two bytes). What if I wanted to access just ONE-HALF of that address? I know I can address it in BIT form (i.e. D100.0, D100.1, etc). Can you do it in byte form? Question 2: How does one move/copy/distribute just one BYTE from one address to another? The MOV command moves a WORD (i.e. two-bytes). I want to move just one-half of a word (i.e. one byte). Here is what I am trying to do: I want to create a contiguous memory space of data that will be composed of data from other non-contiguous memory locations. For example, lets say my contiguous memory space is D1000-D1007 (i.e. 8 words, 16 bytes). I want to assign the first byte at address D50 to the first byte at address D1000 and the second byte at address D59 to the second byte at address D1000: D1000 = (D50.0-7) + D59.(8-15) How does one accomplish this?

Share this post


Link to post
Share on other sites
1. Depends on what you want to do. 2. u didn;t think outside the box... heres 3 ways of the top of my head... XFRB MOVD or a simple / (divide) can achieve what u want...

Share this post


Link to post
Share on other sites
1. As SW states - it depends what you need to do. As a starter D100 ANDW #00FF leaves you with the lower byte D100 ANDW #FF00 leaves you with the upper 2. I'd use a FOR/END_FOR loop in ST and enclose something like this: Result:=(SomeWord AND #FF00); 'Access high byte Result:=Result OR (SomeOtherWord AND #00FF); 'Access lower byte and 'OR' into result If you need to swap a byte position, you can: Result:=(SomeWord AND #FF00)/256; 'Access high byte and shift 8 bits 'down' Pp

Share this post


Link to post
Share on other sites
How do you "know"?? One of my very few gripes with the Omron PLC is that you CANNOT directly address D memory at the bit level. See link: - http://forums.mrplc.com/index.php?showtopic=13788&hl=

Share this post


Link to post
Share on other sites
Forgive my ignorance. I"m not a seasoned PLC programmer. I was just using the schema as an example. However, that link was sure helpful, thank you.

Share this post


Link to post
Share on other sites
.For the newer models such as CJ/CP1/CS1 use the following instructions.... SETA SETB RSTA RSTB OUTB TST TSTN

Share this post


Link to post
Share on other sites
BTW, for those who find this thread later, I found that MOVD(083) worked perfectly for me. A digit is four bits therefore you would issue a MOVD command to move two digits (i.e. one byte). Edited by Van

Share this post


Link to post
Share on other sites

I know this is an old thread, but I just found this and Van's last post helped me quickly do exactly what I was needing.  I needed to take the result of a math problem and stick it in both the top and bottom bytes of an Output word.  Figured I'd post the two ladder operations for future reference:

MOVD Math_Result #0220 Output

MOVD Math_Result #0020 Output

 

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0