Move Bits Into Byte W/ Siemens

So If I create an FC that I send the "LENGTH" and the DB68.db0.0 which is where the array starts, I need to subtract 5 from the length then start at that point. If the length was 7 I would want to start at P#db68.DBX2.0 Byte 5 and then write it into DB69.dbx0.0 BYTE 5. Seems like an easy task just can't figure out how to edit the starting byte. According to the format I need to edit bits 0-2 of byte 3, all of byte 4, and 3-7 of byte 5. How is this edited do I just use simple math functions or "move" information into?

Sorry for all the questions, I'm pretty new to this.
 
Source code is much better than jpg - copy/paste into the post, the code can then be copy/pasted into Step7 and compiled and run as you wrote it with no typos introduced.
 
JOLTRON said:
......If the length was 7 I would want to start at P#db68.DBX2.0 Byte 5 and then write it into DB69.dbx0.0 BYTE 5. Seems like an easy task just can't figure out how to edit the starting byte......

From the above I assume you are trying to set up the parameters for SFC20 to block move the characters. Is that correct ?
 
If you want to contruct an Any pointer to pass on to SFC20, you have to declare an Any pointer in the temp area of the FC and populate the temp area with all of the Any pointer data programatically. Does this make sense ?

Edit:Added example code:

Code:
FUNCTION FC 2 : VOID
TITLE =
VERSION : 0.1
 
VAR_INPUT
iLength : INT ; 
END_VAR
VAR_TEMP
pSource : ANY ; 
iSFC20Return : INT ; 
END_VAR
BEGIN
NETWORK
TITLE =contruct the source any pointer
	 LAR1 P##pSource; 
	 L	 W#16#1002; //byte any pointer header
	 T	 W [AR1,P#0.0]; 
	 L	 5; //source number fo bytes = 5
	 T	 W [AR1,P#2.0]; 
	 OPN DB	68; //source DB number
	 L	 DBNO; 
	 T	 W [AR1,P#4.0]; 
	 L	 P#DBX 0.0; // pointer format for DBX0.0, the start of the array
	 L	 #iLength; 
	 +	 -5; // start byte of the last 5 bytes
	 SLD 3; // convert to pointer format
	 +D	; // add to DBX area pointer 
	 T	 D [AR1,P#6.0]; 
NETWORK
TITLE =copy chars to source
	 CALL "BLKMOV" (
		 SRCBLK				 := #pSource,
		 RET_VAL				 := #iSFC20Return,
		 DSTBLK				 := P#DB69.DBX0.0 BYTE 5);
END_FUNCTION

I have partially hard coded source and destination for simplicity. If you want to pass these into the FC, then more processing is required.
 
Last edited:
yes.

Note that transferring pointers to AR1 allows them to be shown as their area name instead of as dword number when monitoring


bytemon.JPG
 
Last edited:
Thank you very much L D[AR2,P#0.0]. The code works great. I'll have to study it a little bit and write it out a few times to fully understand what every line is doing. You've been a great help, thanks for you time.
 

Similar Topics

I am reading 32 bits from a DCS system into a DINT tag. I need to move this data into 4 INT tags. 1st 8 bits to one tag, next 8 bits to another...
Replies
3
Views
1,757
Hi I'm trying to move bits in to a word. I'm wanting to move %10.0 - %10.13 (Onboard Inputs) in to %MW1 I've tried moving one bit in to another...
Replies
1
Views
1,441
Hi I'm trying to move bits in to a word. I'm wanting to move %10.0 - %10.13 (Onboard Inputs) in to %MW1 I've tried moving one bit in to...
Replies
4
Views
3,399
Hey. I need some input on how to solve this task i am struggeling with. In the picture I attatched to this post, i tried to display what my task...
Replies
40
Views
16,458
I am using Unity Pro XL 4.1 Is there an easy way to move a Boolean value to every bit of an Integer? There is a function for moving a boolean to...
Replies
1
Views
5,814
Back
Top Bottom