Directnet plc to bs2
Wrigly
Posts: 9
Trying to get a v memory location from a plc to a BS2. The PLC is a Koyo DL06 using their Directnet protocal.The first part is a request for data from the BS2 to the PLC, which works right and I get a proper responce. My problem lies with the nest section where I send a SOH header to the PLC giving the information for the location, size and such to the PLC. At this point the PLC can respond in one of two ways, first with a ACK and data requested or with a NAK(not acknowledge) if there are problems. This is where my problem is I always get a NAK. I have tried different settings and request to no avail. I have a question of addressing, as the BS2 is themaster and PLC is the slave, do I have to identify the BS2 in some way as the master? Any help on this would be great.
Thanks Wrigly
' {$STAMP BS2}
' {$PBASIC 2.5}
c1 VAR Word
c2 VAR Word
c3 VAR Word
c4 VAR Word
c5 VAR Word
plc VAR Byte(8)
main:
c1=0
c2=0
c3=0
c4=0
c5=0
plc(0)=0
plc(1)=0
plc(2)=0
SEROUT 1,16468,[noparse][[/noparse]$4E,$21,$05]
SERIN 0,16468,[noparse][[/noparse]c1,c2,c3]
DEBUG CLS,HEX ? c1,HEX ? c2,HEX ? c3
SEROUT 1,16468,
[noparse][[/noparse]$01, ' 1 = SOH
$30, ' 2 = target address byte
$31, ' 3 = target byte address 2
$30, ' 4 = read or write
$31, ' 5 = data type
$30, ' 6 = starting address MSB
$34, ' 7 = starting address MSB
$30, ' 8 = starting address LSB
$31, ' 9 = starting address LSB
$30, ' 10= number of complete blocks
$30, ' 11= number of complete blocks
$30, ' 12= bytes in last block
$34, ' 13= bytes in last block
$30, ' 14= master ID
$30, ' 15= master ID
$17, ' 16= ETB
$30, ' 17= LRC1
$31] ' 18= LRC2
SERIN 0,16468,[noparse][[/noparse]STR plc\2]
DEBUG HEX ? plc(0),HEX ? plc(1),HEX ? plc(2)
END
Thanks Wrigly
' {$STAMP BS2}
' {$PBASIC 2.5}
c1 VAR Word
c2 VAR Word
c3 VAR Word
c4 VAR Word
c5 VAR Word
plc VAR Byte(8)
main:
c1=0
c2=0
c3=0
c4=0
c5=0
plc(0)=0
plc(1)=0
plc(2)=0
SEROUT 1,16468,[noparse][[/noparse]$4E,$21,$05]
SERIN 0,16468,[noparse][[/noparse]c1,c2,c3]
DEBUG CLS,HEX ? c1,HEX ? c2,HEX ? c3
SEROUT 1,16468,
[noparse][[/noparse]$01, ' 1 = SOH
$30, ' 2 = target address byte
$31, ' 3 = target byte address 2
$30, ' 4 = read or write
$31, ' 5 = data type
$30, ' 6 = starting address MSB
$34, ' 7 = starting address MSB
$30, ' 8 = starting address LSB
$31, ' 9 = starting address LSB
$30, ' 10= number of complete blocks
$30, ' 11= number of complete blocks
$30, ' 12= bytes in last block
$34, ' 13= bytes in last block
$30, ' 14= master ID
$30, ' 15= master ID
$17, ' 16= ETB
$30, ' 17= LRC1
$31] ' 18= LRC2
SERIN 0,16468,[noparse][[/noparse]STR plc\2]
DEBUG HEX ? plc(0),HEX ? plc(1),HEX ? plc(2)
END
Comments
I don't have my DL-06 manual in front of me, but I have a nagging feeling that the DL-06 can support DeviceNet in either sending or receiving but not both. I'll check and re-post.
Having said that, I could be wrong; in which case it may only be that the DL-06 is starting to talk back before the stamp is ready for the serin command. The DL-06 has a setting to make the plc wait for some period of time before returning the results of the query.
If this topic is of interest to a number of folks, maybe we could have it moved over to the Sandbox and work on this industrial plc - to- stamp communications.
Cheers
John
Sorry for the miss info, the example code shown has a LRC for ascii. I have tried it with just the hex LRC with the same results. You mentioned timing of the DLO6, as it might be sending the info before the BS2 is ready for it. Can you go into detail further on this as all I could find on the DL06 was for port 2.
jesawyers,
Wish I could but I am using a HMI off port 2 on the DL06, which leaves port 1 only left and the two choices are then type K and directnet. I do intend to look into modbus for another app on the boards.
*edit*
OOPS stand corrected I can use modbus on port 1 of the DL06 but cannot change any timing, will have to give modbus a shot.
Post Edited (Wrigly) : 11/28/2005 6:42:27 PM GMT
The delay before sending is described on page 4-48 of the DL06 user manual. Its set in the Comm port setup area and will let you put some time delay in before the plc sends data back to the stamp.
If you go the Modbus route, I'd be interested in your success. I tried it on an earlier project and found the checksum calculation to be a pain. But, there may be a way to hard code the check sum if you could get to the point of always issuing the same command. When the data comes back to the stamp, you could just ignore the checksum and use the data.
Cheers
Wrigly
The max232 chip won't take care of the parity problem, it just shifts the voltage levels of the signals.
Can you post your working modbus code? I assume the stamp is the Modbus master?
Cheers
SEROUT 15,16468,[noparse][[/noparse]01,03,04,32,00,10,197,55] ' v2040 forward data request
SERIN 7,16468,500,datacheck,[noparse][[/noparse]STR plc\16]
I cleared the plc string before each serin from the plc and then verfy first 3 bytes for address and data structure to insure refreshed data set when it times out to datacheck. I am reading a bigger section of data than I need durring each poll but leaves me more room for expansion in either the plc or stamp code as I need without rewriting the modbus request each time I change the data I am monitoring.
Anyone have any ideal either hardware or code wise on dealing with the odd parity issue?
thanks again
Wrigly
Thanks for the info. Makes future work easier to tackle!
·· As per our phone conversation I think at this point the better solution for a controller would be the SX28.· With SX/B you could use a familiar PBASIC Style language and accomplish this task using interrupts.· In fact, a couple of our engineers have indicated that it would be posible to develop a ring buffer and send/receive data at two different baud rates/parity/etc.
·· What I would recommend is to check out the PDF at the following link.· It is Al·Williams book "Exploring The SX" from our website.· Page 221 may have what you need to see this through.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com