MicroLogix RTC time format (wont show zeros)

Skidood

Member
Join Date
Oct 2016
Location
Ontario
Posts
215
Hi, I have successfully got my system to do the following:

1. write the RTC hours, minutes and seconds to 3 integer files every 250 mS.

2. Reference those integers using "indirect addressing" in an ASCII string, with a colon separating them so the string looks like, for example, 11:23:48

2. Print the string (using a serial printer on Port 2)

The problem is that if the minutes or seconds are below 10, this is what prints:
11:6:7 when it should be 11:06:07

Anyone out there have any tips? I think I'm screwed.
 
Last edited:
MOV to move the numbers in S:40 thru S:42 to 3 integer files (N)

The ASCII string looks like this.

"TEXT" [N9:3]:[N9:4]:[N9:5] 378.4 289 PSI

The insertion of the integers works fine, just zeroes dont show up from the RTC since it doesnt send any. Even when you set the time in the RTC function file, the zeroes disappear as soon as they are entered.
 
Last edited:
there is probably a more efficient way but i dont use the 50 platform much or ascii ever, as this way you will need a few ifs

if min < 10 AND sec <10
"TEXT" [N9:3]:0[N9:4]:0[N9:5] 378.4 289 Psi
else if min <10
"TEXT" [N9:3]:0[N9:4]:[N9:5] 378.4 289 Psi
else if sec <10
"TEXT" [N9:3]:[N9:4]:0[N9:5] 378.4 289 Psi
else
"TEXT" [N9:3]:[N9:4]:[N9:5] 378.4 289 Psi

I would probably do conditionals on minutes and seconds and convert to string and concatenate but i also have never one it
 
This is where my project has started to become tedious instead of fun. I have quite a few different strings to print, and most of them will be from a Concatenate instruction to begin with, and RSLogix 500 only allows you to combine no more than 2 strings together per conc. instruction. Looks like just to take care of the printing requirements I have, I will need to program a few dozen rungs. I wonder if one of those Windows/PC type controllers would be better suited for this.
 
If you're doing the same thing repeatedly, you could always look at using a subroutine to do the grunt work - just move the relevant strings into the relevant areas, call your subroutine, have it assemble everything off those same registers, then grab the resulting string and put it wherever it's required. You could call that SBR as many times as you need to assemble all your strings, but only have to write the code once.

It would be easier, of course, if you had Logix 5000 and you could pass specific parameters to the SBR (or even use an AOI). Then you wouldn't have to move the strings in and out of position to use the SBR, you could just tell it each time which strings to work on. But it's still doable - as I say, you just have to move your strings in and out of the positions for the SBR to work on.
 

Similar Topics

I'm looking to add some low Battery Status Alarms to a set of PLCs (Mostly RSLOGIX500 based). I noticed there were two possible alarms for low...
Replies
3
Views
1,519
This is a weird one. I vaguely remember reading something here about a firmware issue but I can't find the post. I'm looking at this tiny...
Replies
2
Views
2,315
On the Micrologix 1100, I'm having an issue with RTC freezing. I think its only happening after a power outage. But when I go to enter values...
Replies
4
Views
2,436
Hello, I want to use the RTC function files in my program to turn on a certain output at a certain time, but I am having trouble setting the...
Replies
10
Views
3,938
Back
Top Bottom