how to reference logix program

James Mcquade

Member
Join Date
Oct 2007
Location
Nashville, Tennessee area
Posts
3,695
hi all,
in regards to logix programming, i have a question.
i have the following in the program tree
> Tasks
> Main Task
> Main Program
A
B
C
> Text_Program

i have the structured text program written and verified.
How do you get the main program to go to the Text_program?

i see this type of programs in our plant and i am trying to learn better programming methods.
thanks in advance,
james
 
hi all,
in regards to logix programming, i have a question.
i have the following in the program tree
> Tasks
> Main Task
> Main Program
A
B
C
> Text_Program

i have the structured text program written and verified.
How do you get the main program to go to the Text_program?

i see this type of programs in our plant and i am trying to learn better programming methods.
thanks in advance,
james

You can use a JSR block in a run in your main program to add your text code to the scan. Use the text_program as the parameter in your JSR, and place that JSR block in an appropriate rung as you feel good.

Regards,
-PreLC
 
thanks,
that helped, i was in the wrong location.
i am trying to learn structured text and this is what i am trying to do.
i can do the ladder logic for a motor starter forward or reverse, no issue.

i cannot seem to get the text part right.
if the power is on and the local motor disconnect is on and the motor is not in reverse and the motor off (wind down Timer) is off and you push the start pb
then motor1fwd is set to 1, else it is set to zero. pushing the stop pb reset the output.
Would someone please help me with this code. i am so confused right now.
thanks,
james
 
i can do the ladder logic nd will show what i have in structured text.
i will zip the file. it's quitting time and i will get to it tomorrow at work during break / lunch.
by the way, how do you past a picture in the post?
james
 
by the way, how do you past a picture in the post?
james
Before clicking "Submit Reply" click "Preview Post" instead and you will get an option for file attachments. If you only attach one png or jpg or bmp file the image is shown below the text. For more files a link is created for each attachment.
 
In ladder logic, this is a logical AND:
Code:
   A    B
