Programming Help

iWatchman

Member
Join Date
Oct 2016
Location
Oklahoma
Posts
5
Greetings,

So I’m taking a mostly self-taught PLC programming class and I have been presented with a programming activity that includes creating a 24-hour clock that records the time (i.e., hours, minutes, seconds) of when a pushbutton is pressed (signaling an emergency condition has occurred). The program must be able to record up to three interruptions during a 24-hour period. The activity includes the use of a timer, counter and a move instructions to create a 24-hour clock that can record up to three interruptions.

I have created simple programs using timers and counters and have studied up on the MOV instruction set, but I must say this task is a bit of a jump from my current understanding. I’m using RSlogix Micro Starter Lite with a Micrologix 1000 Processor (Allen-Bradley SLC 500 series PLC trainer). Any help would be appreciated especially some programming examples, of which I learn the best from.

Thanks
 
Do you have anything yet? if yes post what you have... if not give it a try and we will help once you get started

You have the basics, when the button is pushed move the values to a register and hold them until needed and you can recall them
 
Welcome to the forum.

First thing first.

1. What does your assignment ask you to do?
2. Think about what you need to do.
3. Write out what has to be done in simple terms and reread.
4. Expand on what you have written by adding pushbuttons, timers, counters...
5. Go through each step and see if it makes since.
6. Code what you have written.

If the code is too difficult, code one part at a time and get that working,
then expand the next step. By breaking the program into smaller parts, you can get a handle on the big picture.
Add comments to your program.

If you are still having trouble, zip the program (forum rules) and post it.
We will be more than willing to help, BUT you must put forth some effort first.

Not being cruel, it won't do you any good if someone does your work for you.
when you get into the real world, your boss will find out quickly if you know what you are doing.

james
 
First thing - write out the logic / algorithm in its basic sense & work from there. Translating the written logic to PLC logic.

Good luck, and enjoy the learning process. It will make you a better Software Emgineer!
 
Do you have anything yet? if yes post what you have... if not give it a try and we will help once you get started
You have the basics, when the button is pushed move the values to a register and hold them until needed and you can recall them


I don't have anything. I have no idea what instruction sets are used to create a "time-clock" that can be referenced. But I totally get what your saying about "when the button is pushed move the values to a register and hold them until needed and you can recall them". I just haven't a clue how to make that happen.
 
If you're using a MicroLogix 1000, I think you will have to build a clock as there is no real-time clock available. You will have to use a 60 second timer, a minute counter, and an hour counter. Write the values of these timers and counters into integers and use logic to capture the current value of those integers when the button is pressed.
 
If you're using a MicroLogix 1000, I think you will have to build a clock as there is no real-time clock available. You will have to use a 60 second timer, a minute counter, and an hour counter. Write the values of these timers and counters into integers and use logic to capture the current value of those integers when the button is pressed.

This is all true. Additionally, the clock you create is not going to be nearly as precise as what you might expect.

It is advisable to not reset the 60 second timer each time it is done, rather set the preset for a value higher than 60 seconds and then use compare instructions to trigger logic to increment the minute counter as subtract sixty seconds from the accumulator. This will have the same effect but will retain any over run that has occurred. Also, use the finest timer precision available. I believe that will be a 0.01 second timebase for your processor. So your compare would be to check if T4:0.ACC > 6000, SUB T4:0.ACC 6000 T4:0.ACC, CTU C5:0, assuming that C5:0 is your minutes counter.

This might be beyond what the instructor expects you to do, so feel free to ignore this idea and keep it basic. In the real world, you won't use that controller for this application, you'll get one with a real time clock. It's still a good learning exercise though.
 
Last edited:
OkiePC,

Couldn't he just use and XIO instruction tied to the DN bit of the minute timer to reset the timer? Or would that be inaccurate as well? The inaccuracy is due to processing time?
 
Last edited:
It will be inaccurate no matter what you do. If the DN bit resets the timer then you can be sure that the timer accumulator has met or exceeded the preset. The method I described and used to preserve any overrun will only help a little bit.

