Creating a Delay

16 views
Skip to first unread message

addi...@wrcakron.com

unread,
May 14, 2009, 4:09:26 PM5/14/09
to FBDK
If I have the following source code, how would I write in a delay
before each out put would turn on? What I want to do is have them turn
on sequentially. I am a student electrical engineer with the
University of Akron, so my experience with programming limited at the
moment.
Code:
FUNCTION_BLOCK W2K1_DO (* Service Interface to One Bank of W2-61499-K1
Digital Output *)
EVENT_INPUT
INIT WITH QI,BANK; (* Service Initialization *)
REQ WITH QI,OUT0,OUT1,OUT2,OUT3,OUT4,OUT5,OUT6,OUT7; (* Write
Output *)
END_EVENT
EVENT_OUTPUT
INITO WITH QO,STATUS; (* Initialization Confirm *)
CNF WITH QO,STATUS; (* Output Write Confirmation *)
END_EVENT
VAR_INPUT
QI : BOOL; (* Event Input Qualifier *)
BANK : UINT; (* Bank number {1..6} *)
OUT0 : BOOL; (* I/O Point Number 8*BANK *)
OUT1 : BOOL; (* I/O Point Number 8*BANK+1 *)
OUT2 : BOOL; (* I/O Point Number 8*BANK+2 *)
OUT3 : BOOL; (* I/O Point Number 8*BANK+3 *)
OUT4 : BOOL; (* I/O Point Number 8*BANK+4 *)
OUT5 : BOOL; (* I/O Point Number 8*BANK+5 *)
OUT6 : BOOL; (* I/O Point Number 8*BANK+6 *)
OUT7 : BOOL; (* I/O Point Number 8*BANK+7 *)
END_VAR
VAR_OUTPUT
QO : BOOL; (* Event Output Qualifier *)
STATUS : UINT; (* 0=OK, 1=Inhibited, 2=Allocation Error *)
END_VAR
SERVICE APPLICATION/RESOURCE
SEQUENCE normal_allocation (* Allocates bank as 8 outputs *)
APPLICATION.INIT+(BANK) -> RESOURCE.allocateOutputs(BANK) ->
APPLICATION.INITO+();
END_SEQUENCE
SEQUENCE unsuccessful_allocation (* Bank already allocated OR Invalid
bank number *)
APPLICATION.INIT+(BANK) -> RESOURCE.allocateOutputs(BANK) ->
APPLICATION.INITO-(STATUS=2);
END_SEQUENCE
SEQUENCE normal_write (* Write data to previously allocated CHNO *)
APPLICATION.REQ+(OUT0..OUT7) -> RESOURCE.write(OUT0..OUT7) ->
APPLICATION.CNF+();
END_SEQUENCE
SEQUENCE write_inhibited
APPLICATION.REQ-() -> APPLICATION.CNF-(STATUS=1);
END_SEQUENCE
SEQUENCE allocation_error (* CHNO not allocated for output *)
APPLICATION.REQ+() -> APPLICATION.CNF-(STATUS=2);
END_SEQUENCE
SEQUENCE conversion_error (* Analog data conversion error *)
APPLICATION.REQ+() -> RESOURCE.write(DATA) -> APPLICATION.CNF-
(STATUS=3);
END_SEQUENCE
SEQUENCE deallocate (* Makes CHNO available for re-allocation *)
APPLICATION.INIT-(CHNO) -> RESOURCE.deallocate(CHNO) ->
APPLICATION.INITO-(STATUS=0);
END_SEQUENCE
END_SERVICE
END_FUNCTION_BLOCK

James Christensen

unread,
May 15, 2009, 5:33:59 PM5/15/09
to fb...@googlegroups.com
Send us the XML code so we can import the block into the FBDK and see
what it looks like (the FBDK doesn't import the textual source code
anymore because the XML is the standard interchange format). Then we
can continue the discussion from there.
- Jim C
--
Best regards,
Jim Christensen

addi...@wrcakron.com

