Sign in to follow this  
Followers 0
boomer7010

DF1 Protocol For Bit Read

8 posts in this topic

Hello All!

I need some help structuring a command to read a bit in a Micrologix 1500 using DF1 Full Duplex via RS232. I have a simple program loaded on the PLC and I'd like to read the bit B3:0/0. I have been reading the "DF1 Protocal and Command Set" and the PLC's instruction manual, but with my lack of experience with serial communication and interfacing with PLC's I am not making the progress in the time I'd like. Hence a call for help.

I am using LabVIEW for the communication. My current command line I am sending (after initializing the port) is attached. Could anyone help me structure it correctly or point me in the right direction?

 

Command_0.png

Share this post


Link to post
Share on other sites

The command is OK. What is the result of issuing the command? The result could be a garbled response, error code or ...

If the result is nothing, it could be the cable is not correct/connected, the device is powered off, bad serial port, etc.. Lots of possible reasons.

We have a free DF1 slave program that might help https://www.hmisys.com/downloads/PeakHMISlaveSimulatorInstall.exe

 

 

Share this post


Link to post
Share on other sites

When I read the buffer after sending the command, it reads 2 bytes and the hex value is 1015.

im guessing this is the PLC’s response with 10 = DLE and 15 = ? Not sure, but it’s something other than DLE which means it’s not a successful read. Am I right?

Share this post


Link to post
Share on other sites

From the DF1 guide:

E Command cannot be executed

 

Share this post


Link to post
Share on other sites

For some closure to this thread. I was calculating the BCC and my PLC was expecting CRC. I implemented the correct CRC conversion and I have successful communication!! On to testing the bit write...

Share this post


Link to post
Share on other sites

Thanks for the followup !

Most A-B devices can be set for BCC or CRC, but SLC/MicroLogix default to CRC.   As you've found, it's a fairly ordinary CRC-16 checksum, so it's 2 bytes instead of 1.

Remember also that the Transaction Sequence Number should increase by one every time you send a command;  the reply for that specific command event should have a matching TSN.

The sequence numbers are one of the things that distinguishes DF1 from Modbus and allows true full duplex communication.

Some A-B devices can be configured to ignore duplicate packets, so sequences of the same command with the same TSN will ignore all but the first one.

Share this post


Link to post
Share on other sites

Ah ha. This is a great point, thanks Ken! I have not been doing this and have noticed communication issues when sending sequential commands. 
 

So I need to store the TSN number as a variable and increment each time I send a command? When can/should I reinitialize this to 0?

Share this post


Link to post
Share on other sites

I'm not a protocol driver author, but in general I'd initialize to zero when you open a connection or restart the driver, then roll over at 65535.

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