Help - Search - Members - Calendar
Full Version: I am sure some body know this please help
Forums.MrPLC.com > PLCs and Supporting Devices > Allen Bradley
hidroela
Ok I am trying to understand The AB DF1 protocol in order to use it in a visual basic 6 Application with the objective of makes a simple 232 Serial driver that can read and write to the PLC5/30

The problem that I am facing right now is that I can not figure it out how to construct the command to send to the PLC5.
According to AB this should be the format for unprotected read

user posted image

Now my question is? If I have a output table with this address O:031/17 and I need to read it how can I make the command to send,

Note: I got this code from another forum so I am no sure if it is correct

RS232PLC.InputLen = 0
QueryBuffer = RS232PLC.Input

''3:Create Query (Build the command)
QueryBuffer = Chr$(16) & Chr$(2) & Chr$(DestinationNode) & _
Chr$(SourceNode) & Chr$(15) & Chr$(0) & _
Chr$(TransactionNo) & Chr$(0) & Chr$(162) & _
Chr$(Size * 2) & Chr$(FileNumber) & _
Chr$( ConvertFileType(FileType + 132)) & _
Chr$(ElementNumber) & Chr$(SubElementNumber) & _
Chr$(16) & Chr$(3)

'4:Calculate Crc Check Sum and add to Query
QueryBuffer = QueryBuffer & MsgCRC(QueryBuffer)

'5: Send Message
RS232PLC.Output = QueryBuffer

If there any body that know how to deal with this and are willing to share
There knowledge I will appreciated

Best regard Hidroilio Perez
Gerry
I'm no VB expert, but:

You can't access the output image table with that particular command. You will only be able to access the "PLC2 compatibility file" which is an integer file whose number equals the node address of the station issuing the command. Since DH+ node numbers are generally expressed in octal, you will need to convert the number to decimal to get the right file no for the PLC5.

You should investigate using the "PLC5 typed read" command instead.
lavinh
You need to create a DDE Topic in RSLink (ex. topic name is testsol) and then you can read and write to the PLC by reading the following:

1) Visual Basic examples: read a word
The following program reads the present value of N7:0 into a text box (txtCold) once the Read button (Command1) is pressed.

Sub Command1_Click ()

'Read word from N7:0

txtCold.LinkTopic = "RSLinx|testsol"
'Assign application|topic to DDE text box

txtCold.LinkItem = "N7:0"
Assign link item to DDE text box

txtCold.LinkMode = 2
'Set up link as manual; open up link

txtCold.LinkRequest
'Request data RSLinx

txtCold.LinkMode = 0
'Close DDE link


End Sub


2) Visual Basic examples: write a word
The following program writes a user inputted number to N7:0 when the Write button (Command1) is clicked, and reads the value stored in N7:0 to verify that the number was actually sent. The inputted number is stored in the text property of the text box named txtWrite_val. The returned value is stored in the text property of the text box named txtRead_val.

Sub Command1_Click ()

'Write value to N7:0

txtWrite_val.LinkTopic = "RSLinx|testsol"
'Define DDE application & topic

txtWrite_val.LinkItem = "N7:0"
'Define DDE item

txtWrite_val.LinkMode = 2
'Open DDE link (manual)

txtWrite_val.LinkPoke
'Poke Data to RSLinx

txtWrite_val.LinkMode = 0
'Close DDE link


'Read value from N7:0

txtRead_val.LinkTopic = "RSLinx|testsol"
'Define DDE application & topic

txtRead_val.LinkItem = "N7:0"
'Define DDE item

txtRead_val.LinkMode = 2
'Open DDE link (manual)

txtRead_val.LinkRequest
'Request data from RSLinx

txtRead_val.LinkMode = 0
'Close DDE link


End If

End Sub


Good luck
TechJunki
QUOTE (lavinh @ May 12 2005, 08:18 PM)
You need to create a DDE Topic in RSLink (ex. topic name is testsol) and then you can read and write to the PLC by reading the following:

lavinh, This code would work great with the use of RsLinx but unfourtunately this project is trying to be done without it.

hidroela, I have been doing some research on this, I think Gerry is correct in saying you can only read integer files with this string config, I think the best way to go about this is to read and write to an integer file in the PLC. The code I posted earlier should work for you for that purpose, it can be easily modified to read more values if need be.

>>Previous Post<<

QUOTE
I do not have a N9:0 to N9:9 on my plc and i dont know so i am still searching


