I am sure some body know this please help

hidroela

Member
Join Date
Sep 2003
Location
Across from nasa
Posts
74
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





untitled.GIF




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
 
Sheesh man. Buy and ActiveX DF1 driver or an OPC server that talks DF1. You'll save lots of development time buying a debugged professional piece of software instead of growing your own.

Start looking here:
www.automatedsolutions.com

(8{)} ( .)
(yosi)
 
The code looks correct as far as I see it. Much code is missing. Also it's poor programming practice to put everything in one statment.

However, what's not shown is that TransactionNo needs to be incremented for every sent message. And if any byte is a DLE (if I recall correctly) you need to add another DLE next to it.

Better to get the .NET code available in another thread here, open it an editor and see how it was done.

Or BUY a driver, Cheep. Just guessing from the level of your question, you'll spend many days (if not weeks) trying to code this.
 
free df1 driver available

Download a free DF1 driver from www.tomantron.com
It's a DLL which was designed to work with .NET
It will not work in VB6. Will work with VB.NET, C#, C++.NET
J#.
As far as I know it is currently the only free DF1 driver for
.NET available on the Web.
Ask yourself a question why that is so?
Well because it's a job to code it and test it.

As far as your question goes, for PLC5 you want to use protected typed logical read and write. CMD=0F and FNC = A2/AA.
Page 7-2 of DF1 reference manual.
Blue42 makes some good points.
To send the serial data you would use an MSCOM.
You need to learn about serial communications first.
 
Well I know that there is a bunch of ActiveX control out there ,that some of them are really cheap, that implement one is going to be a no easy task. but I got pay while I am doing it ,I am going to learned from it and finally the joy of doing what I like to do
And finally the joy to put a free VB6 RS232 drive available on the net
I am pretty sure Jiri Toman that you experiment the same feeling when you finished you project

Ok now I got and start
Thanks (y)

Best regards Hidroilio Perez

 
Ok Jiri Toman this is the command that you are talking about

14.GIF


So If I decide to read O:03/017 in the plc5 data table(for example)

10.GIF


My command to send would be:

10 02 00 00 0F 00 01 A2 04 00 03 1B 10 03

After we got to this point we have to CRC (cyclic redundancy check) the command and attached to it and also Check for 10h byte DLE within message and change to DLE DLE.

Now we are ready to send the command and Wait for acknowledgment Or Time Out

Acknowledgment from the PLC

DLE ACK
10 ........06

And the return

10 02 00 00 4F 00 01 01 10 03

Acknowledgment from the PLC

DLE ACK
10 ........06
 
TNS needs to be two bytes long you only have one byte.
Also CRC is two bytes long. Actually I would suggest that you use the BCC first that would only take one byte and it is much easier to calculate!
TNS number needs to be incremented each time you send the string in or else the PLC might see it as a duplicate message and might not reply.
 
J toman thanks for your comments you are right the (TNS (transaction) (2 bytes) long) I miss it, it is clear on AB documentation. and on the CRC I already got the routine to calculate it one more time thanks

Best Regards Hidroilio Perez
 
This is related to this project(DF1 Driver)
AB DF1 documentation state that:
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 or software)


Best regards Hidroilio Perez
 
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



Best regards Hidroilio Pérez
 
Yes it can but it may only work with older OS. You will also need RSLinx and a serial cable to get online. Do a search on this forum and I bet you will find a lot of infomation on how to setup the RSLinx RS-232/DF1/Ch0 serial communication. Once online, if you change a parameter, the processor will be put into program mode (stop) and you will lose communication. You will have to go back into RSLinx and reconfigure/autoconfigure the serial port if you need to go online again or put the PLC into run mode (or use the key in front of the CPU).
 
You will need to connect to PLC5/30 via a DH+ and monitor the data files you are trying to address.You will need RSLinx and RSLogix5 as well as KT (DH+) card.

Channel 0 (RS-232 port)config will have to match the settings used in your VB/C++ code.

In addition you should have a second PC which would be used
to send in test data in to your primary PC. In order to send in the test data such as DLE ACK, DLE NAK, DLE ENQ, message packets etc. and monitor replies from your primary PC you will need to write a test program that would allow you to do that (off the shelf comm software is too generic and will slow you down).

You have not even began to scratch the surface.
 

Similar Topics

I met the problem when design the control cabinet sometime does not match with the side of material (the enclosure too small after installed the...
Replies
7
Views
5,796
Does anyone have experience wiring this type of analog pressure transmitter up? It's 4 wires. 3 blacks and 1 green which I assume is earth...
Replies
9
Views
264
I need an enclosure for wifi access points that will be outdoors. The antennas will mount outside the box but everything else inside. Standard...
Replies
4
Views
156
I've gotten to the learning curve where I can program a call for pump to come on at set point but I'm not sure how to turn the same pump off when...
Replies
1
Views
130
I need to protect some pressure transmitters from hot (120°C) oil. Does anyone have a favorite transmitter cooling element/standoff they use...
Replies
4
Views
166
Back
Top Bottom