Help with SCL

STL???

Member
Join Date
Sep 2005
Location
UK
Posts
879
Hi,
I'm trying to create an adjustable step generator in SCL, the idea being that a DB of words holds the step order and when the step has completed, the code looks to the next word for the step value.
i.e
DB1.DBW0 = 2 (move 2 to active step)
step done then
DB1.DBW2 = 15 (move 15 to active step)
step done then
DB1.DBW4 = 10 (move 10 to active step)
etc

each number is assigned to an action and once completed sets step end "high" to increment to the next word.

Ultimately i can alter the sequence order (valve control) via datablock edit.

Heres what i've wrote so far, but i get the following error on line 53 "Invalid data type" which is this line of code:

Active_Step:= Seq_DB.DW[step_index];

How do i address this so i can access each word with the offset provided by step_index?

this is my first attempt at SCL, so all criticism good and bad welcome

thanks Steve


FUNCTION_BLOCK FB305
TITLE = 'Sequencer'
// know_how_protect
//
//
//
VERSION : '1.0'
AUTHOR : ???
FAMILY : SEQ_S7
NAME : Seq


VAR_INPUT
Seq_DB:BLOCK_DB;
Step_end:BOOL;
Max_Step:INT;
Reset:BOOL;
END_VAR

VAR_IN_OUT
Supervisor_time: INT;
END_VAR

VAR_OUTPUT
Active_Step:INT;
END_VAR

VAR_TEMP
END_VAR

VAR
//Static Variables
Step_end_store: BOOL;
Step_end_Pulse:BOOL;
Step_index:INT;
END_VAR

// Generate one shot pulse for Step_end
Step_end_Pulse:= Step_end AND NOT Step_end_store;
Step_end_store:=Step_end;

// maximum step reached or Reset needed?
IF step_index >= Max_step OR Reset THEN
step_index:=0;
END_IF;


// Step increment
IF Step_end_Pulse then
step_index:= step_index + 1;
Supervisor_time:=0;
Active_Step:= Seq_DB.DW[step_index];
// Active_Step:=step_index
END_IF;


END_FUNCTION_BLOCK

 
Not sure.

Try to setup an array of INTs in your Datablock Seq_DB. Call the array "Step".

Then change from
Active_Step:=Seq_DB.DW[step_index]
to
Active_Step:=Seq_DB.Step[step_index]

I generally try to avoid adressing absolutely in SCL.
Indexing arrays symbolically is a breeze in SCL.
 
Also, comment out this line:
Seq_DB:BLOCK_DB;

But it seems you want to pass the DB block number to the SCL block.
That will take a bit more effort

//add this:
VAR_TEMP
Seq_DB:BLOCK_DB;
Seq_DB_word : WORD ;
END_VAR;

//add this
BLOCKDB_word := BLOCK_DB_TO_WORD(Seq_DB);

//modify to this:
Active_Step:= WORD_TO_INT(WORD_TO_BLOCK_DB(Seq_DB_word).DW[step_index]);

Not sure if it works as advertised.
And it does not look nice, but what the hey.

edit: LD you solution is so much simpler.
The extra step via a WORD variable is redundant.
 
Last edited:
New posters take note, this is an excellent example of how to create a new thread.

Explain what you are trying to do, state the specifics of what is going wrong and post the code. Give that man a beer.
 
Give that man a beer

I've lost count of how many i owe to you, Jesper and a few others!!!

the basic code is now working - i just needed to change the incrementer from 1 to 2 because i was indexing bytes.

Now to start tightening up/error checking....

Regards
Steve
 
Perhaps Phil Should.........

L D[AR2 said:
New posters take note, this is an excellent example of how to create a new thread.

Explain what you are trying to do, state the specifics of what is going wrong and post the code. Give that man a beer.

Perhaps Phil should put a sticky permanently at the top post

Titled Please Read before Posting:

Did you do a Search before you posted ?

Then

HOW TO POST A QUESTION AND WHAT TO INCLUDE

1...
2...
3...
4...

etc
 
504bloke said:
Perhaps Phil should put a sticky permanently at the top post

Titled Please Read before Posting:

Did you do a Search before you posted ?

Then

HOW TO POST A QUESTION AND WHAT TO INCLUDE

1...
2...
3...
4... etc

Now I would vote for this.

There was a post in last 24 hours where someone wanted to monitor motor current and asked can it be done. He kinda forgot to mention if motor was AC or DC.

Dan Bentler
 

Similar Topics

Hello nice to meet you, im new in here, I'm currently trying to convert code written in STL for a S7-400 to SCL for an S7-1500, because when i run...
Replies
5
Views
316
Hi! I am working on a project were we will be replacing an 300 CPU with a 1500 CPU and we are working on migrating / converting code. There is a...
Replies
9
Views
1,066
Hi, Can someone translate this for me please, or at least help to explain what the instructions mean? SET SAVE =...
Replies
17
Views
4,613
Hi guys Its been some time since I worked with SCL and have a few lines of code I need some help with, I have the SCL raw code and am currently...
Replies
1
Views
1,499
Working with a SCL instruction and need a little help. The logic is a Heat / Cool circuit controlled by a PID. The PID Zone_4.CVEU tag is coming...
Replies
3
Views
3,163
Back
Top Bottom