Description

The following program is a short demo application to send the "Hello World" message through a Hayes compatible Modem (Com One, Deskline 56K).

To start the application, the "stage" variable has to be set to 1 in a Control Expert animation table.

Variable Data Types

start_xxmit_block

BOOL

command

WORD

msgout

ARRAY[0.40] OF BYTE

Msg_Size

INT

xmit_DONE

BOOL

xmit_ERROR

BOOL

xmit_ACTIVE

BOOL

xxmit_RESPTOUT

INT

xxmit_STARTDLY

INT

xxmit_ENDDLY

INT

xmit_STATUS_mem

INT

counter

INT

stage

WORD

IEC section for XXMIT

Program the following in an FBD section:

IEC Section for Modem commands

Program the following in an ST section:

(* %S6 is used to generate a 2 second delay *) %m6 := %s6;
if xxmit_STATUS_Mem = 0 then
if not(xxmit_STATUS = 0) then
xxmit _STATUS_Mem := xxmit_STATUS;
end_if; end_if;
(* If XXMIT error, the function block is stopped *) if xmit_ERROR=1 then
stage := 0;
counter := 0;
start_xxmit_block:=0; end_if;
if stage = 1 then 
(* Initialization message*)
xxmit_STATUS_Mem := 0;
counter := 0;
xxmit_ENDDLY := 700;
xxmit_STARTDLY := 600;
xxmit_RESPTOUT := 700;
(* Command word init *)
command:=2#0000001000000001;
msgout[0] := 16#26;(*&->26*)
msgout[1] := 16#46;(*F->46*)
msgout[2] := 16#26;(*&->26*)
msgout[3] := 16#4B;(*K->46*)
msgout[4] := 16#30;(*0->30*)
msgout[5] := 16#26;(*&->26*)
msgout[6] := 16#44;(*D->44*)
msgout[7] := 16#30;(*0->30*)
 msgout[8] := 16#56;(*V->56*)
msgout[9] := 16#31;(*1->31*)
msgout[10] := 16#51;(*Q->51*)
msgout[11] := 16#30;(*0->30*)
msgout[12] := 16#58;(*X->58*)
msgout[13] := 16#30;(*0->30*)
msgout[14] := 16#45;(*E->45*)
msgout[15] := 16#31;(*1->31*)
Msg_Size := 16;
start_xxmit_block:=1;
stage := 2; end_if;
if stage = 3 then
(* Dial message *)
xxmit_STARTDLY := 100;
xxmit_ENDDLY := 100;
xxmit_RESPTOUT := 32000;
(* Command word init *)
command:=2#0000001000000010;
(* Extension number *)
msgout[0] := 16#32;(*2*)
msgout[1] := 16#35;(*5*)
msgout[2] := 16#37;(*7*)
msgout[3] := 16#34;(*4*)
start_xxmit_block:=1;
Msg_Size := 4;
stage := 4; end_if;
if (stage = 5)then 
if RE(%m6) then
counter := counter + 1;
end_if;

(* Two seconds delay *)
if stage = 5 and counter = 2 then
counter := 0;
stage := 7;
end_if; end_if;
if stage = 7 then 
(* ASCII message to be send *)
 xxmit_STARTDLY := 300;
xxmit_ENDDLY := 400;
xxmit_RESPTOUT := 32000;
(* Command word init *) 
command:2=#0100001000000000; 
msgout[0] := 16#48; (*H*)
msgout[1] := 16#65; (*e*)
msgout[2] := 16#6C; (*l*)
msgout[3] := 16#6C; (*l*)
msgout[4] := 16#6F; (*o*)
msgout[5] := 16#20; (* *)
msgout[6] := 16#57; (*W*)
msgout[7] := 16#6F; (*o*)
msgout[8] := 16#72; (*r*)
msgout[9] := 16#6C; (*l*)
msgout[10] := 16#64; (*d*)
msgout[11] := 16#20; (* *)
msgout[12] := 16#21; (*!*)
msgout[13] := 16#21; (*!*)
Msg_Size := 14;
start_xxmit_block:=1;
stage := 8; end_if;
if stage = 100 then
(* Hangup message *)
command:=2#0000001000000100;
xxmit_STARTDLY := 300;
xxmit_ENDDLY := 400;
xxmit_RESPTOUT := 500;
msgout[0] := 16#48;(* *)
msgout[1] := 16#30;(*CR*)
Msg_Size := 2; 
start_xxmit_block:=1; end_if;
(* Change of state after each XXMIT operation *) if xmit_DONE = 1 then 
start_xxmit_block:=0;
if stage = 2 then 
stage := 3;
end_if;

if stage = 4 then
ounter := 0;
stage := 5;
end_if;

if stage = 8 then
stage := 99;
end_if;

if stage = 99 then
stage :=100;
end_if; end_if;