unread,
May 18, 2009, 9:34:13 AM5/18/09
to FBDK
XML Code Start
<!DOCTYPE FBType SYSTEM "http://www.holobloc.com/xml/
LibraryElement.dtd" >
<FBType Name="Basic" Comment="Basic Function Block Type" >
<Identification Standard="61499-2" />
<VersionInfo Organization="Rockwell Automation" Version="0.2"
Author="JHC" Date="2003-12-04" Remarks="Renamed for better indexing." /
>
<VersionInfo Organization="Rockwell Automation" Version="0.1"
Author="JHC" Date="2002-11-05" Remarks="Corrected missing ST element
in Algorithm REQ." />
<VersionInfo Organization="Rockwell Automation" Version="0.0"
Author="JHC" Date="2000-05-30" />
<CompilerInfo header="package fb.rt.template;" >
</CompilerInfo>
<InterfaceList>
<EventInputs>
<Event Name="INIT" Comment="Initialization Request" >
<With Var="QI" />
</Event>
<Event Name="REQ" Comment="Normal Execution Request" >
<With Var="QI" />
</Event>
</EventInputs>
<EventOutputs>
<Event Name="INITO" Comment="Initialization Confirm" >
<With Var="QO" />
</Event>
<Event Name="CNF" Comment="Execution Confirmation" >
<With Var="QO" />
</Event>
</EventOutputs>
<InputVars>
<VarDeclaration Name="QI" Type="BOOL" Comment="Input event
qualifier" />
<VarDeclaration Name="DIGI_IN" Type="BOOL" />
</InputVars>
<OutputVars>
<VarDeclaration Name="QO" Type="BOOL" Comment="Output event
qualifier" />
<VarDeclaration Name="DIGI_OUT0" Type="BOOL" />
<VarDeclaration Name="DIGI_OUT1" Type="BOOL" />
<VarDeclaration Name="DIGI_OUT2" Type="BOOL" />
<VarDeclaration Name="DIGI_OUT3" Type="BOOL" />
<VarDeclaration Name="DIGI_OUT4" Type="BOOL" />
<VarDeclaration Name="DIGI_OUT5" Type="BOOL" />
<VarDeclaration Name="DIGI_OUT6" Type="BOOL" />
<VarDeclaration Name="DIGI_OUT7" Type="BOOL" />
</OutputVars>
</InterfaceList>
<BasicFB>
<InternalVars>
<VarDeclaration Name="SEQUENTIAL_DELAY" Type="BOOL" />
</InternalVars>
<ECC >
<ECState Name="START" Comment="Initial State" x="552.9412"
y="429.4117" >
</ECState>
<ECState Name="INIT" Comment="Initialization" x="923.5294"
y="141.1765" >
<ECAction Algorithm="INIT" Output="INITO" />
</ECState>
<ECState Name="REQ" Comment="Normal execution" x="217.647"
y="752.9412" >
<ECAction Algorithm="REQ" Output="CNF" />
</ECState>
<ECTransition Source="START" Destination="INIT" Condition="INIT"
x="923.5294" y="429.4117" />
<ECTransition Source="INIT" Destination="START" Condition="1"
x="552.9412" y="141.1765" />
<ECTransition Source="START" Destination="REQ" Condition="REQ"
x="552.9412" y="600.0" />
<ECTransition Source="REQ" Destination="START" Condition="1"
x="217.647" y="429.4117" />
</ECC>
<Algorithm Name="INIT" Comment="Initialization algorithm" >
<ST Text="" />
</Algorithm>
<Algorithm Name="REQ" Comment="Normally executed algorithm" >
<ST Text="" />
</Algorithm>
</BasicFB>
</FBType>
XML Code End

Essentially what I am seeking to do is create an algorithm which will
delay each output sequentially, so in other words it receives input
data and the corresponding events, which I have used the Basic FB
model for, and then it will out put data on DIGI_OUT0, wait 0.5seconds
then out put data on DIGI_OUT1 and continue on until all outputs are
on. The purpose of this is for testing I/O on W2's. I am a EET Co-op,
so my knowledge of programming languages is still growing, I have not
had any experience with XML or Structural Text, only some C, so this
is a new language and it is still unfamiliar to me. Thanks for the
help.

