Sign in to follow this  
Followers 0
Elizabeth86

I can't get my simple timing code to work

3 posts in this topic

Hi I have built this code to wig-wag on and off at 2 seconds using a timer. I now need to make it flash 5 flashes per/sec by switching input x3. So I have been doing a bit of research and found if I use M8028 I can achieve this, but my code doesn't work. Could someone please take a look and point me in the right direction.

Share this post


Link to post
Share on other sites
homework eh? if you set M8028, some of FX timers will have 10ms resolution if i understand correctly you want each of your outputs (Y1, Y2) to work in bursts of pulses when X3 is on. when X3 is off, outputs are simple alternating 2sec pulses. proper way to accomplish what you want (or anything else) is to make program modular, for example: 1. create 2sec clock (clk1) 2. create 200ms clock (clk2) 3. then for each outpur create rung with logic that controls it although it is possible to create long and messy code using only few lines, that is a poor style and hard to maintain. my suggestion is to break it down. tip, consider combining clk1 and clk2 and X3 into a condition to drive Y1 (then do the similar thing for Y2 in another rung) also, timers are usually limited resource (specially in smaller PLCs). excessive use of timers is frawned upon when same task could be accomplished withouth or with few timers. one such case is repeating patterns with fixed timing. and there are also internal clock bits for this very purpose. but since this is homework, efficiency is not top priority, you need to demonstrate that you can produce specified signal using any means you know. of course there are always different ways to get job done, in this case i would also consider/accept/appreciate solutions using counter, bitshift (Johnson counter), fifo, lookup tables, etc. nothing like watching professor scrath his head...

Share this post


Link to post
Share on other sites
long time since I worked with an FX1S but from memory only timers 32 and above could be redefined as 10mSec - try using TC32 & TC33 instead (although I could be wrong).

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