Viktor_k83 Posted January 21 Report Posted January 21 Hi, I'm pretty new to OMRONs and completely new to SYSMAC. I need to reset a daily counter every day at a given time. I read threads I found here, including https://mrplc.com/topic/44831-displaying-a-dayhourmin-timer and as I understood that DT and DOT are different animals in SYSMAC. Also, at first, I didn't want just to compare curr_time with reset_time and wanted to extract HH from the data and compare it with, say "23" hours. But I got lost and can't figure out the structure of TIME and DATE_AND_TIME variables. So as another option I thought I'd just count minutes or hours, compare to 1440 or 24 and then reset at the end of the day (23:59). But then I also don't want to run the cycle every often and a pulse timer, likely, will be needed. Can you share a better and easier way to implement this in SYSMAC? p.s. A basics question - what's the alternative to ABB (L)/(U) bits in SYSMAC? I read that it should be SET/RES but I didn't find the symbols, only SetBits and SetABit. Or should I just latch it physically in the logic. Quote
BE Posted January 21 Report Posted January 21 (edited) 8 hours ago, Viktor_k83 said: I read that it should be SET/RES but I didn't find the symbols, Set and Reset bits are created by right clicking the bit "coil" and clicking "Set Instruction" or "Reset Instruction" (screenshot below. As far as I know there is no keyboard combo. I can't answer the other question right now, as I have to have a play with it first. Edited January 21 by BE Quote
Viktor_k83 Posted January 22 Author Report Posted January 22 1 hour ago, BE said: Set and Reset bits are created by right clicking the bit "coil" and clicking "Set Instruction" or "Reset Instruction" (screenshot below. As far as I know there is no keyboard combo. I tried that, yes, but the SET/RESET menu was greyed out. Quote
BE Posted January 22 Report Posted January 22 55 minutes ago, Viktor_k83 said: I tried that, yes, but the SET/RESET menu was greyed out. That's the wrong spot. Look about half way up, there are "Set Instruction" and "Reset Instruction" options. Clicking either of these will put an S or R in the center of the coil respectively. The "Set/Reset" is used when the PLC is online, so you can set or reset bits. It does have its limitations, but its typically used only for internal bits (ie. not physical I/O - for that you need to use the "Forced Refreshing" options) 1 Quote
BE Posted January 22 Report Posted January 22 9 hours ago, Viktor_k83 said: Can you share a better and easier way to implement this in SYSMAC? Couple of ways I can think of to do this, depending on specific requirements. If it just needs to reset every 24hrs, a self resetting timer would be fine. At the end of 24hrs, the output bit triggers to reset your count, and also resets the timer so it starts again. If you need to set the actual time, then it will be different. Something like the below. Basically it just sets the hours, minutes and seconds based on integers and multiplies these out to get total seconds. Then uses the SecondsToTOD function to create the resetTOD, which is then compared to a trucuated TOD from the PLC. If the time value was going to be fixed (ie. only changed in the program using Sysmac Studio) then it could be simplified a lot more, but this would allow for variables to be changed via a HMI or similar in an 'operator friendly' way. Side Note: The code still simulates correctly with the untruncuated TOD variable in the = function. However the truncuated version allows you to see it working, as the reset bit stays "on" for the full 1 second time period. Quote
Viktor_k83 Posted January 22 Author Report Posted January 22 19 minutes ago, BE said: Couple of ways I can think of to do this, depending on specific requirements. If it just needs to reset every 24hrs, a self resetting timer would be fine. At the end of 24hrs, the output bit triggers to reset your count, and also resets the timer so it starts again. If you need to set the actual time, then it will be different. Something like the below. Basically it just sets the hours, minutes and seconds based on integers and multiplies these out to get total seconds. Then uses the SecondsToTOD function to create the resetTOD, which is then compared to a trucuated TOD from the PLC. If the time value was going to be fixed (ie. only changed in the program using Sysmac Studio) then it could be simplified a lot more, but this would allow for variables to be changed via a HMI or similar in an 'operator friendly' way. Side Note: The code still simulates correctly with the untruncuated TOD variable in the = function. However the truncuated version allows you to see it working, as the reset bit stays "on" for the full 1 second time period. Theoretically, I can start timer with the first production every day and then start counting time, add enough off hours and then reset. It's simple to say the least and until I figure out a more reliable and proper way to do this. Thank you. For the second part, could you upload the screenshot in a better quality here or somewhere else. As it's not readable in this size. Please. Quote
BE Posted January 22 Report Posted January 22 (edited) 1 hour ago, Viktor_k83 said: Theoretically, I can start timer with the first production every day and then start counting time, add enough off hours and then reset. It's simple to say the least and until I figure out a more reliable and proper way to do this. Thank you. For the second part, could you upload the screenshot in a better quality here or somewhere else. As it's not readable in this size. Please. Try that (the website seems to be dropping the quality......) Edited January 22 by BE Trying to get a readable screenshot :) 1 Quote
BE Posted January 22 Report Posted January 22 Just to note, in the latest screenshot, the truncuated TOD isn't on the = function (Line 3), but I have left the trunc function in Line0 as I referenced it in my previous response. Quote
Crossbow Posted January 22 Report Posted January 22 Look halfway up the menu you posted, and you will see SET INSTRUCTION and RESET INSTRUCTION. Those change the coil functions and add the S or R. There are no keyboard shortcuts in the default keyboard, but you can add them. I always used Ctrl+Alt+S and R for mine. The Set/Reset menu you looked at is for use online testing the program to temporarily turn them on or off, not really a force. As for clock, use DATERD and then do a compare like the rising edge of hour being 0 to reset at midnight. DATERD writes all 7 values of the clock. 1 Quote
Viktor_k83 Posted January 23 Author Report Posted January 23 So after watching this video (thanks to Google and its auto-translation): https://www.youtube.com/watch?v=bTXI2E_5IUY I was able to come up with this code as attached. Instead of the HOLD timer (just to hold the check until the reset minute will pass), a flag for "seconds" can be implemented. So in short, DtToDateStruct works like charm and allows to manipulate with its children. But I'd still want to learn how to use Trunc and work with strings. Thank you @BE I'll try to replicate your code and compare both results. p.s. Couldn't find a simple way to increment/"++" instruction. As any TRUE/FALSE switch in simulation increases the standard "+" by random hundreds. Quote
Viktor_k83 Posted January 23 Author Report Posted January 23 Also, to duplicate my message from another forum. It looks like there is a glitch in the software. When you move the instruction to an existing rung with the same instruction ("=") - it first drops the connection. But re-adding or double-clicking the output solves the problem. p.s. Test variables, not correct ones are on the screenshot. Quote
Solution Viktor_k83 Posted January 23 Author Solution Report Posted January 23 Attached is the final version of the daily reset counter that can be set a given time of the day (HH:MM but you're welcome to add secs if needed). Just wanted to post here for the records, hope it helps for anyone looking for OMRON / SYSMAC Studio specifically: Quote
BE Posted January 28 Report Posted January 28 On 1/23/2025 at 1:14 PM, Viktor_k83 said: p.s. Couldn't find a simple way to increment/"++" instruction. As any TRUE/FALSE switch in simulation increases the standard "+" by random hundreds. Right click the PE_FinalCount bit and select "Diff Up". This means it will only be 'on' for a single scan when the variable becomes true (a small 'up' arrow will appear in the contact). It does the same job as the R_Trig function block, but is a bit simpler and faster to code 🙂 1 Quote
Viktor_k83 Posted January 29 Author Report Posted January 29 23 hours ago, BE said: Right click the PE_FinalCount bit and select "Diff Up". This means it will only be 'on' for a single scan when the variable becomes true (a small 'up' arrow will appear in the contact). It does the same job as the R_Trig function block, but is a bit simpler and faster to code 🙂 That's the insight, thank you! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.