S7 300 stl programming

FernandoJose

Member
Join Date
Feb 2017
Location
Brazil
Posts
5
I'm new in STL programming, today I was checking some example codes and found this:

L 1
L QB 4
SLW
T QB 4
SET
SAVE
CLR

I do not know the final result in QB4, can someone help me?
 
I'm not an STL expert, but I will venture a guess.

Basically you are shifting output byte 4 by 1 every time this code executes.

Load 1 into Accu1
Load QB4 into Accu1, which moves 1 to Accu2
Shift all the bits in Accu1 the integer that's in Accu2
transfer the result to QB4

If QB4 starts as 0000_0010

after the code executes once it will be 0000_0100.

hopefully this helps
 
Thanks you for your quick answer. So every time I use SLW first I load de number of bits that will be shifted, and then I load the data that will be shifted right?
 
There are actually more than one way that you can structure the instruction, but that will work.

I am a little confused about the fact that the W in SLW stands for Word and we are only assigning a byte, but perhaps someone who has a better understanding or experience with the instruction can enlighten us.
 
Thanks you for your quick answer. So every time I use SLW first I load de number of bits that will be shifted, and then I load the data that will be shifted right?


There are 2 ways you can do it.
If it's a fixed number of bits it needs to be shifted, you can do:

Code:
L QB4
SLW 1   // Shifts ACCU1 1 bit, you can do 4, 7, 8, etc.
T QB4

If you want to change the number of bits that you want it to shift, you can do:

Code:
L MB1   // Contains the nr of bits you want ACCU1 to shift
L QB4
SLW     // Shifts ACCU1 x amounts of bits
T QB4
 

Similar Topics

Hello everbody out there. I have 2 topics actually I wanted to share and get your opinions about but since they are related I sum up in one...
Replies
14
Views
9,829
First off thank you in advance. Second I am very new to STL. I am trying to build a counter that has one count up and 23 count down options. Am...
Replies
6
Views
384
Hi.Can I convert the block written in stl mode below to ladder mode? L #InOctet SLD 3 L #InBit OW T...
Replies
2
Views
562
Another STL question. In the attached screen shot the line with = #sf.S01_Dryer_ON dose not have the RLO on. But if we look lower in the logic...
Replies
4
Views
1,228
Hello, I am still new to STL. But from what I understand is the JC mnemonic should jump if RLO = 1. If we review both pictures the M0bf RLO = 1...
Replies
5
Views
1,059
Back
Top Bottom