professor_jonny

step program

4 posts in this topic

I'm using a cp1l  plc and are currently using step/ step next functionality with in a program and it works but i have run out of programming space and what i want to do is break down the program into blocks and recall them from with in a step or something simular so I dont need to rewrite code multple times.

problem is you can not have steps within steps.

will i be able to acomplish this with subroutines blocks or some sort of stack pointer with indirect adressing or something

would any one be able to shed light on a possible solution?

Share this post


Link to post
Share on other sites

I always like to build my own sequencer.  Pick a register that holds the sequence number.  when you start the machine move a 10 in that register, when some condition is met, move a 20, then 30 and so on.  You can then have all of your outputs turn on or off based upon which step you are on.  If between steps 30 and 60, turn on output 1, repeat for all output conditions.

Then if you have a sub process, create a second sequence register for that process.  Have it be 0 when not running.  When you reach the step in the main process that makes the sub process run, then move a 10 in the sub process register to kick that one off.  Have the main sequencer wait (if that is the desired result) until the sub process is complete before moving to the next step in the main.  When moving to the next step in the main, move a 0 in the sub sequence counter.  

Hopefully this makes sense, but if not, ask some follow up questions.  

1 person likes this

Share this post


Link to post
Share on other sites
34 minutes ago, Michael Walsh said:

I always like to build my own sequencer.  Pick a register that holds the sequence number.  when you start the machine move a 10 in that register, when some condition is met, move a 20, then 30 and so on.  

I have made a sequencing program as such it uses move and compair instructions but it ends ends up taking up more space than the step program as compair is a larger memory footprint than step.

I'm asuming you mean something like the attached?

The other problem I have is that im trying to remain backwards compatable with the cpm1a and it does not as such have an inline function just CMP with cpu flags and it gets long winded and confusing.

test.cxp

Edited by professor_jonny

Share this post


Link to post
Share on other sites

Yes, your test program is very much like what I am talking about.  As far as the CPM1A is concerned, you are right, you would have to use the CMP instruction and the associated flags.  I don't really have a suggestion that addresses all of your parameters.

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