If you do not have that data table in your PLC just simply create it and copy all the values to that data table in the PLC that you want, then you can read them from the visual basic code. In the long run this may be the easiest. Be sure to let us know what you come up with, this sounds like an interesting project.
Gerry
QUOTE (TechJunki @ May 13 2005, 03:08 AM)
hidroela, I have been doing some research on this, I think Gerry is correct in saying you can only read integer files with this string config, I think the best way to go about this is to read and write to an integer file in the PLC.

I was referring to the "unprotected read" command.
This is an artefact from the 1774 / PLC-2 era and can only reference data table addresses appropriate to a PLC-2. i.e. an octal number not less than 010.

To use this command to access a PLC-5, you must have a "PLC-2 compatibility file" in the PLC-5.

There are other more appropriate commands for accessing PLC-3's, PLC-5's, and SLC's.

e.g. "PLC-5 typed read"

Personally, I think he needs to learn a lot more about the PLC's in question before tackling a driver.
From memory, the protocol manual contains pseudo-code for what he wants.
hidroela
thanks lavinh but this is an snap shot of an application that I develop using Rslinx and VB6 for more information goto
http://home.earthlink.net/~hidroela/main.png
what I am trying to do is get away from RSlinx and by the way that technique (DDE )is some how really slow on my project I used what they call OPC Client


TechJunki I can to create that N9 table Because file No. 9 is already in used in my plc

I got this tips from another forum
I have been trying to organize the steps to accomplish the first part off my project or I would like to say OUR PROJECT here there go:

<<<<<<<<<<<<Almost all this information is from AB documentation>>>>>>>>>>>>>>>>>>

This is the command that we need to use
user posted image


Where each elements of the command means
user posted image


This two sets of instruction go at the beginning and the end off each command send
beginning
DLE and STX
Sender symbol that separates the multi_drop header from the data.
end
DLE ETX
Sender symbol that terminates a message.
user posted image

DLE=10, STX=02

DST and SRC
user posted image

DST: Indicates the remote node address that the computer is communicating to.
SCR: Indicates the DH node address that is the source of the message.

So that mean that if the destination node is 9 the value of DST=11 if is 0 then DST=0
Same apply to SRC if source node is 5 the value of SRC=5

DST=0; SCR=0

CMD (command)
user posted image

CMD=0F this is from communication table page 7-3 on AB Documentation
FNC=A2 his is from communication table page 7-3 on AB Documentation

STS
user posted image


STS: Indicates the status of the message.
A command message should always set this field to 00 (hex).

TNS (transaction)
user posted image


Indicates a specific transaction value for each message. The TNS value increments for each message
packet.

TNS=1
user posted image

BYTE SIZE
The size of data to be read (in bytes), not including the address fields or other overhead bytes.

BYTE SIZE=4 bytes

FILE NUMBER
Addresses files 0_254 only. For higher addresses, setting this byte to FF expands this field to three bytes total. Use the
second and third bytes for the expanded file address (low address byte first).

FILE TYPE
Use one of the these values for this field. Do not use any other values; doing so may result in unpredictable results.
80_83 hex: reserved
84 hex: status
85 hex: bit
86 hex: timer
87 hex: counter
88 hex: control
89 hex: integer
8A hex: floating point
8B hex: output logical by slot
8C hex: input logical by slot
8D hex: string
8E hex: ASCII
8F hex: BCD

ELEMENT NUMBER
Addresses elements 0_254 only. For higher addresses, setting this byte to FF expands this field to three bytes. Use the second
and third bytes for the expanded element address (low address byte first).

SUB_ELEMENT NUMBER
Addresses sub elements 0_254 only. For higher addresses, setting this byte to FF expands this field to three bytes. Use the
second and third bytes for the expanded sub element address (low address byte first).

DATA
For SLC 5/01 or 5/02
82 bytes (41 words)

For SLC 5/03 or 5/04
225 bytes with IP (does not apply to DF1 drivers)
236 bytes without IP (applies to DF1 drivers)

Best regard Hidroilio Perez helpsmilie.gif
hidroela
Now TechJunki we need to figure it out each part of the command suppose that we are going to read this point on the plc5 O:03/015

user posted image

BYTE SIZE
Because is going to be an integer 0,1 ,10, 100, 1000
The BYTE SIZE=04 bytes

FILE NUMBER
On this case FILE NUMBER=00

FILE TYPE
According to the previous post because it is and output file type
FILE TYPE=8B

ELEMENT NUMBER=03

SUB_ELEMENT NUMBER=0F

Please if my meditation are not correct let me know

