generate a pulse signal in structured text in Studio 5000

batindeko

Member
Join Date
Nov 2017
Location
stutensee
Posts
16
Hey,

i need help to write a structured text program that set a signal to high 6s and to low 6s. I used TONR to do this but it doesn't work


Code:
TONR_0.PRE := 6000;
TONR_0.Reset := Reset ;

TONR_0.TimerEnable:= 1;

TONR(TONR_0);

timer_state := TONR_0.DN;


TONR_1.PRE := 6000;

TONR_1.TimerEnable:= timer_state;

TONR_1.Reset := Reset;

if timer_state then

TONR(TONR_1);

if  TONR_1.DN AND Local:1:I.Data.1 then

TONR(TONR_0);

end_if;
end_if;

		if TONR_0.DN then 
	
			impact67_55144:O1.Data[0]:= -1;
			impact67_55144:O1.Data[1]:= -1;

		end_if;

		if not(TONR_1.DN) then 
	
			impact67_55144:O1.Data[0]:= 0;
			impact67_55144:O1.Data[1]:= 0;

I wote the same program in ladder logic and that program works fine find attached the program here

ladder_logic.jpg
 
Code:
(...)
TONR_1.Reset := Reset;
[COLOR=Red][B]if timer_state then <-delete just this line[/B][/COLOR]
  TONR(TONR_1);
if  TONR_1.DN AND Local:1:I.Data.1 then 
(...)
Try deleting the line in red.

Code:
(...)
TONR_1.Reset := Reset;
TONR(TONR_1);
if  TONR_1.DN AND Local:1:I.Data.1 then 
(...)
 
I finallly found how to do it. below is my Code.

I would like anyway to know which other method i can use to make it. thank again for your Support.

Code:
TONR_0.PRE := 1000;         // set the preset time

TONR_0.Reset := TONR_1.DN  ;    // reset the
TONR_0.TimerEnable:= 1;

TONR(TONR_0);

TONR_1.PRE := 1000;

TONR_1.TimerEnable:= TONR_0.DN;

TONR(TONR_1);

		if TONR_0.DN then 
	
			impact67_55144:O1.Data[0]:= -1;
			impact67_55144:O1.Data[1]:= -1;

		else 
	
			impact67_55144:O1.Data[0]:= 0;
			impact67_55144:O1.Data[1]:= 0;

		end_if;
 
This is with a IEC TON timer, as it has been a few years since I had to touch an A-B PLC.

Code:
myTON(IN:=NOT myTON.Q, PT:=t#6s);
bSignal := bSignal XOR myTON.Q;

There. Every time the timer elapses, it will flip the bSignal.
It's pretty crude and will start in the off state, but it's quick and easy.

Some translation:
.IN = .TimerEnable
.Q = .DN
.PT = .PRE
 

Similar Topics

Does anyone know how to generate output pulse in plc CP1E-N40DR-A??? What instruction i need to make pulse output working.....
Replies
1
Views
1,892
Hello Friends, I am looking for a way to take my PID Output( it is the result of my PI Algorithm in Real format) and generate a PWM Signal in...
Replies
16
Views
2,449
Does anyone know a way to dynamically generate a 2D barcode on a PanelView screen? An Activex Control maybe? If such a method is out there, it...
Replies
14
Views
2,958
Hi, I am trying to generate source file of OB1 including all dependent blocks. But i am getting a message which says-->>one or more blocks...
Replies
3
Views
1,245
Hello Everyone, I would like to know where to start when designing a HMI+PLC Allen Bradley based, that complies with CFR 21 PART 11, ALCOA...
Replies
4
Views
2,897
Back
Top Bottom