Thanks Jerson. I made the mistake of already having the board made so I would like to try to see if I can do it with just one 485 transceiver. The J1708 looks like it is still being used and if I cannot get a modified J1708 protocol to work with a 485 connected the normal way, then my next try would be to try an actual J1708 transceiver. Maxxim makes one and it look as if it would be a drop-in replacement so I would have the expense of re-doing the board design.
I think I have base code working but for some reason the 485 enable line sits high - even after the packet should have been delivered..... which tells me the program thinks there is still stuff to transmit...... looking into it now....
Regards,
Steve
Code below:
Code:Node_ErrChk:'------------------------------------------------------------------- 'Checks the received node packet for data integrity and sends an ACK if good or a NAK if bad NodeWord=Node_Addr+Node_Cmd_Resp+Node_Bd+Node_Port_Dev Node_Sum_temp=NodeWord.byte0 ^ $FF 'Creates a local temp sumcheck used for comparison if Node_Sum_Temp <> Node_Sum then 'If the received checksum and the local checksum don't match, then.... error=1 'Turns ON error LED Node_Cmd_Resp=$03 'Form our NAK response Node_Addr=Address 'What our local address is Node_Bd=0 'Doesn't matter, we are asking for a retransmit Node_Port_Dev=0 'Same as above NodeWord=Node_Addr+Node_Cmd_Resp+Node_Bd+Node_Port_Dev 'Create our checksum Node_Sum=NodeWord.BYTE0 ^ $FF 'ditto ncts=1 'Enable transmission of 485 interface NodeLineBusy2: if BAUDCON1.6=1 then pauseus (Address*10) 'Checks to see if the receive operation is idle(1), if it is, pause for address*10 uS for random if BAUDCON1.6=0 then NodeLineBusy2 'Receive operation is still busy, if not, send packet hserout [sync,Node_Addr,Node_Cmd_Resp,Node_Bd,Node_Port_Dev,Node_Sum] 'Send command while not TXSTA1.1 : wend 'Wait for USART to finish xmitting ncts=0 'Places 485 interface back into receive mode else 'OR....... Status1=1 'Turns ON LED NodePktResp=Node_Cmd_Resp & $0F 'Strips off high order nibble to check for a NAK, put in local temp var - keeps packet integrity if NodePktResp=$03 then goto Node_ReXmit 'Got a NAK from the Control Computer so send it again if NodePktResp=$02 then Node_ErrChk_Exit 'We were ACKd, so just leave it alone 'Now we have received a node packet, believed to be good, so we will ADD $02 to 'the Node_Cmd_Resp byte we received and transmit back to Control PC so the PC 'knows everything is OK in our world....... and figure a new Checksum...... Node_Cmd_Resp=Node_Cmd_Resp + $02 'Adds the ACK to the byte for our response NodeWord=Node_Addr+Node_Cmd_Resp+Node_Bd+Node_Port_Dev 'Build our new checksum Node_Sum=NodeWord.BYTE0 ^ $FF 'ditto ncts=1 'Enable transmission of 485 interface NodeLineBusy3: if BAUDCON1.6=1 then pauseus (Address*10) 'Checks to see if the receive operation is idle(1), if it is, pause for address*10 uS for random if BAUDCON1.6=0 then NodeLineBusy3 'Receive operation is still busy, if not, send packet hserout [sync,Node_Addr,Node_Cmd_Resp,Node_Bd,Node_Port_Dev,Node_Sum] 'Send command while not TXSTA1.1 : wend 'Wait for USART to finish xmitting ncts=0 'Places 485 interface back into receive mode endif Node_ErrChk_Exit: Status1=0 'Turns OFF LED Error=0 'Turns OFF LED if it was ON node_PacketRcvd=0 'Zero the switch so we don't send other bytes return




Bookmarks