Sign in to follow this  
Followers 0
Sidewaze

Programming help

17 posts in this topic

Hello, My name is Scott and I'm an electrician with AB PLC experience for trouble shooting and minor changes. I've always wanted to get deeper into programming but never really had anything for me to get into. I've recently aquired a 5/03 and a small rack with some I/O and have a home project I want to do. I'm having some issues with programming my application. What I have is four powerheads that I want to run different routines triggered by the realtime clock. For example say at 5 am I want ph 1&2 to alternate with 3&4 every 3 sec for an hour. Then say at 6 am 1&4 with 2&3 for the same base plus different routines through out the day. Now I've been able to figure out how to start the routine and use pulsing timers and start the second but when I test the program and it cycles from first to second it works. Now when second routine finishes and I try to run run the first routine just toggling the latch bit the timers work but the outputs don't fire. Now I can go to the second routine and latch the bit and the outputs work. Is there a command I need to put between routines or should I use sub routines. Now I tried using a subroutine but not sure I'm programminng right and reading the AB help doesn't really clear it up. Just looking for some direction as to the best way to program this project. Thanks for any direction in advance. Scott

Share this post


Link to post
Share on other sites
Put your plan on paper first, list the states or steps of operation for your system, and then we can help you choose a good programming approach.

Share this post


Link to post
Share on other sites
Thanks for the replies. I will try to export what I have come up with shortly. He is my intentions I recently setup a 180 gallaon saltwater reef aquarium and want to create different currents through out the day. So I have four powerheads in the tank that I want to alternate in different patterns. Now there are canned packages the I can buy but I'm still locked into their parameters. I was able to come by a small slc setup for cheap and this is when I thought here's my chance to learn. This is what I have come up with for the day 5am PH1 & PH2 alternate with PH3 & PH4 every 3 sec for one hour 6am PH1 & PH3 alternate with PH2 & PH4 every 3 sec for one hour 7am PH1 & PH4 alternate with PH2 & PH3 every 3 sec for one hour 8am PH1, PH3 & PH4 on 12pm PH1,2,3&4 on 7pm PH1,2,4 on 10pm PH1,3,4 on 3am PH1,4 on Then I can play from there I would eventually like to learn the sequencer to play with different patterns. Thanks for any guidance I've been told you have to think differently when programming.

Share this post


Link to post
Share on other sites
Basically what you need is a sequencer. Okie is right, put it down on paper. I usually use a spreadsheet. In your case my spreadsheet would look like this: Hour PH1 PH2 PH3 PH4 3 X X 5 Xa1 Xa1 Xa2 Xa2 6 Xa1 Xa2 Xa1 Xa2 7 Xa1 Xa2 Xa2 Xa1 8 X X X ** Same function. You can combine in one rung or leave separate for future changes 12 X X X 19 X X X ** Same function. You can combine in one rung or leave separate for future changes 22 X X PH1 & PH2 (Xa1) alternate with PH3 & PH4 (Xa2) every 3 sec for one hour PH1 & PH3 (Xa1) alternate with PH2 & PH4 (Xa2) every 3 sec for one hour PH1 & PH4 (Xa1) alternate with PH2 & PH3 (Xa2) every 3 sec for one hour The top row, columns PH1 - PH4 represent outputs. X=True, On, 1, whatever your used to. The first column (Hour) is the step. To me, the steps would look like this: If Hour is >= 3 and < 5 then Step 1 The SLC doesn't offer structured text so this would be a compare rung using GEQ and LES If Hour is >= 5 and < 6 then Step 2 If Hour is >= 6 and < 7 then Step 3 If Hour is >= 7 and < 8 then Step 4 Etc, etc. The steps are BOOLs. B3:0 in SLC speak for instance I would define the steps first. Then assign each step to an output Steps 2,3, and 4 are the only "odd" ones and there isn't much to that logic. Build yourself a 1.5s timer that latches a bit. Call it 3sON or whatever. The rung would look like this NOT 3sON tells the timer to run. Timer DN LATCHES 3sON Now build another 1.5s Timer that looks like this 3sON TRUE tells the timer to run. Timer DN UNLATCHES 3sON So now 3sON toggles Off and On every 3s Step 0 -----------------------(PH1) and (PH4) Step 1---3sOn--------------(PH1) and (PH2) Step 1---Not 3sOn--------------(PH3) and (PH4) Step 2---3sOn--------------(PH1) and (PH3) Step 2---Not 3sOn--------------(PH2) and (PH4) etc, etc The cool thing about this is that it gives you a lot of insight into ONE way that a sequencer can work. In the gas processing business we have 2 an 3 bed (sometimes 4) dehydration system sequencers with all kinds of interlocks and 20 or 30 steps. Fundamentally they don't look any different than this. The CLX makes it a lot easier but for your purpose the 5/03 should work great. You could make the 3s toggle timer PRE values a tag so that you can change the toggle delays on the fly. Edited by Michael Lloyd

Share this post


Link to post
Share on other sites
PS- I suspect that the problem that you wrote about in your first post is that you duplicated an output or possibly a One Shot (positive edge trigger, whatever) bit.

Share this post


