DirectSOFT PLC Programming: Help Me Understand This!

Grendizer

Member
Join Date
Apr 2012
Location
Toronto
Posts
88
Hey all,

I have this old code am trying to convert. Never worked with this PLC before. The 2 rungs are attached. What is happening here? What are they trying to accomplish?

Thanks

Pic.jpg
 
FYI, you'll have better luck including the PLC model type in the future. ;)
I looked up the PLC /instruction matrix for the LDIF instruction, and it's only valid for DL06, DL260, DL435, DL440, DL450. All of these are addressed in octal format. (This is important to deciphering the data)

Let's break it down into it's component parts.

[LDIF X0 K12] Load Immediate Formatted
This loads the group X0 - X13 (12 bits long, starting at X0 [Octal addressing, so X0 - X7 , X10 - X13]) and packs it into the accumulator. The Instruction help isn't real clear here, but I take "Immediate" to mean the same as "Interrupt" and "synchronous", meaning that any changes in the source data are ignored, once the instruction is in process.

[BCD] Binary to BCD conversion
This converts the BIN value in the Accumulator to BCD, and stores it in the Accumulator.

[LDIF X14 K4] Load Immediate Formatted
Since there's already data in the accumulator from the first LDIF, this will push the current Accumulator value to the first stack of the Accumulator, and stores the value of group X14 - X17 in the Accumulator.

[OUTX V2500] OUT Indexed
This takes the 16-bit value from the first level of the accumulator stack and copies it to an indexed address based on the Accumulator. So, our BCD converted X0 - X13, is copied into the address V(2500 + the HEX value of X14-X17)


In short, it looks like it's multiplexing data into the V memory.
However, I'm not sure why there's a for next loop around it since the offset is based on physical input data.
 
This appears to be a suggested format for reading multiplex analog input cards. They sequence a channel's data into the lower bits of the input and identify the channel using the upper bits of the input word. This loop is reading all 8 channels on the input card. Some of the CPUs will do this multiplexed input automatically in the background not requiring logic.
 
This appears to be a suggested format for reading multiplex analog input cards. They sequence a channel's data into the lower bits of the input and identify the channel using the upper bits of the input word. This loop is reading all 8 channels on the input card. Some of the CPUs will do this multiplexed input automatically in the background not requiring logic.

What causes the analog cards pointer data to move to the next channel during the loop? I must be missing something, because as far as I see it, without some trigger to the analog card, there's no way to guarantee that the loop will read all 8 channels.
 
The OUTX is what moves the channel data based on the channel decode information in X14-X17.

The person who wrote it is trying to hack the PLC into getting all 8 channels in a single scan.

I am fairly sure that this code doesn't work the way that it was intended to since neither Bernie nor I have ever seen it done this way.
 
The analog modules sample logic only does one channel per scan. I can't find this FOR loop using immediate input instructions in the documentations.

As a pure guess the immediate read could trigger the next channel but since it occurs twice I would be skeptical.

Maybe ask on the AutomationDirect forum. https://forum.automationdirect.com/index.php

The OUTX is what moves the channel data based on the channel decode information in X14-X17.

The person who wrote it is trying to hack the PLC into getting all 8 channels in a single scan.

I am fairly sure that this code doesn't work the way that it was intended to since neither Bernie nor I have ever seen it done this way.

So, we've decided that they are reading each channel 8 times per scan? I guess they really want to make sure they get that data. :ROFLMAO:
 
fenix - the apparent purpose of the code is to read all 8 channels of the single analog input card in one scan. I don't have the hardware to test the validity of this method. Since the analog card will present the channels on successive scans, according to the documentation, it's not strange to assume that the act of the card being read is what triggers the switch to the next channel. So an immediate read (being done in the LDIF command) could possibly trigger this switch. I just don't have the hardware tp test this hypothesis.

My problem with the code is that two immediate reads are being done per iteration of the FOR/NEXT loop. I would expect, if the hypothesis is correct, that this would bump forward two channels. If the hypothesis is correct a better way would be to do one LDI at the start of each FOR/NEXT iteration with a store of the data then two LDF commands done on the result of that single read to extract the analog reading and the channel number.
 
Last edited:
My bad. This code works just fine now that I have tested it. I found the examples in the analog manual. Not sure why I missed them the first time around.
 
It's in the DL405 series analog modules pdf, d4anlg.pdf at least.

It claims 8 in one scan at a cost of 2mS per channel, 16mS add'l scan time for all 8.
 

Similar Topics

I would like a recommendation for training on DirectSOFT DL405 and how to program it with ladder logic. Let's just assume I know nothing about...
Replies
1
Views
3,308
I would like a recommendation for training on DirectSOFT DL405 and how to program it with ladder logic. Let's just assume I know nothing about...
Replies
1
Views
3,019
does any one know dat how to force a input bit , to test the program in plc...i'm using directsoft software 4 KOYO Plc.
Replies
3
Views
4,739
I called Automation Direct support yesterday to find out if there was a way we could download programs and memory into our plc's without the use...
Replies
1
Views
4,265
I am not a Automation Direct programmer. I have done a lot of RS500 I have the DS5 software and I am able to look at the program. I am reaching...
Replies
10
Views
1,111
Back
Top Bottom