How to point the Pointer to the current hour?

piscis

Member
Join Date
May 2003
Posts
241
PLC AutomationDirect 06 with RTC

Every hour I need to store the amount of kilowatts the entire plant has used. The problem I’m having is how to match the current hour and provide my pointer with the correct address?

For the sake of the argument let’s assume this:

V2340 this is the start of my Pointer
V2367 this is the end of my Pointer

Let’s say I turned off the PLC on Friday and turned it back on, sometime on Monday morning. The plant starts manufacturing and its 10:00am, and we have accumulated already the KWH value to store it in our variable for -Hour 9:00am-

Question:
How the pointer would know where to store the next KWH value, which should be in V2350 (HOUR KWH #9)

Right now I have an SP0 “First Scan” loading V2340 octal into my pointer P4000 but the problem here is address not matching the current hour.

If the instruction LDA would accept a variable instead of a constant, that way at first scan I would just simply add the current hour to 2340 and store it in v4000. The problem is how to convert this to an octal addressing.

Wouldn’t it be nice if AD’s PLC would stick with decimal numbering system only?

I’m using the real time clock and I have hours in V7770. Do you guys have an idea how to do this?
 
Question:
How the pointer would know where to store the next KWH value, which should be in V2350 (HOUR KWH #9)

piscis,

Brian123 showed me how to use the find (FIND) instruction.

From the manual page 5-147.

Find (FIND)
The Find instruction is used to search for a specified value in a
V-memory table of up to 255 locations. The function
parameters are loaded into the first and second levels of the
accumulator stack and the accumulator by three additional
instructions. Listed below are the steps necessary to program
the Find function.
Step 1: Load the length of the table (number of V-memory locations) into the second level of
the accumulator stack. This parameter must be a HEX value, 0–FF.
Step 2: Load the starting V-memory location for the table into the first level of the
accumulator stack. This parameter must be a HEX value.
Step 3: Load the offset from the starting location to begin the search. This parameter must be
a HEX value.
Step 4: Insert the Find instruction which specifies the first value to be found in the table.
Results:— The offset from the starting address to the first V-memory location which contains
the search value (in HEX) is returned to the accumulator. SP53 will be set on if an address
outside the table is specified in the offset or the value is not found. If the value is not found 0
will be returned in the accumulator.
Helpful Hint: — For parameters that require HEX values when referencing memory
locations, the LDA instruction can be used to convert an octal address to the HEX equivalent
and load the value into the accumulator.
 
Try this: (The comment (V2340) was corrected. It was V2300 in the image)

PLC 06

// Rung 1
// Address 0
#BEGIN COMMENT
"This rung loads the address of the start of the hour table (V2340)"
"It then loads the current hour (which is in BCD format)"
"It converts the hour to binary format"
"Then it adds this converted hour to the table pointer which is on the stack"
"It then stores the now adjusted pointer to the storage location at V4000"
#END
LDA O2340
LD V7770
BIN
ADDBS
OUT V4000

// Rung 2
// Address 5
END

// Rung 3
// Address 6
NOP


#BEGIN ELEMENT_DOC
"V4000","Pointer Storage","",""
"V7770","Hour","",""

#END

HourPointer.JPG
 
Last edited:
The DL-06 and DL-260 instruction sets are very rich (even excluding the IBoxes) and can perform a lot in a very short space if the user takes the time to actually read the manual thoroughly.

The stack based math instructions, as shown by ADDBS in this example, can help where intermediate storage locations would normally have to be used.
 
Bernie:

Thanks!! Great Job!

Just out of curiosity, how would you do this on a 05 which does not accept the ADDBS instruction?
 
It would be:

LD V7770 (get the hour in BCD)
BIN (change to binary)
OUT Vxxxx (some holding place)
LDA O2300 (load the table start)
ADDB Vxxxx (add the hour offset)
OUT V4000 (save it to the pointer register)

The ADDBS eliminates the need for a temporary holding place. If you've programmed math in AB ladder logic you probably already know all about this (the need for temporary holding registers).

Another way for either DL06 or DL05:

If you call up the Windows Calculator you could pre-compute the hex value of the octal address 2300. That would be 4C0. This actually saves the processor a step in doing the conversion in the LDA command.

LD V7770 (get the hour in BCD)
BIN (change to binary)
ADDB K4c0 (add the table start - in hex)
OUT V4000 (save it to the pointer register)
 
Last edited:

Similar Topics

Hi guys, I'm new here and I just started to work as junior automation engineer. It will be much more easier now I have access to this site. Wish...
Replies
3
Views
1,505
If one were to bubble sort an array (data from AD) using pointers, how would one keep track of which pointer points to which AD after sorting? or...
Replies
4
Views
2,068
Hi, I have some problem with View Point which I'm using to manual control of conveyors. On begin when in network was only PLC and HMI View Point...
Replies
0
Views
69
I have a bunch of tags in Historian/VantagePoint that off by one decimal point. I looked into the HMI displaying the same number, and the HMI is...
Replies
2
Views
113
Good morning, I have a Emerson/GE PLC with Cimplicity SCADA. I need to export data of a specific point/object to a CSV file and load the CSV file...
Replies
7
Views
273
Back
Top Bottom