Author Topic: Pump Seq  (Read 6225 times)

rbatta

  • Newbie
  • Posts: 11
  • I'm a llama!
    • View Profile
Pump Seq
« on: February 26, 2012, 06:00:40 AM »
Hello - I need to cycle a small pump on and off at intervals defined by the operator.

I tried using two timers to alternate on/off and the PV command.  I have no issues changing the PV value of the timers, however the results are inconsistent, meaning the output does not cycle on and off in a precise manner.
 
The cycle time is between 1 and 5 seconds and I?m using a regular timer.  Should I try using a high speed timer?
What is the best way to accomplish this?
Thanks in advance.


garysdickinson

  • Hero Member
  • Posts: 502
  • Old PLC Coder
    • View Profile
Re:Pump Seq
« Reply #1 on: February 26, 2012, 06:06:50 PM »
Hi,

I've have a couple of questions.

When you say that the "output does not cycle on and off in a precise manner", how big an error in cycle time are you seeing?

How much of an error in cycle time can your application tolerate?

Can you give me a hint of the code that your are using?  

I'm a little concerned about your reference to "PV" or present value.  

If you are using timers, you may really want to be changing the "SV" or set value.  The SV is the value that the TIMER is loaded with when it is made active. If you change a TIMER's PV this may change the time period for the current cycle, but the TIMER will reload with the SV on the next usage.  

Look at the SetTimerSV and the GetTimerSV (n) statements change or examine the SV for a given timer.

I have more questions, but this should get the dialogue going.


Gary D.

rbatta

  • Newbie
  • Posts: 11
  • I'm a llama!
    • View Profile
Re:Pump Seq
« Reply #2 on: February 27, 2012, 05:39:11 AM »
Hi Gary,

Thanks for the reply.  I'm using a T100MD+r49 PLC.  My first attempt was to use two lines of ladder logic.  The first line closed the output and starts timer1.

When timer1 expires, it starts timer2 on the second line, which opens the circuit on the first line (killing the timer and opening the output).  When the second timer expires, it re-initiates the timer1 and the process starts over again.

Timer1 serves as my "on time" and timer2 serves as my "off time".  The timers are set to the same interval (50% duty cycle).  While this was running, I noticed a significant performance impact on the PLC.

I also tried using a sequencer with similar results:

Observing the Output LED while the process was running, I see a very rapid double-blink, then off for the appropriate duration, back on (double-blink again), then solid for the appropriate duration, etc

I sorry if I'm not explaining it very well ? but I expected to see a smooth on/off pattern and I'm not getting that.

The pump being commanded needs to be accurate within 500ms.  I double checked my code, I am using the SV command (not PV).

I feel like I'm missing something obvious.



garysdickinson

  • Hero Member
  • Posts: 502
  • Old PLC Coder
    • View Profile
Re:Pump Seq
« Reply #3 on: February 27, 2012, 09:21:30 AM »
Ok,

This is a snippet of ladder logic that I have used for a similar application.  It uses 2 TIMERS, one determines the ON time the other determines OFF time.  The RUN input starts/stops the whole oscillator.

You should have no problem achieving a timing accuracy of 5+/- 0.5 seconds with the the T100MD.

Try this code.  If you are still having problems, I'll ask more questions.

Gary D.
« Last Edit: February 27, 2012, 09:22:06 AM by garysdickinson »

rbatta

  • Newbie
  • Posts: 11
  • I'm a llama!
    • View Profile
Re:Pump Seq
« Reply #4 on: February 28, 2012, 04:56:36 AM »
Eureka!

I found the error in my ways.  The ladder logic I was using initially was near identical to what you had suggested, so I stepped back from the trees to see the forest.

I had a .5 clock that triggered a custom function to update all of the variables read by my HMI software.  In that custfunc, I was updating the Set Timer SV value.  So every ? second the timer was getting updated, causing the fluctuating results.

My new plan is add the update SV command in each timer.  This way the active timer would update the inactive timer.

THANK YOU!!

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3171
    • View Profile
    • Internet Programmable PLCs
Re:Pump Seq
« Reply #5 on: February 28, 2012, 12:37:27 PM »
Is there a need to keep changing the SV all the time?

Note that you can also start a timer with different set time without using the SETTIMERSV. All you need to do is to assign a present value to the TIMERPV[n] and clear its contact and it will start counting down and turn on its contact when time out.

See this link:

http://www.tri-plc.com/yabbse/index.php?board=2;action=display;threadid=1046

Email: support@triplc.com
Tel: 1-877-TRI-PLCS

garysdickinson

  • Hero Member
  • Posts: 502
  • Old PLC Coder
    • View Profile
Re:Pump Seq
« Reply #6 on: February 28, 2012, 12:47:10 PM »
I, too,  worry about the need to change the TIMER SV often.  My concern is with how the SV are stored in the PLC.  I am worried that these are stored in an EEPROM and there is a danger that you may wear out the EEPROM by rewriting these values over and over.

Another alternative is to not use the ladder logic TIMER mechanism and do the work with custom functions.

The following shows how you can get the same basic behavior without the use of the ladder logic TIMER mechanism.  This approach may fit better with your HMI and it skirts around my concern with EEPROM, for the most part.

The following custom function, InitPumpCycle is invoked once with the 1st. Scan contact. This function sets up the initial values that define the pump ON/OFF times in 0.5 second units.

' InitPumpCycle - Set up Initial values for variable duty pump mechanism
'

' The next 2 varaibles hold the On/Off SetValues to be used to load
'  the CycleCntr variable.  
'
' The OnTimeSV and OffTimeSV variables are initialized on power up. These
' varaibles can be changed by your HMI code and the changed variables will
' be loaded into CycleCntr by the CheckPump function at the correct time
'
OnTimeSV = 10
OffTimeSV = 5???????????????'
??????????????????
' This variable is used as a down counter for the current phase of the pump
'
CycleCntr = 0

[/color]

This custom function, CheckPump is run every 0.5 seconds using "Clk:0.5s" special contact. RUN is an INPUT that is used to determine when the PUMP is to be cycled ON/OFF or just left off.  You will notice that only a single variable, CycleCntr is used for both the ON and OFF timing.  


' CheckPump - Custom function to handle variable duty cyle PUMP OUTPUT
'
IF TestIO(RUN) = 1
 ???' Pump is to be cycled
???'
???CycleCntr = CycleCntr-1?????????' Decrement
???IF (CycleCntr <= 0)????????????'  and check counter

??????' CycleCntr has hit 0
??????'   Change ouput state and
??????'   reload CycleCntr with the correct value
??????'
??????ToggleIO PUMP

??????IF (TestIO (PUMP) = 1)
?????????CycleCntr = OnTimeSV
??????ELSE
?????????CycleCntr = OffTimeSV
??????ENDIF
???ENDIF
ELSE
???' Pump is to be stopped
???'
???CycleCntr = 0???
???CLRIO PUMP
ENDIF
[/color]

Please note that the example takes advantage of the #Define to assign a locations in the DM[] array to the variables named OnTimeSV, OffTimeSV and CycleCntr.

#???#Define Name???Value
1???OnTimeSV???DM[1]
2???OffTimeSV???DM[2]
3???CycleCntr???DM[3]
[/color]

If you'd like a runnable version of this test code, just email me. In my user profile is my email address.  I can't put my email address in the body of this post because the YaBB software considers my email address to be obscene.

Gary D.
« Last Edit: February 28, 2012, 01:33:03 PM by garysdickinson »