--] [--] [--
In ladder logic, this is a logical OR:
Code:
      A
--+--] [--+--
  |       |
  |   B   |
  +--] [--+
I finally realized the phrase "motor starter circuit" may refer to what I usually call a "Start/Stop Circuit" pattern.

if the power is on AND the local motor disconnect is on AND the motor is not in reverse AND the motor off (wind down Timer) is off AND you push the start pb
then motor1fwd is set to 1, else it is set to zero.

pushing the stop pb reset the output. => (... AND stop pb is not pushed)
Actually that may not be quite right, I would guess that the green logic might actually be "AND (EITHER you push the start pb OR motor1fwd is already 1)"

Verbose ST

IF power_on AND lcl_disconn_on AND (NOT motor_in_reverse) AND (NOT wind_down_timer) AND (start_pb OR motor1fwd) AND (NOT stop_pb) THEN

motor1fwd := 1;

ELSE

motor1fwd := 0

END_IF;


Concise ST
motor1fwd := power_on AND lcl_disconn_on AND (NOT motor_in_reverse) AND (NOT wind_down_timer) AND (start_pb OR motor1fwd) AND (NOT stop_pb);


Caveats

  • The AND and OR operators may be && and || in some ST dialects.
  • I made some assumptions about the sense of some of those variables e.g. stop_pb is 0 or 1 when the pb is released or pressed, respectively, so you may need to remove some of the NOTs and/or insert a few of your own.
  • All of the colorful variables (tags) are assumed to be BOOLEANs.
  • How those colorful variables are set to 0 or 1 is beyond the scope of my ability to help here; presumably there is additional logic to handle those.
    • E.g. wind_down_timer sounds like it could the the .TT bit of a TON that starts timing when the motor was running and the stop_pb was pressed, and has a preset longer than it takes for the motor to coast to a stop
Equivalent ladder logic

  • Rung 0000 should be equivalent to the ST above
  • Rungs 0001 and 0002 compose a naive attempt at the wind-down logic
xxx.png
 
The wind-down is a bit cleaner with a TOF:
xxx.png
N.B.

  • NOT (power_on AND lcl_disconn_on) becomes pumping_disabled and inverted by using an XIO
  • Reverse logic has been added via branches, after the direction-independent logic, on Rung 0000.
 
Drbitboy, which software do you use to draw those cool curved arrows?


Microsoft Paint, Calligraphy Brush 1 (until now, I didn't know it had a name!).
xxx.png
self-reference.jpg
Cf. XKCD.com
 
Hmm, at first blush that Structured Text looks okay to me, although it does not yet have any wind-down logic ( AND (NOT Mtr1Running)). If it's not working, perhaps the sense of one of the booleans is inverted from the actual inputs? Boolean Mtr1Overload might be better named Mtr1NoOverload, if 1 is the value that allows the motor to run, and assuming you want to run the motor only if there is no overload.

Sidebar: to match the ladder logic, other than to add Mtr1Running, there should be a [Mtr1FwdPb := 0;] statement inserted between current lines 4 and 5, although I would put it outside the IF-THEN-ELSE-ENDIF, to ensure a stray press of the start PB, while the motor is otherwise inhibited, on the HMI does not hang around like a stale f@rt, waiting to start the motor when one of the permissives changes from 0 to 1.

Also, I am pretty sure your ladder logic as shown will not work as intended: OTE Mtr1Running should be driven by XIC OffDelayTimer1.TT, not by .EN/XIC .DN.

P.S. my ladder logic has a problem: while the motor is running in one direction or another, if the operator holds down the start push button and flips the forward/reverse switch, then the motor outputs will invert without waiting for the wind-down delay.

this is logix 5000 ...


Yah, I'm a dilettante, I don't have the real stuff readily available, but RSLogix Micro Starter Lite should be close enough, no?

.
 
Last edited:
With separate forward and reverse start PBs, I would go with something like this (the logic for Power, Disconnect and Overload is combined into the PWR_DSC_OVL_DISABLE bit):
xxx.png
That image shows the 13th second of the wind down; the forward start PB is pressed, but the [XIC wind_down/DN] bit is preventing that from starting the motor.

This still has a problem: if both forward and reverse buttons are held down at the same time when the wind-down timer expires and /DN becomes 0, then both forward and reverse outputs will become 1. This is one possible fix
yyy.png
Although there is still a possible race condition, especially with Logix 5000's asynchronous I/O, where if the forward and reverse start buttons are released and pressed, respectively and simultaneously, between Rungs 0001 and 0002, then both forward and reverse outputs will become 1. So perhaps a better solution is to AND an [XIO MOTOR1FWD_OUPUT] with the [XIC_PB_NORMALLY_OPEN] in the upper branch of the Start/Seal-in pair on Rung 0002.

Update: final answer? I am pretty sure the following ensures both directions will not be assigned a 1 simultaneously. N.B. if both start buttons are held down when the wind-down expires, the forward output will be dominant.
zzz.png
 
Last edited:
to All,

thanks for your help with the attachments and text structure.
i started all over and as i compiled the program, i noticed a message. i failed to create a main routine for my text portion.
the routine is called pgm_test02, i failed to create the MainRoutine part of the system and link pgm_test02 to the MainRoutine. i then created a subroutine for the starter and did a jsr to the starter routine.


drbitboy,
i am running the ladder logic portion that i posted now and it is working.
logix 5000 requires an output after the tof instruction or you get an error.

again,
thank you everyone.
james
 

Similar Topics

I had an idea to improve some of my standard programs, and make them easier to modify/expand in the future. Is there a way to address the current...
Replies
9
Views
3,717
Hello brothers and sisters of PLCTalk.net, I am working with a PLC5/40 program which uses RSLogix 5, and am wondering if there is a way to export...
Replies
1
Views
1,342
Hi! I had a little problem yesterday regarding how to link two DINTs together, but after some time thinking, I feel my question is actually, “How...
Replies
29
Views
7,230
Hi all, I have a concept I have implemented with other PLCs whereby I use alias variables in the PLC to expose cross-reference information to the...
Replies
3
Views
3,571
Hi all, I have a program running on Rslogix 500 and whenever I try to do online cross reference, it freezes the program. I have to close RSlogix...
Replies
0
Views
1,572
Back
Top Bottom