Best regards Hidroilio Perez
Guest_cjh
Your sub element number looks wrong to me. As I recall, the sub element number refers to the "word" number of this slot. I think that you should use 0 in this case. If you were looking for O:3/16 through O:3/32, you would put 1 in to the sub element field.
I may be mistaken but I believe this to be the case.
hidroela
Guest_cjh thanks for your observation I thought for example on this case O:03/015 that
015 means the output No.15 off the 17 that a plc5 has so my confusion is, like you state <<you were looking for O:3/16 through O:3/32 >> could be a plc5 with more than 17 outputs on it I don’t know just asking

thanks
Best regards Hidroilio Perez
TechJunki
hidroela, been looking at this a little, I have put together a new program which you can choose the file type and file number that you want to read from, and will then read 5 words. I have tested this on various Integer and Bit files, ex. N7:0, N9:0, N14:0 B3:0, with success on a SLC 5/04, I have not tested Output data files but I do not see any reason why if wouldn't work. Give it a try, the codes somewhat messy but hopefully it will be a place to start. Keep me updated...

JJ
hidroela
Which command are you using in your example (protected typed logical read with three address fields)? If it is so I got confused in your code below
It is some thing that I am missing please explain that to me
i try it but did not work Bad Ack


user posted image

QUOTE
                        DLE         STX                    DST                           SCR
QueryBuffer = Chr(16) & Chr(2) & Chr(DestinationNode) & Chr(SourceNode) & _
      CMD          STS                TNS                    FNC       BYTE SIZE
    Chr(15) & Chr(0) & Chr(TransactionNo) & Chr(0) & Chr(162) & _
       File No.                  File Type                  Element No.
    Chr(Size * 2) & Chr(FileNumber) & Chr(filetype + 132) & _
        S/Element No.               DLE        ETX
    Chr(ElementNumber) & Chr(16) & Chr(3)


Thanks
Best Regards Hidroilio Perez helpsmilie.gif
technogumbo
Hidroela, you stated that you do not wish to use RSLinx for this project. However, RSLinx Lite is FREE and comes with RSLogix 5 and 500. Lastly, RSLinx has all the capability to do what you are needing. However, should you wish to create an OPC topic, I do believe you will need to upgrade to RS Linx OEM or RS Linx PRO. You are correct that a DDE topic is very slow. There is a module in the RS Logix 5 Advanced PLC programming class (through Allen-Bradley) that teaches how to read and write data to/from a PLC-5 using an Excel page. Very slick way to make up a poor-man's GUI interface to an A-B PLC. Should you be interested in this approach, I can come up with the code in a short time.
hidroela
TechJunki take a look at this little project that I start this week end as a base for our RS232 DF1 Driver headache


Thanks
Best regards Hidroilio Perez
hidroela
technogumbo

Why not any thing that would help to develop this project (RS232 Driver) will be appreciated

Thanks
Best regards Hidroilio Perez thumbsupsmileyanim.gif
TechJunki
hidroela, Nice program, I finally got it to work by changing some of the code. The one thing I did notice though, is when reading an Output address ex. O:0/1 it returns the entire word instead of the bit value. This is probably not a huge deal as it is fairly simple to extract the decimal data to binary form. I also removed the Timeout code, it didn't work properly, and I did not have time to dig into this part of the program. Other than that the program appears to work well, you did a good job assembling the base code, this will be a good starter for a number of projects.

Let me know if it works for you. I tryed this on a SLC 5/04 where it worked fine, but I just tryed on a PLC-5 and I keep getting a value of "4110" on any register that I try to read. I will keep trying to get it to work on the PLC-5, but for now it should definetely work on a SLC processor.
JJ
TechJunki
It appears to read from a PLC- 5 processor you will have to use the following, the Typed Logical Read is for SLC-500's only. Will have to modify the String to suit.
Guest
TechJunki I am glad that you got it working on the SLC 500 and also which command is the right to used in the plc5 I will work on it and post results


Thanks
Best regards Hidroilio Perez
hidroela
This is related to this project

At the end of each polling frame and each message frame, there is a one-byte BCC (block check character) field, or a two byte CRC (cyclic redundancy check) field. You select BCC or CRC through switch settings or software configuration. Either field allows you to verify the accuracy of each message frame transmission:

And my question is can I send any one of them or I have to send one in specific according to some settings in the plc (through switch)


Best regards Hidroilio Perez
hidroela
Here is the response
Just in case some body need to


user posted image

Best regards Hidroilio Perez
hidroela
TechJunki

I was wrong on my last post that’s not the device that we have blush.gif

I just find today that the plc5/30 o at least the one that we own the Serial port's default configuration are:
• DF1 point to point
• 2400 bps
• No parity
• One stop bit
• BCC error check
• No handshaking

And according to what I found so far it can not be changed through switches so probably that’s why I could not read from the plc now I need a visual basic code to calculate the BCC
Don’t think that I drop the project I know that we will finish


