Sign in to follow this  
Followers 0
Colin Carpenter

Time and Date Handling

8 posts in this topic

Have just completed a PLC changeover weekend and my eyelids are just starting to recover .......:) Wonder if someone can help me with an area I've never explored before relating to time stamping operations. I have a Q02 PLC that is controlling a process department, and there are 8 tanks that I would like to be able to timestamp when various things happened and display the information on an HMI. I've worked out how to read the date and time information from the Q02 and can see that it puts the values into an array, so I can read the data registers and get the year, month, day date, hrs, mins and day of the week from the 7 data registers. When a process starts, I'd like to be able to create another single data register (string) that contains the date and time so that it can be displayed on the E1101 HMI, in the form "25/02 10:15:32" (or similar) which is a combination of the various time clock registers which were valid at that instant in time. Any advice on functions to use would be greatly appreciated Thanks Colin

Share this post


Link to post
Share on other sites
Since you are using a E1101 and (my guess) E-Designer is it very easy to display the CPU clock. Setup -> Date/Time Format Select your choice of how the time and date should be presented in the panel. Select "Controller 1" as the clock source to be used, and you are ready to go. Edit: Sorry I was to fast and didn't read your post correctly. I think you have to create an Array of integers that you load the time and date to when your process starts. I'd use the BMOVP function for it and use a series of "Analog Numeric" fields to present the date and time for the process start. Edited by Bryll

Share this post


Link to post
Share on other sites
Thanks, I managed to get it sorted with a bit more research. There's a "SECOND" command that you can use to convert the current hours, minutes and seconds from the PLC real time clock into the number of seconds since midnight. (You could obviously do this with some maths as well), and the beauty of the HMI is that you can specify an analogue numeric value as type SECONDS32. This means that I can coninuously run the SECOND command in the PLC to be calculating the number of seconds since midnight, then whenever a process starts or stops, then I would DMOVP the current number of seconds into a DINT. Then, on the HMI, I specify the address of the DINT that I want to display but specify it as a SECONDS 32 type, and the HMI automatically converts the number of seconds back into the HH:MM:SS so that it shows the time on the screen when the process started and when it stopped (using two DINTS obviously) Sweet ....... Edited by Colin Carpenter

Share this post


Link to post
Share on other sites
if i want to changeover everyday AM and PM according to real time, how i suppose to programm it? :helpme:

Share this post


Link to post
Share on other sites
Have attached some screen shots of the code in IEC Developer and also the header for the POU. Once the timeclock has been set in the PLC, this code will give the number of seconds that have elapsed since midnight in the variable TIMESECS. Then simply write some code such as: IF TIMESECS <= 43200 THEN AM = ON IF TIMESECS > 43200 THEN PM = ON Where 43200 is the number of seconds in 12 hrs.

Share this post


Link to post
Share on other sites
sorry for trouble, im using gx work 2(simple project type) i cant do array... can please guide me in another way? Edited by alvis

Share this post


Link to post
Share on other sites
GX Works2 simple project you can use the DATERD command to read date and time from the system clock.

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