It can also be helpful to set a timer with a 1.0 second timebase and let it run to 30000 seconds. Then use some math to calculate the number of elapsed seconds and minutes.

For a classroom exercise, being concerned about the clock being off by a few seconds a day is probably moot.
 
If you're using a MicroLogix 1000, I think you will have to build a clock as there is no real-time clock available. You will have to use a 60 second timer, a minute counter, and an hour counter. Write the values of these timers and counters into integers and use logic to capture the current value of those integers when the button is pressed.

Thanks for confirming that jrsnydley, I was going crazy looking through all the instructions and not finding a real timer solution. Plus I have the Starter Lite version of the program which obviously offers fewer options than the RSlogix 500 version. I will try what you suggested.
 
Plus I have the Starter Lite version of the program which obviously offers fewer options than the RSlogix 500 version.

Not a lot... its more based on the PLC, if you choose a 1000 you have fewer options then if you choose a 1100, same if you have the full version of RSLogix 500 if you choose a 1000 you would be limited on the instructions verse a 5/05, this has absolutely nothing to do with your project but I thought it should be said :D
 
Not a lot... its more based on the PLC, if you choose a 1000 you have fewer options then if you choose a 1100, same if you have the full version of RSLogix 500 if you choose a 1000 you would be limited on the instructions verse a 5/05, this has absolutely nothing to do with your project but I thought it should be said :D

Thanks. That might explain why some of my instruction sets like RTC and RTA are showing but not available.
 
This is all true. Additionally, the clock you create is not going to be nearly as precise as what you might expect.

Maybe, maybe not.

At the Wentzville, MO GM plant I did the scheduling program for the Paint shop on a PLC-5.

I was given a marker pulse from a Simplex time clock once per hour (an input that would come on at the top of the hour for 3 seconds IIRC), with a longer marker pulse at midnight (8 seconds maybe? it was in '94, so it's been awhile). These marker pulses were there to regularly correct my time. The marker pulses were nothing more than an input to the PLC.

Using a 60 second timer was so bad that I had 2-3 seconds that would have to be corrected at each hour. Not acceptable.

So I used an STI set to 985 milliseconds that simply incremented the current time count by one and then jumped back out of the STI.

I came up with the 985 by running the STI at 1000 ms for a day and then figuring out the error to trim it. It was close enough that the hour markers weren't needed and would be off by less than a second at the end of the day. Which was good since to the best of my knowledge Maintenance never did run the input from the Simplex to my PLC.

The rest of the program divvied that up into minutes, hours, days, months, and years. It also started the line, stopped it, and had an HMI attached for setting up schedules. The only manual intervention was to set the beginning day of the week for Jan 1st each year.

And since I was in the HMI anyway, I had it wish me a Happy Birthday every year. :)
 
...
So I used an STI set to 985 milliseconds that simply incremented the current time count by one and then jumped back out of the STI.

I came up with the 985 by running the STI at 1000 ms for a day and then figuring out the error to trim it. It was close enough that the hour markers weren't needed and would be off by less than a second at the end of the day.


Now that's the way to do it if you have no choice but to roll your own clock. The ML1000 supports STI if I recall, so the OP could use that concept.
 

Similar Topics

Hi all, i am the new controls guy at the plant and i have inherited a pc from the previous controls guy with Siemens tia portal version 16 and 17...
Replies
20
Views
919
Hi can you help, have a book stitching machine with collates pages in 8 stages. I have installed a camera system that will give an input to...
Replies
24
Views
1,907
I don't have much experience in programming. I can do simple configuration. it is like this. i want to add something to the existing ladder...
Replies
39
Views
6,220
Hello there, I'm practically new to the PLC world, I'm quite familiar with Siemens TIA Portal but I'm currently tasked to program Schneider PLCs...
Replies
5
Views
1,867
Hello All, As you can guess by the title I am a total noob to programming PLC's. So my problem is that I have an old Pallet wrapper that uses an...
Replies
21
Views
4,930
Back
Top Bottom