Substitute of peek and pock for s7-300?

andreGO

Member
Join Date
Nov 2013
Location
Porto
Posts
2
Hello guys. So the problem is this. Basically I want to pass a variable number of bits from one byte to another. For example to pass the first 3 bits of mw0 to the last 3 bits of mw4 but in a dynamic form.

In the siemens s7-1200 I was using peek and pock

Code:
  #temp_varW:=PEEK_WORD(area:=#IN_TYPE_OF_MEM, dbNumber:=#IN_NUM_READ_DB, byteOffset:=#temp_start);
    POKE(area:=16#84,dbNumber:=#IN_NUM_SEND_DB,byteOffset:=(#temp_db_pos_byte),value:=#temp_varW);
    #temp_i:=#temp_i+1;
    #temp_start:=#temp_start+2;
    #temp_db_pos_byte:=#temp_db_pos_byte+2;

Someone as any idea how to do it ?

Regards
 
Note that MW0 and MW4 are not bytes, so I'm assuming MB0 amd MB4

Source code for a block to do the bit copy:

Code:
FUNCTION FC 300 : VOID
TITLE =
VERSION : 0.1


VAR_INPUT
  wDBSrc : WORD ;    
  dwAreaSrc : DWORD ;    
  wDBDest : WORD ;    
  dwAreaDest : DWORD ;    
  iBitCount : INT ;    
END_VAR
VAR_TEMP
  iLoopCount : INT ;    
  wSRCDB : WORD ;    
  wDESTDB : WORD ;    
END_VAR
BEGIN
NETWORK
TITLE =

      L     #dwAreaSrc; 
      LAR1  ; 
      L     #dwAreaDest; 
      LAR2  ; 
      L     #wDBSrc; 
      T     #wSRCDB; 
      L     #wDBDest; 
      T     #wDESTDB; 
      L     #iBitCount; 
LLL:  T     #iLoopCount; 
      OPN   DB [#wSRCDB]; 
      A      [AR1,P#0.0]; 
      OPN   DB [#wDESTDB]; 
      =      [AR2,P#0.0]; 
      +AR1  P#0.1; 
      +AR2  P#0.1; 
      L     #iLoopCount; 
      LOOP  LLL; 
END_FUNCTION
 
Last edited:
Example call:

Code:
      L     P#M 0.0
      T     #dwAreaSrc
      L     P#M 4.5
      T     #dwAreaDest
      CALL  FC   300
       wDBSrc    :=W#16#0
       dwAreaSrc :=#dwAreaSrc
       wDBDest   :=W#16#0
       dwAreaDest:=#dwAreaDest
       iBitCount :=3
 
HAHA cool! It's not exactly what I want but you gave me a big big help with this code.
Really tks a lot :D

Best Regards from PORTO
 

Similar Topics

We've still got a ton a PLC 5's installed and running. We lost a 1771-P7 Series B power supply. There are a lot of 1771-P7 series D power...
Replies
3
Views
239
Hello! I'm looking for a recommendation for an application to connect to a remote computer. I need an alternative to TeamViewer. I'm trying to...
Replies
10
Views
797
Hey.. What is the best Substitute of 1747-DTAM (SLC 500 Data Table Access Module)... Suggest plz... what can be replaced with it? either Panel-view ?
Replies
4
Views
2,978
I was wondering about the tradeoffs of using a product like Archies AdvancedHMI drivers instead of RSLinx. I was thinking of doing some little...
Replies
5
Views
5,374
Dear Friends, Refering to subject line, I would like to ask you that if any one has ever used S5-CX945 for upgradation from S5 series outdated...
Replies
2
Views
2,089
Back
Top Bottom