Author Topic: Sequencing question  (Read 6375 times)

mvincent

  • Newbie
  • Posts: 8
  • Ska Brew!
    • View Profile
Sequencing question
« on: June 11, 2012, 10:11:53 PM »
I have a sequence of operations that I am doing and  I need the user to be able to plug in how many times the operations need to be repeated(using a DM value input from an HMI), i.e I need Seq 1:1 to Seq 1:5  to run 10 times.  

I am having a mental block about how to go about doing this.

Any help would be greatly appreciated!

Thanks
Matt

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3171
    • View Profile
    • Internet Programmable PLCs
Re:Sequencing question
« Reply #1 on: June 12, 2012, 03:35:59 AM »
You could use a down counter and copy the values from DM to the CTRPV[n]. Each time the sequencer completes a cycle it decrements the counter by one and when it reaches zero the sequencer is locked out.

You need to run a custom function periodically to check that the user has set a new DM value from the HMI. It then copies the DM value to the CTRPV[n] stated above. Once copied it zeros out the DM or set it to some non functional value so that it will not copy again until the user enter a new DM value from the HMI again.
« Last Edit: June 12, 2012, 03:36:16 AM by support »
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

mvincent

  • Newbie
  • Posts: 8
  • Ska Brew!
    • View Profile
Re:Sequencing question
« Reply #2 on: June 19, 2012, 09:32:32 PM »
So I got the counters to all work, however when the DNctr = 0 it just stops everything.  Here is the Dcusf I am using for Seq 1:4:

IF DM[5]=0 then CALL 26                ' DM[5]=ctrpv[2]

else CTRPV[1]=1                      ' CTRPV[1]= my sequencer that I am trying to send back to sequence 1

If I use AdvSeq1:1 it resets the sequencer back for another cycle.

I can't figure out how to get it out of the sequencing cycle when the counter hits 0 and go to dcusf#26

What am I doing wrong?

Thanks

Matt
« Last Edit: June 19, 2012, 09:34:52 PM by mvincent »

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3171
    • View Profile
    • Internet Programmable PLCs
Re:Sequencing question
« Reply #3 on: June 20, 2012, 10:23:26 AM »
You can reset the sequencer by setting its counter value (CTRPV[]) to -1. ie. If your sequencer is set to counter #1, use the following code to reset it.

CTRPV[1] = -1
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

garysdickinson

  • Hero Member
  • Posts: 502
  • Old PLC Coder
    • View Profile
Re:Sequencing question
« Reply #4 on: June 20, 2012, 10:53:10 AM »
I will give you a bullet-proof approach to using the Sequencers for you issue.  I will spread it across a couple of these messages.

The idea is to implement a Moore State Machine (computer science 101).  I have used this approach to build very complex PLC projects.

The following diagram is what I intend to build.

Gary D
« Last Edit: June 20, 2012, 11:33:54 AM by garysdickinson »

garysdickinson

  • Hero Member
  • Posts: 502
  • Old PLC Coder
    • View Profile
Re:Sequencing question
« Reply #5 on: June 20, 2012, 10:56:28 AM »
This is the ladder logic portion of the state machine.  

I chose not to use a ladder-logic COUNTER because of your requirement to have the loop count adjustable.  I chose to use custom functions to manage a software counter that sets a RELAY, LoopCntrZero, to indicate when the loop count has expired.

I would have used a ladder logic COUNTER if the loop count is always the same.

Gary D
« Last Edit: June 20, 2012, 11:39:57 AM by garysdickinson »

garysdickinson

  • Hero Member
  • Posts: 502
  • Old PLC Coder
    • View Profile
Re:Sequencing question
« Reply #6 on: June 20, 2012, 11:00:42 AM »
The following are the 2 custom functions that manage the down
counting of a variable and set/clear a RELAY to indicate the state
of the software counter.



' LoadLoopCntr - Custom function to load loop counter with HMI value
'
' The RELAY LoopCntrZero is used to control Seq1
'
' LoopCntr is defined as DM[1] using the #Define mechanism - Down counter used to control Seq1
' HMICnt is defined as DM[2] useing the #Define mechanism - This value is from the HMI

IF (HMICnt > 0)
???LoopCntr = HMICnt
ELSE
???LoopCntr = 5???' Default loop count
ENDIF

CLRIO LoopCntrZero





' DecLoopCntr - Custom function to decrement LoopCntr
' The RELAY LoopCntrZero is used to control Seq1
'
' LoopCntr is defined as DM[1] using the #Define mechanism - Down counter used to control Seq1


LoopCntr = LoopCntr - 1
IF (LoopCntr <= 0)
???SetIO LoopCntrZero??????' The counter has hit ZERO!
ENDIF





I can send you a running PLC program that you can run in simulation if you provide me an email address.  My email address is in my forum profile.  You can contact me via that address.

Gary D.
« Last Edit: June 20, 2012, 11:32:44 AM by garysdickinson »