RTC on Quantum?

SCADA_Dude

Member
Join Date
Feb 2008
Location
California
Posts
115
I need to execute some code based on time of day. I came up with the following code to extract the clock and put it into a real expressed in hours & fractions of hours. This is so ugly, I hope I am missing the easy way to do this! On A\B its as easy as looking at two S registers!

RRTC_DT(Clock_Result);
Clock_String:= DT_TO_STRING(Clock_Result);
Clock_String:= RIGHT_INT(Clock_String, 5);
Clock_Hrs_Str:= LEFT_INT(Clock_String, 2);
Clock_Min_Str:= RIGHT_INT(Clock_String, 2);
Clock_Hours := STRING_TO_REAL(Clock_Hrs_Str);
Clock_Minutes := STRING_TO_REAL(Clock_Min_Str);
Clock_Time_HrMns := Clock_Hours + (Clock_Minutes / 60.0);
 
If you are using Concept software the method that I use is in the function blocks. I use the GET TOD instruction and the time and date are all broken out for you. Then use Equal to instructions for selecting the time that you want to trigger an event. I'm not familiar with ST programming yet.


Steve
 
Thanks for the reply. I'm using Unity Pro XL 3.0, I searched for GET_TOD but its not included in the library. That's unfortunate because that would be a useful function.
 
SCADA_Dude said:
I need to execute some code based on time of day. I came up with the following code to extract the clock and put it into a real expressed in hours & fractions of hours. This is so ugly, I hope I am missing the easy way to do this! On A\B its as easy as looking at two S registers!

RRTC_DT(Clock_Result);
Clock_String:= DT_TO_STRING(Clock_Result);
Clock_String:= RIGHT_INT(Clock_String, 5);
Clock_Hrs_Str:= LEFT_INT(Clock_String, 2);
Clock_Min_Str:= RIGHT_INT(Clock_String, 2);
Clock_Hours := STRING_TO_REAL(Clock_Hrs_Str);
Clock_Minutes := STRING_TO_REAL(Clock_Min_Str);
Clock_Time_HrMns := Clock_Hours + (Clock_Minutes / 60.0);

You are missing something !!!!

Just read %SW50 and %SW51
 
I knew there had to be an easier way! Thanks!!

I noticed %SW51 is 16#HHMM format (BCD). Whats the easiest way to get these seperated into two integers (HH & MM). Do I convert BCD_TO_STRING like above? I cannot find any BCD shift left/right instructions.

I am using a Unity 12U processor.
 
Last edited:
SCADA_Dude said:
I noticed %SW51 is 16#HHMM format (BCD). Whats the easiest way to get these seperated into two integers (HH & MM).
I think you can use WORD_AS_BYTE block to separate low and high bytes of this word into two different variables.
 

Similar Topics

I have some logic that I have written within a 5380 series controller that tracks the time an event is started, while the event is running an RTO...
Replies
2
Views
91
Had an interesting experience this morning. An old Panelview 600, 2711-K6C5X series B to be precise, comes up as error 32. Unfortunately it...
Replies
0
Views
207
Hello, I have been getting more and more requests for Real Time Clock (RTC) sensitive automation from my clients. I know that there is a Modbus...
Replies
13
Views
2,733
Hi everyone, I have a problem. I seek SysTimeLib and SysTimeRTC, but i can't download them, plz who have these libs, give me them as an archive...
Replies
0
Views
925
Back
Top Bottom