Sign in to follow this  
Followers 0
AdamK

Simpler way to control basic timed I/Os in Sysmac

2 posts in this topic

First post here. I've been learning Sysmac over the last month or two. Currently using a NJ301 with Omron ECC I/Os and a G5 servo and drive (R88D-KN10H-ECT Servo Drive, R88M-K1K050H-S2 motor). If anyone has any questions about that setup, I'd be happy to answer them. I'm posting to see if any of the experts here have a cleaner way to write timed digital outputs in Sysmac, other than what I have come up with. It seems like there should be an easier way. The application is simply turning on an output for a set amount of time to drive a pneumatic system. Right now, I have done this by using a switch (SwOne), a TON delay timer, followed by a TP timer which lead to the outputs. This is followed by this structured text: //If the counter value has not reached set value, keep SwOne on IF CounterVariable1 < 5 THEN; SwOne:=TRUE; END_IF; //If the counter has passed the set value, turn off SwOne IF CounterVariable1 > 5 THEN; SwOne:=FALSE; END_IF; //If the on timer has finished, turn off SwOne to reset the cycle //And add 1 to the counter variable IF ET2 = T#50ms THEN; SwOne:=FALSE; CounterVariable1:=CounterVariable1+1; END_IF; I also added this code for when the machine initializes to reset the timer after it is finished: //Reset counters to zero if the timer is turned off IF SwOne = FALSE THEN; CounterVariable1:=0; END_IF; Although this works fine, it seems to me there must be a simpler way to do this. Coming from a matlab/simulink background, I remember I could just put in an output with a timer built in. Any ideas?

Share this post


Link to post
Share on other sites
Try using the TP (Timer Pulse) Function block. In ladder it looks like this: Here is the same code in Structured text: TPST(OnCondition,T#3s,Output_Bit,Elapsed_Time); Where TPST is the instance name of a TP Function block as shown below: Of course, you could change the timer value from t#5s to t#50ms as needed. I just set it to a big number to capture my images.
1 person likes this

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