Sign in to follow this  
Followers 0
hidroela

I am sure some body know this please help

36 posts in this topic

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 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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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. Edited by TechJunki

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 Where each elements of the command means 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. DLE=10, STX=02 DST and SRC 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) 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 STS: Indicates the status of the message. A command message should always set this field to 00 (hex). TNS (transaction) Indicates a specific transaction value for each message. The TNS value increments for each message packet. TNS=1 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 Edited by hidroela

Share this post


Link to post
Share on other sites
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 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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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 DF1New.zip Edited by TechJunki

Share this post


Link to post
Share on other sites
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 Thanks Best Regards Hidroilio Perez Edited by hidroela

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 AB_RS_232_Driver.zip

Share this post


Link to post
Share on other sites
technogumbo Why not any thing that would help to develop this project (RS232 Driver) will be appreciated Thanks Best regards Hidroilio Perez

Share this post


Link to post
Share on other sites
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 AB_RS_232_Drive_ver2.zip Edited by TechJunki

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Here is the response Just in case some body need to Best regards Hidroilio Perez

Share this post


Link to post
Share on other sites
TechJunki I was wrong on my last post that’s not the device that we have 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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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 New version improved AB_RS232_Driver.rar Edited by hidroela

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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... Edited by TechJunki

Share this post


Link to post
Share on other sites
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 RS232_Driver.rar Edited by hidroela

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0