System Clock PLC M340 - Unity Pro

ndelucca

Member
Join Date
Jul 2013
Location
Rosario
Posts
28
Hi everyone, im trying to read/write the system clock on a M340, by building a program in unity pro. The thing is, that the Date&Time format is useless to me. What i need, is to have the seconds, minutes, hours, day, week, month, all in separate variables (in example, the %SW51 allows me to access in a single variable hours/minutes, but i have no way to modify them individually).
If you have any idea on how to do this, or if its even possible, please let me know. Thank you.
 
You have to use system bit %S50 and words %SW49-%SW53 fro this.

When you want change time, set bit %S50 first, then copy new time to system words %SW49-%SW53. (Use integer to BCD conversion before copy) and set bit %S50 to "0" for updating time to RTC.

To get hours and minutes seperate, you can use Rotate right and left inscructions. Not easiest way, but it is possible ;)

For reading time from system words, use first BCD to integer conversion and then rotate left/right inscructions.
 
Thank you very much Lare, i ended up using the Rotate Right and Left instruccions as you mentioned, it was simple enough once i got used to them. Thanks again!
 
Now i have another problem, once i solved the read clock issue, i went along to write the values i wanted. So by converting separate integer values into combined BCD values, i tried to write each value in the system word that corresponded (%50 := Sec, %51 := HourMinute, etc..) by using the system bit %S50 as you explained in a previous post. The problem is that its not writing the values, the system clock continues running with the same value, even when i set the %S50. Is there any other procedure to write theese values? I also tryed the WRTC_DT function, and the problem persists. Thanks
 
You need set %S50 bit first, then copy new values to system words on bcd-format.

%SW50=second
%SW51=hours and minute
%SW52=month and day
%SW53=year
%SW49=day of week (monday=1)

Clock is updated with falling edege of system bit %S50 so you need reset it after you have copied time to system words.

But if clock times are wrong (like seconds are something like 63 :), time is not updated and old time is taked back to RTC.)

There was also some problem when you first time update clock.
If clocktime is not right at first, time changing via system words don't work. (this happens pretty many times with new CPU)

For this you need to go crack view at online, double click CPU, select animation and real time clock. Then update computer time to RTC if RTC says that clcok time is wrong. After this it should be possible to change time with system words.
 
Hello everyone. This is first time using this forum.

I'm curious, I am using Unity Pro software and PLC M340 modules. I learned that %SW is in hexadecimal.

For example, %SW51 (Hour and minute) and it reads the system clock 7:30AM, or 16#730. So, is it possible that I can convert hexadecimal to decimal by using BCD_TO_INT? If not, what are the other options.

Please respond to this post as soon as possible.

Thank you, Nemic.
 
Hello everyone. This is first time using this forum.

I'm curious, I am using Unity Pro software and PLC M340 modules. I learned that %SW is in hexadecimal.

For example, %SW51 (Hour and minute) and it reads the system clock 7:30AM, or 16#730. So, is it possible that I can convert hexadecimal to decimal by using BCD_TO_INT? If not, what are the other options.

Please respond to this post as soon as possible.

Thank you, Nemic.


You allready readed 2. post of this read?


When you want change time, set bit %S50 first, then copy new time to system words %SW49-%SW53. Use integer to BCD conversion before copy...(=INT_TO_BCD)

For reading time from system words, use first BCD to integer conversion...(=BCD_TO_INT)
 
You allready readed 2. post of this read?

Hi Lare,

Well I know %sw51 is in hex. But I need to make sure that I was right. Is %sw51 in hex type or binary type? If its hex what kind of function block that I can convert hex to decimal?

Nemic
 
re-read post #2 again. BCD to int.
OK, VON_hydro. Since I don't have the Unity Pro software in front of me, so I need a visual check. Take a look at my attached file.

Please, tell me that my logic is correct.

I'll be fully appreciate that you can help me out.


Thank you, Nemic.

BCD_TO_INT.JPG
 
Hi Nemic,

Can you please describe how the BCD to INT block is not working for you? Read up on BCD and make sure you understand what that is and how it works. Maybe post your program and describe what you want it to do and what it is doing wrong.
 
Hi Nemic,

Can you please describe how the BCD to INT block is not working for you? Read up on BCD and make sure you understand what that is and how it works. Maybe post your program and describe what you want it to do and what it is doing wrong.
Hi VON_hydro,

I don't have Unity Pro in front of me, so it is impossible to simulate the program. I know %SW is "System Word", but I'm not sure what SW's data type. I'll try other solution. How about this attached file? All attach files you are seeing are "theories" and not "results".

Nemic

Move and Add.JPG
 

Similar Topics

I am using a Studio 5000 with an Allen Bradley CompactLogix 1769-L24ER-QB1B controller. Im wondering how I can use the system clock to be able to...
Replies
10
Views
2,411
HEllo! Where do it setup the clock? Couldn´t find anything useful in General-->Time of day besides daylight saving time. And when i have set the...
Replies
9
Views
1,237
Hello everyone one. I'm using M340 with simulation mode (actually I still don't have the cpu to test the software). I've made a simple counter...
Replies
4
Views
488
I took an online course but don't remember covering this. How do I access the system clock in a compare instruction? I want to turn on an output...
Replies
1
Views
505
hello everyone, I'm trying to set the system clock on my plc for daylight savings time so the operator does not need to adjust himself twice a...
Replies
1
Views
2,410
Back
Top Bottom