Combining MW in modicon m221

Bennyboi

Member
Join Date
Aug 2021
Location
Uk
Posts
3
Hi all.

I’m currently trying to combine 3 memory words in to a single display on a weintek hmi as I want to display running time. I have the following.
Mw1 - seconds
Mw2 - mins
Mw3 - hours

I want to make a memory word that is following but struggling on how to do to.
Mw3:mw2.mw1 (hours : mins . Seconds) so I can pass this to my hmi.

Can anyone explain on how I can do this and if
It is even possible.

Thanks in advance.
Ben.
 
Welcome to the forum, your question is a little vague, for example are you asking how to get the run time into those words or have you already got them & just want to display them on the HMI.
Assuming you just want to display them then just put the 3 words on the display separated with ":"
So you get MW1 : MW2 : MW3, Some HMI's might have a time field as a ready built variable but is usually tied to an already pre-allocated time i.e. the HMI real time clock, in any case it probably uses the same format, however, it may not be possible to allocate other words to a standard time field.
See pic, however, this only allows 2 digits for the hours, if you need more then you need to increase the number of digits bearing in mind an MW word only goes to 32767 before it reverts to minus, if you need more than 32,000 hours then you need a double word (long integer etc.).
If you are building a run time clock then just increment MW2 on a 1 second clock pulse, compare > 59 then increment MW1, set MW2 to zero
Do the same for minutes i.e. compare > 59 increment MW0, set MW1 to zero.
No doubt you will get many comments on accuracy regarding using the on-board seconds from the RTC or by using a one second timer, it depends on what sort of accuracy you want & size of the runtime. There has been many a discussion on here regarding this, so be prepared for a long drawn out post.

Run Time.png
 
HMI Capabilities

The question is not primarily about the PLC, it is about what the HMI can accept. Parky is correct in saying that in most cases you can just separate the three numbers on the screen with colons between them. I'm not familiar with your HMI but some have other time display options.

Our interface has two specialized options. The first shows time of day in ##:## AM format. It wants the 0-23 hours multiplied times 100 and added to the minutes inside the PLC. It typically is used with single-register 16-bit integer data. This can show times for things like shift start setpoints and it can also show the current time of the PLC clock since the data is formatted by the PLC.

Our second format displays as ##:##:## AM. It wants the number of seconds since midnight. The PLC has to do ((Hours * 60) + Minutes) * 60 + Seconds. This requires a 32-bit double integer result - two consecutive %MW in your Modicon.

Once you investigate what your HMI can to you will have the answer as to how to handle it in the PLC.
 
Build the string in the PLC

IF you want fancier 12-hour '##:##:## AM' display with leading zeros showing on the minutes and seconds and midnight showing as '12' instead of '0' AND your interface doesn't support it then you may have to go the rough route and build the time up as an ASCII string in PLC registers. Then you run into having to determine how your HMI interprets register data as strings (byte order, etc). That answer may involve more work than what the problem deserves. PM me if you want to discuss this route further. I've done a little with M221.

PLC clock setting from the HMI is another whole discussion. We use a predefined PLC-independent integer array. That makes the HMI side pretty simple but it complicates the PLC programming. Once again the initial work is in determining what your HMI is comfortable with.
 
I wouldn't think the OP needs AM/PM as they stated run hours. One thing is not clear is how many hours the OP is expecting is this run time per day/week/month or years, if the answer was greater than about 6 months then a word is not large enough for the hours.
 

Similar Topics

Hi, I have a functions which extends codes generation for RFID tags. Basically it takes a char and splits it's hex value over 2 chars. I cannot...
Replies
24
Views
9,455
I'm onsite right now and I'm trying to decide how to proceed. I need to make some major edits to the Micrologix 1400 file, but the guy with the...
Replies
9
Views
1,161
Hello, I am trying to write a logic to control a pump. I have my logic as attached. Is there a way to do Auto and Manual control without having...
Replies
12
Views
2,721
Hi there, Quick Question. I have 2 PLCs and 2 solenoids. I would like to wire these up so that If either one turns on, it will turn on both...
Replies
17
Views
11,419
I have an application where I need around 60 Amps of 24V. Most 24V PS go up to 40A, so I need to be able to add them in parallel. Puls power...
Replies
36
Views
10,382
Back
Top Bottom