SourceForge Logo

Allen Bradley Driver

BIG FAT WARNING:
This is pre-alpha code and information. You assume all responsibility for its use.

DANGER: DON'T connect to a PLC unless you are certain it is safe to do so!!! It is assumed that you are experienced in PLC programming/troubleshooting and that you know EXACTLY what you are doing. PLC's are used to control industrial processes, motors, steam valves, hydraulic presses, etc. You are ABSOLUTELY RESPONSIBLE for ensuring that NO-ONE is in danger of being injured or killed because you affected the operation of a running PLC.
Also expect that buggy drivers could write data even when you expect that they will read only !!!

I've tested this driver with Allen Bradley's SLC 50/3. It uses DF1 protocol on channel 0 (RS232). In the test case channel 0 was set to use DF1 full duplex protocol with 9600 baud, no parity and one stop bit and CRC error checking. It was a point to point connection, so no I did not implement source/dest address fields but set them simply to 0.
Details of Allen Breadley protocol can be found in Allen Bradley DH485+ Manual.
The driver can currently only read integer or floating point values from the PLC's files using what AB calls the "protected typed read with three address fields" command (CMD=0xF, FNC=0xA2).
The ability to read other data types could easily be added. I cannot test write commands currently, because the only such PLC available for me is in a producing machine. Fields marked with an asterisk (*) are Allen Bradley's command and type codes. They will be directly copied into the respective fields of messages.
Be extremely careful with them as AB warns us that undefined codes may give unpredictable results !!
Opening object tagObject properties
Object typeComment CMD* FNC* Data type code* File No. Start address Byte count Sheet Start Coord. Error Coord. Condition Closing object tag
<ALLENB; 'This will copy 20 bytes (10 integers) from file N7 beginning with element 100 as integers to D1..D10 if A1 is<>0. It will put execution error code into E1' 15 162 137 7 100 20 1 'D1' 'E1' 'A1' </ALLENB>
'if A1 is<>0, this will copy 20 bytes (5 float numbers) from file F8 beginning with element 60 to to F1..F5 as floating point numbers. It will put execution error code into E2' 15 162 138 8 60 20 1 'F1' 'E2' 'A1' </ALLENB>
ParameterPossible valuesMeaning
CommentAnything you wantUse it to remeber the purpose of the line
CMD15AB's command code 0xF.
FNC162AB's command code 0xA2.
File No.depends on files in PLCThe file to read from
Data type code137,138 AB's data type code. The driver uses this to convert byte sequence to double. You cannot siply put in other type codes here without extending the driver.
Start addressfirst to last element in PLC file Start address in PLC
Byte count1..82Number of bytes to transmit
Sheet1..last sheet usedNumber of spreadsheet to store data
Start Coord.A1..NTP10000First cell cooresponding to first address. Next data elements go to or are taken from cosecutive rows.
ConditionA1..NTP10000A cell which must have numerical contents non zero in order to execute the transfer.
Error Coord.A1..NTP10000This cell takes an error code or zero if transmission went o.k.

All PLC drivers use blocks of data. The first and last element in PLC memory are used to specify a block. For the corresponding area in the spreadsheet, the first cell coordinate is specified. Further data elements are copied to or taken from consecutive row of the same column.

Speed hint:

The driver transfers a block of data for each instruction. If you use for example elements 1 to 5 of some file and elements 8 to 10 of the same file, it is faster to read elements 1 to 10 as one block and just do nothing with elements 6 and 7.