Best regards Hidroilio Pérez thumbsupsmileyanim.gif
hidroela
this is from another forum thanks to DaveW

how to change com por settings

What I’m trying to say is that you will need to use RSLogix5 to go online to the PLC using the RSLinx RS232/DF1 serial driver that is already working and change the PLC serial port (Channel 0) parameters (baud, stop, parity, BCC/CRC, etc). Once online, click the Channel Configuration branch on the project tree to the left of the screen, select the Channel 0 tab, and under Error Detect, change it from BCC to CRC. As soon as you apply this change, RSLogix5 will ask you to confirm switching the CPU from RUN to PROGRAM mode so that it can make the change. When you confirm Yes, the processor is stopped and logic is no longer scanned (your machine is stopped!) until you put it back into RUN mode. But because you change a serial port parameter, RSLinx will fail because it’s looking for BCC still. Your RSLogix5 will timeout because it needs RSLinx. You will need to reconfigure RSLinx for CRC, go back online and put the processor back into RUN mode or use the Key in front of the CPU.

Best Regards Hidroilio Perez clapping.gif
hidroela
Ok TechJunki the project despite the skepticism of some people is going. we are now able to read to the integer table of the plc5 and SLC-500




Note:this project is free if you want you can modified destroyed seller but if some body make improvements to it pleaseeeeeee……. Post it, so we can all benefit from it i hope you think the same way TechJunki

Best regards Hidroilio Pérez clapping.gif




New version improved
hidroela
Need help
I trying to read on the binary file B3/10 in a plc5 when I send this command (typed read (read block)) using Checksum=CRC
Command send
|16|2|0|0|15|0|58|0|104|0|0|1|0|15|0|3|10|0|1|0|16|3|137|126

The respond from the plc is

DLE|STX| SRC|DST| CM|STS| TNN | A | B |DLE|ETX |CRC|
|16 | 2 | 0 | 0 | 79 | 0 | 58 | 0 |153|9|3|66|16|16|0 | 16 | 3 |87|88



The first byte of the type/data parameter is the flag byte,

According to my finding 153 the flag byte

153 Dec converter to binary =10011001

1 Id Format Field
001 Id Value Filed
1 Size Format Field
001 Size Value Field
My problem is that I can not figure it out how to read the B part 9|3|66|16|16|0

Any body help my out how to interpreter this enigma

Best regard Hidroilio Pérez
TechJunki
I am a little confused as to your question but...

If you are reading the word 10 you will need to use B3:10....

For a bit value such as B3/10 this will only return the single bit value of B3:0/10...

hidroela
New improvement Read Binary table, Output table, Input table, Timer table, Plus Integer table from previous version
Classes Wrapped in to a DLL (with timer and MScomm) with Help File
Timeout and respond incorporate

Best regard Hidroilio Pérez thumbsupsmileyanim.gif
hidroela
Does any one know what the tag mean in the
Protected typed file read command
user posted image

I search the entire documentation and do not find reference no where
That explain what it is


Best Regards Hidroilio Pérez shrug.gif
hidroela
the answer is here


Best Regards Hidroilio Perez dancered.gif
hidroela
More improvements Read Binary table, Output table, Input table, Timer table and Integer now on Micrologix family of processor plus many bugs fix.

Best Regards Hidroilio Perez clapping.gif
hidroela
Another version capable to write to
PLC-5 the integer table
Micrologix Bit, Output, Input and Integer data table
plus many bugs fix

Best regards Hidroilio Pérez thumbsupsmileyanim.gif

Is Here
Daniel Camacho
Hello, I was wondering if anyone is working on and ethernet driver as well? blush.gif
hidroela
Another version capable to write to: the integer, Bit, Output and Input PLC-5 data table and Micrologix data table.Plus several bugs fix

Best regards Hidroilio Pérez dancered.gif
Chavak
Hidroela,

Thankyou very much for sharing you work. Once I wanted to work around for this, but never got a chance to start.

Thankyou
_____________
hidroela
By the way I got a new version that I forgot to share (Sorry) for almost a moth this is a new concept on the software implementation (I am not a one I mean developer) take a look and drop some comments thanks

Best regards Hidroilio Perez thumbsupsmileyanim.gif
hidroela
Sorry me again this is version on Visual Basic Net 2005 Framework v2.0.50727

Attach is a project with the DLL and a littler test Project


Best regards Hidroilio Pérez dancered.gif
hidroela
Some bugs fix

-write to plc

-versioning add date

-others



Best regards Hidroilio Pérez IPB Image



This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.