Jim Christensen

unread,
May 18, 2009, 9:48:54 AM5/18/09
to FBDK
Have a look at the FLASHER_TEST configuration and the related FLASHER4
FB in the src/doc folder. You should be able to do what you want by
extending the FLASHER4 block to FLASHER8.
- Jim C

addi...@wrcakron.com

unread,
May 18, 2009, 10:44:45 AM5/18/09
to FBDK

Jim, how do I actually test the block? When I open the FBDK Editor all
I see is Run, from what I understand there is an actual testing
utility that I can manually set inputs and events and such to test the
blocks. Where can I find this utility?

addi...@wrcakron.com

unread,
May 18, 2009, 10:20:36 AM5/18/09
to FBDK
Jim, if I were to write an algorithm for a function block, can I write
it in Java or C in the structured text window if I specify the
language type? The Modeling Control systems using IEC61499 book was a
little unclear on that. I will also take a look at the FLASHER_TEST
fb. Thank you for the help.

On May 18, 9:48 am, Jim Christensen <james.h.christen...@gmail.com>
wrote:

James Christensen

unread,
May 18, 2009, 11:36:20 AM5/18/09
to fb...@googlegroups.com
Help==>How To...==>Basic FBs==>Step 3, link to "algorithms"
- also online at http://www.holobloc.com/doc/fbdk/howto.htm

Jim Christensen

unread,
May 18, 2009, 11:36:45 AM5/18/09
to FBDK
When all else fails - RTFM! Help==>HowTo...==> Basic FBs

addi...@wrcakron.com

unread,
May 18, 2009, 12:44:12 PM5/18/09
to FBDK
When I try to compile the Java file I recieve this error:
Can't run the Java compiler command:
\Program Files\Java\jdk1.6.0_03\bin\javac -classpath .\lib;.
\fbrt.jar
Check the javac preference in the editor.ini file.

I am not sure exaclty how I can check the preference in the .ini
file.

On May 18, 11:36 am, Jim Christensen <james.h.christen...@gmail.com>
wrote:

addi...@wrcakron.com

unread,
May 18, 2009, 1:01:01 PM5/18/09
to FBDK
I discovered the root of the problem, please disregard, the path was
to an incorrect version of the compiler.

addi...@wrcakron.com

unread,
May 18, 2009, 4:00:12 PM5/18/09
to FBDK
Can you please explain some of the operation of TON(IN:=A,PT:=B); I
understand that TON is a delay timer on, and the input is the input
time length, but what I do not understand is the PT:=B, what is the
purpose of this? Essentially what I want to use it for is delaying
outputs for the following code:

OUT3:=NOT OUT3;
"delay of 0.5seconds"
IF NOT OUT3 THEN
OUT2:=NOT OUT2;
"delay of 0.5seconds"
IF NOT OUT2 THEN
OUT1:=NOT OUT1;
"delay of 0.5seconds"
IF NOT OUT1 THEN OUT0:=NOT OUT0;END_IF;
END_IF;
END_IF;

This is COUNT_UP algorithm from FLASHERT which you suggested I use as
a start.

James Christensen

unread,
May 18, 2009, 4:47:29 PM5/18/09
to fb...@googlegroups.com
Drive the flasher logic with periodic events from E_CYCLE as in the
FLASHER_TEST configuration. Do not try to build delays into the
flasher code. The FBDK does not support TON or IEC 61131-3 style timer
blocks, because IEC 61499 is an event-driven architecture, not
scan-driven as in 61131-3. In fact, for FBD and LD algorithms, the
FBDK and FBRT have supported only pure functional programming since
2006-09-01; see http://www.holobloc.com/doc/fbdk/fbdahlp.htm.
- Jim C
Reply all
Reply to author
Forward
0 new messages