Another Siemens Indirect Addressing Question

rikcando

Member
Join Date
Apr 2012
Location
Ontario
Posts
128
Yes, I did search for information first. Yes I looked through the limited help files that came with my Step 7. No I do not have any other books.

What I have done:
Machine does 3 basic sequences. I have 3 different FB's based on each sequence used to determine the next command number to send out (1 byte). I have (on paper) written a fourth FB to handle the actual setting of the command output byte (QB22), monitoring the acknowledge inputs (IB22), and setting Q21.5 when the acknowledge is completed correctly.

Item to consider:
Machine actually handle 2 sets of 3 basic sequences. Two simialr processes each with 3 FB's, each with a command byte and an acknowledge byte to be handled in the same manner. First set is QB/IB22, second set is QB/IB122.

What I would like to do:
In Ladder, not STL, write one FB to handle both command/ acknowledge sets. I would like to send the address of the command byte to the FB instead of hardcoding it and having two FB's.

Is it possible?
 
I think I have been thinking too hard on this. Now that I have read this I see that I should probably just use the IN/OUT variables as my QB/IB and that would do it. Sorry for wasting your time.

Edit:
But is it possible?
 
Sorry for delay but I took a nap. Thanks for the reply. Here is a small sketch I put together .

Edit: to update picture

process.jpg
 
Last edited:
The process FB's will have an OUT parameter of CmdByte (byte).

The Main FB1 would call 2 instances of FB30, passing CmdByte and a pointer to the correct QB address.
Edit: Actually, I just wanted to send an INT and use it as the pointer address since I have configured the QB and IB to be the same for each device.
 
Last edited:
I have been playng with the pointers trying to figure out how they work. I've not had very much success. I can load an output byte and transfer to a memory byte (L QB 3;T MB 4) but if I stick a pointer in there it give me an error.

I tried moving the pointer to a TEMP variable first (type INT) but still it does not work.

The error I get when I try to 'L QB [#tmpPoint];' is "Statement not permitted for DWORD/DINT indir. instruction address".
What does this mean? Can the pointer be used with an output byte (QB)?
 
This pointer must be a doubleword.
The format is byte,bit. The 3 lsb's forms the bit no, and must be 0 by byte/w/dw access. ( L byteno / SLD 3 would to the trick).

Have no time to check your sketch now, I'm off to a meeting.
Maybe LD pops in.

Kalle
 
Alright, I know that I said that I wanted to do it in ladder, and that is mostly due to customer demand to keep the STL to a minimum. Below is basically what I want to do. I would prefer to have it in ladder. The issue is that I wanted to make an FB (or FC) to do this but replace the hardcoded address with a pointer to the input and output bytes.

Code:
      L     #CmdByte                    //Load command byte
      T     QB    22                    //tranfer to outptu byte
      L     IB    22                    //load ack inputs
      L     QB    22
      ==I                               //if equal
      =     #Ackd                       //      set OUT ack bit
      AN    #Ackd                       //if not ack'd
      =     #NotAckd                    //set  temp for tmr IN
      CALL  #Faulted                    //run SFB4
       IN:=#NotAckd
       PT:=T#2S                         // after 2 seconds
       Q :=#FaultBit                    //    turn on OUT fault bit
       ET:=
      AN    #temp                       //temp bit not on 
      SAVE                              // save - set br
 
Thank you KalleOlsen. I think I understand now. I needed to reboot the Step 7 computer but I will be testing that right away.
 
Hold on - why do you think you need to use a pointer and not pass the QB as an IN_OUT parameter to the FB?
 
Last edited:
I have not given the whole story. I was trying to keep it to a simple question. I am not looking for other to do my work for me, and I was hoping to be able to figure this out myself. I guess i like the challenge.

I have 3 different bytes to send. I could send one byte and increment to the other bytes as needed. I wanted to make it a bit more efficient and readable by not having to send in 3 output bytes and 3 input bytes. If I could just send in one byte, or even DWORD with the address it would be much more presentable.

I can use the IN/OUT. I would prefer not to. I would like to learn how the pointer works.

I created a small sample program but it keeps crashing on me. It tells me it needs OB121. Loaded it in (empty) and I get the following error.

Alignment error on reading. (FB3 which has pointer logic)
Cause:
A bit address (bits 0 to 2) was specified for byte, word, or double word access.
To correct or avoid errors:
Make sure that the bit address contains access address 0.
 
Current FB3
Code:
      L     #Pnt_QB3                    //Load command byte
      T     #DWPntr                     //tranfer to outptu byte
      SLD   3
      L     #CmdByte
      T     QB [#DWPntr]
      L     IB [#DWPntr]                //load ack inputs
      L     QB [#DWPntr]
      ==I                               //if equal
      =     #Ackd                       //      set OUT ack bit
      AN    #Ackd                       //if not ack'd
      =     #NotAckd                    //set  temp for tmr IN
      CALL  #Faulted                    //run SFB4
       IN:=#NotAckd
       PT:=T#2S                         // after 2 seconds
       Q :=#FaultBit                    //    turn on OUT fault bit
       ET:=
      AN    #temp                       //temp bit not on 
      SAVE                              // save - set br
 
You need to post all of the .AWL for your FB3 as I have no idea what the variable types are in your code (e.g. IN_OUT/STAT/TEMP...)
 
I think it would be nice to know how to do this is necessary.

I will write an FC to return the ack bit and handle a single byte. I will call it 3 times, once for the command, once for DataX, and once for DataY. I can set up 3 different Ack bits and test those. I will do this just to make some progress today. If I write a small FC is it easier to pass off the use of STL with my client.

But I still would like to know how to do this, and is it possible to do this in LAD.
 

Similar Topics

Hi Guys. Apologies for the long winded script but I want to give you the full script I imagine some of you guys have been in the same situation...
Replies
9
Views
2,227
Dear All, I have a machine of stone cutting CNC. with Siemens 810D system. I am very tired to maintain(Servo drive failure) it now wants to...
Replies
8
Views
4,910
Hi guys I need to transfer a tia license for a couple of days from one pc to another via usb and then back again after wards. What is right way...
Replies
10
Views
6,866
Yes, I'm sorry, I'm starting this topic again. In my defense, I promise I tried to read on this forum and using other sources to get a good idea...
Replies
8
Views
4,310
Hi all, I need some assistance. Does anyone know if it is possible to or how to copy a HMI project from one program to another program...
Replies
5
Views
4,913
Back
Top Bottom