You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old October 10th, 2017, 04:41 PM   #1
Grendizer
Member
Canada

Grendizer is offline
 
Join Date: Apr 2012
Location: Toronto
Posts: 82
DirectSOFT PLC Programming: Help Me Understand This!

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
Attached Images
File Type: jpg Pic.jpg (8.3 KB, 141 views)
  Reply With Quote
Old October 10th, 2017, 05:31 PM   #2
fenix
Member
United States

fenix is offline
 
Join Date: Jul 2017
Location: Indiana
Posts: 20
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.
  Reply With Quote
Old October 10th, 2017, 09:27 PM   #3
bernie_carlton
Lifetime Supporting Member + Moderator
United States

bernie_carlton is offline
 
bernie_carlton's Avatar
 
Join Date: Apr 2002
Location: Yakima, Washington
Posts: 6,158
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.
__________________
Controlling outputs is the PLC's way of getting its inputs to change.

www.thePLCguy.com
  Reply With Quote
Old October 10th, 2017, 09:47 PM   #4
fenix
Member
United States

fenix is offline
 
Join Date: Jul 2017
Location: Indiana
Posts: 20
Quote:
Originally Posted by bernie_carlton View Post
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.
  Reply With Quote
Old October 10th, 2017, 09:51 PM   #5
fenix
Member
United States

fenix is offline
 
Join Date: Jul 2017
Location: Indiana
Posts: 20
Doublepost fail
  Reply With Quote
Old October 10th, 2017, 10:31 PM   #6
bernie_carlton
Lifetime Supporting Member + Moderator
United States

bernie_carlton is offline
 
bernie_carlton's Avatar
 
Join Date: Apr 2002
Location: Yakima, Washington
Posts: 6,158
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
__________________
Controlling outputs is the PLC's way of getting its inputs to change.

www.thePLCguy.com
  Reply With Quote
Old October 11th, 2017, 07:40 AM   #7
icky812
Lifetime Supporting Member
United States

icky812 is offline
 
icky812's Avatar
 
Join Date: May 2002
Location: Cumming, GA
Posts: 679
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.
  Reply With Quote
Old October 11th, 2017, 04:30 PM   #8
fenix
Member
United States

fenix is offline
 
Join Date: Jul 2017
Location: Indiana
Posts: 20
Quote:
Originally Posted by bernie_carlton View Post
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
Quote:
Originally Posted by icky812 View Post
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.
  Reply With Quote
Old October 11th, 2017, 05:09 PM   #9
bernie_carlton
Lifetime Supporting Member + Moderator
United States

bernie_carlton is offline
 
bernie_carlton's Avatar
 
Join Date: Apr 2002
Location: Yakima, Washington
Posts: 6,158
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.
__________________
Controlling outputs is the PLC's way of getting its inputs to change.

www.thePLCguy.com

Last edited by bernie_carlton; October 11th, 2017 at 05:19 PM.
  Reply With Quote
Old October 11th, 2017, 05:17 PM   #10
fenix
Member
United States

fenix is offline
 
Join Date: Jul 2017
Location: Indiana
Posts: 20
Quote:
Originally Posted by bernie_carlton View Post
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.
I understand. Just trying to crack a bit of a joke...
  Reply With Quote
Old October 12th, 2017, 08:20 AM   #11
icky812
Lifetime Supporting Member
United States

icky812 is offline
 
icky812's Avatar
 
Join Date: May 2002
Location: Cumming, GA
Posts: 679
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.
  Reply With Quote
Old October 12th, 2017, 09:29 AM   #12
bernie_carlton
Lifetime Supporting Member + Moderator
United States

bernie_carlton is offline
 
bernie_carlton's Avatar
 
Join Date: Apr 2002
Location: Yakima, Washington
Posts: 6,158
Icky812, in which manual did you find this code?
__________________
Controlling outputs is the PLC's way of getting its inputs to change.

www.thePLCguy.com
  Reply With Quote
Old October 12th, 2017, 02:08 PM   #13
Mike Nash
Member
United States

Mike Nash is offline
 
Join Date: Mar 2008
Location: Alabama
Posts: 12
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.
  Reply With Quote
Old October 12th, 2017, 09:28 PM   #14
bernie_carlton
Lifetime Supporting Member + Moderator
United States

bernie_carlton is offline
 
bernie_carlton's Avatar
 
Join Date: Apr 2002
Location: Yakima, Washington
Posts: 6,158
That's a large hit to the scan time. I thought I had seen it somewhere. I wonder if it's valid on all platforms?
__________________
Controlling outputs is the PLC's way of getting its inputs to change.

www.thePLCguy.com
  Reply With Quote
Old October 13th, 2017, 07:45 AM   #15
icky812
Lifetime Supporting Member
United States

icky812 is offline
 
icky812's Avatar
 
Join Date: May 2002
Location: Cumming, GA
Posts: 679
Just the D4-440, D4-450 and D4-454 as far as I know.
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
Rs logix 5000 varunmahendran91 LIVE PLC Questions And Answers 4 October 6th, 2014 01:26 PM
How to learn Control Logix PLC programming SuperMiguel LIVE PLC Questions And Answers 1 July 22nd, 2014 04:38 PM
Festo PLC Programming Homam Al-Othman LIVE PLC Questions And Answers 5 April 10th, 2014 02:49 AM
DirectLogic 405 PLC Programming wilvil2000 LIVE PLC Questions And Answers 1 December 5th, 2003 09:37 PM
PLC programming software workarounds jdbrandt LIVE PLC Questions And Answers 17 April 12th, 2003 09:51 AM


All times are GMT -5. The time now is 09:16 PM.


.