Sign in to follow this  
Followers 0
Kitwe

PLC newbie needs help! CPM1 Timer within interrupt routine

5 posts in this topic

Totally new to PLC's so thought I would learn using a CPM1. I have written a small programme that should activate a timer on an input interrupt, I am using a push button as the input interrupt and the timer should count down from 500 when activated, however the timer will only count down by one unit on an interupt i.e from 500 to 499 then 499 to 498 etc - what am i doing wrong? See attached ladder drawing - BTW using Syswin 3.4. Richard

Share this post


Link to post
Share on other sites
Try this - much easier. RESET will reset the channel to 500 on a rising edge - COUNT will decrement the channel on a rising edge.

Share this post


Link to post
Share on other sites
Hi Bob, Thanks for the reply, what I want to know is why my programme won't work. Have I set up the interrupt correctly? - do timers work within an interrupt routine? It works OK if I use a digital i/p to fire the timer. Richard

Share this post


Link to post
Share on other sites
Interrupt programs interrupt the main code, run one time and then return to the main code. So no, your code will not work like this. The timer needs to be scanned in the code to function. That is why each time you run the interrupt it only decrements by 1. Your code has turned it into a counter rather than a timer.

Share this post


Link to post
Share on other sites
Hi Michael, Thanks for that, that explains it. I took the timer out of the interrupt routine and used a set bit in the interrupt routine to fire the timer. Steep learning curve!

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