Link to post
Share on other sites
Hi Scott, Michael's advice is sound, although I would approach the problem utilising a built-in instruction that is often overlooked. Have a read of the Instruction Help on the SQO instruction. I believe this will help to program the basic function of choosing which powerheads will operate at any time of the day. I too did a spreadsheet, a very useful visualisation tool, but I did an entry for each hour of the day.... I followed your sequence, placing an X where I wanted PH's to run (we'll deal with the alternating PH's later). Now you've read the SQO help..... It is "usually" used in a "clocked" manner, meaning that each time the rung changes state false to true, the SQO advances to the next bit pattern to output. But we can also use the SQO as like a "lookup" table, by using the SLC's Real-Time-Clock "Hour" value directly, and MOVing it to the SQO instruction's .POS register. All you then need is a pair of timers for your "alternating" powerheads, and a bit of simple logic to enable (or inhibit, *hint) the pumps as required at 5, 6, and 7 a.m. 7 or 8 rungs of code does the whole job. Feel free to ask questions....

Share this post


Link to post
Share on other sites
Adding to what daba says, I actually prefer rolling my own sequencer so that I can separate the stepping mechanism from the bit pattern file handling. The SQO is an MVM with indirect addressing and a built in counter, and would probably be a perfect choice for you, since you will be advancing in one direction one step at a time. You could drive the SQO instruction with the real time clock or timer(s). I like Michael's solution too, and your SLC should support the LIM instruction (LEQ, and GEQ combined into one block). The advantage to his is that when restarted, as long as the clock is right, it will run the correct "step". With the SQO, you would have to add code to get to the correct step number if it needs to match a real time clock based pattern. You would only have to do it following a power outage though, and those might be rare, nonetheless, it is a drawback.

Share this post


Link to post
Share on other sites
...SQO instruction Ohhhh... I like that one a lot. I never had need for it back in my SLC days. Mostly because I spent most of my time with the S5 and S7 back then. Good stuff though

Share this post


Link to post
Share on other sites
Poke the RTC hour into the .POS of the SQO control block and all is well. There's no need to "advance " or "clock" the SQO at all. Manipulating the SQO .POS register is just like a "look-up" table. Edited by daba

Share this post


Link to post
Share on other sites
So why not just poke the pointer into the MVM or MOV since I don't think we're masking outputs here? Granted you would have to roll your own DN bit...:) And that would limit the resolution to whole hours, which perhaps meets the spec, but using LIM blocks on the hour and minutes gives you 60 times the resolution....and you don't need a cheat sheet or display special to interpret and program it, just an on/off schedule for each output. Don't get me wrong, I like sequencers, but for systems with more devices and more steps. Seqencers allow you to pack an incredible amount of control information into an itty bitty living space. We used them with 16K 8-bit ISSC PLCs to control very complex tire assembly machines. No way could that controller run that machine with any other style of logic, but there were more than 150 outputs and about 80 steps some of which were optional. For complex assembly machines with lots of inputs, I love the SQI instruction. The SQI gets placed in charge of the step change, and its output bits are typically defined directly from real world discrete inputs. If you want to know which of the three limit switches changed states last when it's too fast for the naked eye, or you want the operator to see the machine pause or fault and see a diagnostic window that tells them exactly which sensors or other conditions the machine is waiting for...the diagnostics given by input sequencing are phenomenal in complicated high device count machines. and you don't have to touch the logic if you replace the sequence data for changes in the product. Paul Edited by OkiePC

Share this post


Link to post
Share on other sites
OK, using MVM simplifies this, SQO is overkill** - you can set-up your Powerheads "enable" bit patterns into a bit file, and indirectly address the data you want to MVM to the output card using the SLC's "RTC-Hour" (S:40) This reduces the solution to just 5 rungs of code. ** However, the SQO instruction is available on all A-B platforms - some don't support indirect addressing. And since there are only four outputs, we will certainly be using a mask, otherwise we wouldn't be able to use the rest of the output card Horses for Courses - no need for a more complex solution when a simple one meets the specifications, and works perfectly. Edited by daba

Share this post


Link to post
Share on other sites
Ok, This is way beyond my skills yet. I'm not sure even what I should be doing now. Maybe I need to save for a class. Sorry guys

Share this post


Link to post
Share on other sites
Sidewaze - you were asked to post your file. That would have provided the basis, along with your description of the sequence as you see it, for a quick solution. But you posted on the 20th of January and now it's February and you are no further along. We can't see where you have a problem without seeing your program. If you are unsure HOW to post a program (see 'Help with attaching files') just say it. Anyone would be glad to help. But if you are abandoning this for now then ok.

Share this post


Link to post
Share on other sites
I know I did and planned to but unfortunately I was ill for a week and life got in the way. I was just reading some of the solutions and is a bit intimidating. I'm not abandoning and will post later but its simple and by no means to the level others have mentioned. You say lay it out on paper which is fine but not sure how I transfer that to logic. Anyway I will post later today and go from there. Thanks for the help I just feel intimidated is all.

Share this post


Link to post
Share on other sites
I've searched but can't locate "Help with attaching files". Can you point me to the location so I can read process.

Share this post


Link to post
Share on other sites
Do this - the result of programming the SLC5/03 is an RSS file. Using Windows, right click on the file the 'send to' Compressed (Zipped) folder. When you make a new post here click the 'Browse' button below the text window and find the 'zip' file on your computer. Click 'Open' and the zip file. The click the 'Attach This File' button. When you finish your post ('Add Reply') the zip file will show up as well. We can then open it and see your work.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0