Jump to content

Recommended Posts

I'm trying to write a program for a Samba to turn a motor on and off.  I need to be able to input an on time and off time on the HMI and for it to run in a loop.  I got that far as bastardized as my code may have been, but I need the timers to pause and not reset if they stop the motor for a period of time.  He also wants to be able to set a TOTAL on timer that only counts the time while the motor is running.  The bulk of my experience has been with Allen Bradley and while I love the Unitronics product, I'm having a little trouble adapting. Thanks for any and all help. On the one I attached I managed to put a counter in where they could set a number and it would stop after that number was reached, but the way I'm writing it doesn't allow it to be "paused" for repair or inspection without resetting the counters.  

DynoWithWorkingCounter1.vlp

Share this post


Link to post
Share on other sites

Just a little bit of time to devote to this right now. I'll try to help more later.

21 minutes ago, Roho said:

He also wants to be able to set a TOTAL on timer that only counts the time while the motor is running.

I would not use a timer for this, merely increment a register every second of run time (or use SB 7 if you need more precision).

image.png.0b2cece2732488a0dd9b6f040d5e2c84.png

You can then manipulate MI 0 (oops, I see now that I mistakenly used MI 0 instead of ML 0, which would be less likely to overflow) to display on the HMI in various ways or use for calculations.

If you need timers to pause and not reset, then change your logic to use TA timers instead of TD timers, or use an incremented register or counter as I did above for the total run time.

Share this post


Link to post
Share on other sites

I had checked the help file, but I couldn't really find anything either.  I'm sorry to bother ya'll, I'm just fumbling my way through this and realized a little help would be necessary.  Thanks for any and all help you can give.

Share this post


Link to post
Share on other sites
2 hours ago, Roho said:

I'm sorry to bother ya'll, I'm just fumbling my way through this and realized a little help would be necessary.  Thanks for any and all help you can give.

Help is what we're here for, especially when you're attempting to work your way through it and not just asking for someone to write your program for you. I'm not sure why the Timer section of the help file got lost, but I'm sure Cara will get it fixed. I recommend not using the Beta version of the software for your first program.

Were my suggestions on how to deal with the timer issues clear? I'm attaching a pdf of the Timers section from a previous version of VisiLogic that should help you understand the 3 different types of timer that VisiLogic offers. While it's fewer than the 15,000  :) different types A-B offers, these 3 (TD, TE, & TA) WILL get every job done with some careful thought.

Timers.pdf

Share this post


Link to post
Share on other sites
11 hours ago, Flex727 said:

Were my suggestions on how to deal with the timer issues clear?

Definitely helpful.  You're right, A-B has your timer needs more than covered, and you'd think they would be harder and more complicated to use, but the new standard is the 3 timer setup, so I guess it's time to figure it all out.  Thanks for the help.  I don't have it yet, but I'm workin' on it.  

Share this post


Link to post
Share on other sites

Ok, I've gotten a very long way, and the way I got there may not be the best way, but it works.......ALMOST!!! It does everything I currently need, except for being able to hit stop when the motor is off.  You hit stop while the motor is running and it pauses the timer beautifully, you hit stop when the motor is off and the off timer just keeps on going.  I understand why, what I'm having trouble with is finding a solution that works anywhere in the cycle.  As usual any and all suggestions are welcome.  Thanks.

DynoWithWorkingCounter3.vlp

Share this post


Link to post
Share on other sites
49 minutes ago, Roho said:

you hit stop when the motor is off and the off timer just keeps on going

I presume that the only reason you care is that next time you hit START you want it to stay stopped until the off timer completes the previous cycle. If that's the case, given the logic you currently have in place, it looks to me like the easiest way would be to add a latch bit that indicates the status of the last press of the start or stop button, as follows:

image.png.77b12e089bef50724ca732882b9892ac.png

Share this post


Link to post
Share on other sites

It's working!  I had to start that latch bit in a set position so it threw me for a second, but it's doing what I need.  Now to write an inc to count just the motor run time and figure how to display it on the HMI and it's golden.  Thank you a million times over!!!!

Share this post


Link to post
Share on other sites

While it is alot closer to perfect, I'm still having a couple issues I'll post tomorrow as I'm sending this from home and don't have the file. One problem is how to reset the actual timers. They start back at the last stopping point no matter what so I need to figure a way to zero them. Also it's now starting with the off timer as opposed to the on timer, which I think it always did, but now it isn't running itself down before I hit start. I'll explain more tomorrow.

Share this post


Link to post
Share on other sites

I'm awfully close!! 2 problems.

1: I can't get the total test time from the incremental to the display in a usable format.

2: On initial startup, the off counter starts first. Plus if there's a time in either counter, it runs that time and then starts the new time.  If you run a full cycle and don't change anything, it works perfectly each subsequent time, but if you do a fresh start or change a time it causes a problem.  I'm not sure how else to describe the problem, but I tried the reset idea above, and nothing would run.  There seemed to be a conflict due to the reset timer bit used earlier in the program.  I'm excited that I'm close, but frustrated because it's still causing me grief.  Thanks again for all your help.

DynoWithWorkingCounter5.vlp

Share this post


Link to post
Share on other sites

No time right now to analyze your logic, but I'll quickly show you how I do #1:

image.png.017cef12908e23717e7b782f06374f86.png

Also, you need to change the timer display to Preset and adjust the Format:

image.png.72ae2fc9e183eea7260ee5032796790c.png

If your Total Test Time will exceed 24 hours, you'll need to do a bit of math to separate out and display the number of days.

Share this post


Link to post
Share on other sites

A little bit of advice - if you hit an impasse, just try different things - you won't break the PLC. Make your best guess, implement, then go online with the PLC and see what is happening. If that doesn't work, make an adjustment and watch what happens. You'll home in on the solution eventually. No one always knows how to solve a logic problem on the first go.

Share this post


Link to post
Share on other sites

I've been playing best guess like crazy.  I've gotten through some of it, now I see I needed another function for the timer to work properly.  You've been a big help.  You deserve that top guru title!!!

Share this post


Link to post
Share on other sites

The timer is working flawlessly now, thank you so much.  I'll figure this other little glitch out in due time. 

19 minutes ago, Flex727 said:

 

 

19 minutes ago, Flex727 said:

 

image.png.017cef12908e23717e7b782f06374f86.png

 

 

 

Share this post


Link to post
Share on other sites
On 2/22/2019 at 12:20 AM, Flex727 said:

I'm going to hit up @Cara Bereck Levy one more time just in case she missed it. It looks like the Timers Help section was lost in the update to 9.8.79. Didn't this happen once before?

Yes--it has happened before--I fixed it.
I'm really sorry--I tried something this time that I hope will prevent this from ever happening again.  .chm Help is a Microsoft invention, and the compiler hasn't been updated--or bug-fixed--since 2012. The database behind the Help sometimes corrupts, and loses objects--even though it compiles without error. I have a feeling it is due to nesting...anyway, I rebuilt some stuff.  Hope it fixes the issue once and for all.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...