R
I have the task of building a small J1939 to Modbus RTU gateway. I have to read about 20 PGNs from the J1939 data link with a Pic Micro, store them, then allow them to be retrieved via MB RTU.
I only need to update the registers approx. once per second, and the modbus request will be around 1 to 10 seconds depending on the data.
My concerns are... There is a lot of data coming across this link. Even the hardware filtered PGNs are coming at 100 ms. each so that is about 200 messages per second.
Is the best way to do this is to set a hardware filter for the range of PGNs I want, then use a software on the pic to rotate PGNs and accept them only as needed. Then process Modbus request in between.
Example, say I had 5 PGNs, and to keep it simple, I will use small numbers.....
Array of PGNs [1, 7, 12, 13, 26]
index = 0
CheckCan;
Get PGN number from array I want to wait on
Wait on PGN xx data to arrive
Got data from PGN xx so decode and store the data
If Index > 5 then Index = 0 else increment index
'Check for modbus request
Goto CheckCan
My Modbus will be on the USART and interrupt driven so it should jump to the modbus routines upon a request, process it, then go back to processing J1939 data. Would something like this work?
Richard
I only need to update the registers approx. once per second, and the modbus request will be around 1 to 10 seconds depending on the data.
My concerns are... There is a lot of data coming across this link. Even the hardware filtered PGNs are coming at 100 ms. each so that is about 200 messages per second.
Is the best way to do this is to set a hardware filter for the range of PGNs I want, then use a software on the pic to rotate PGNs and accept them only as needed. Then process Modbus request in between.
Example, say I had 5 PGNs, and to keep it simple, I will use small numbers.....
Array of PGNs [1, 7, 12, 13, 26]
index = 0
CheckCan;
Get PGN number from array I want to wait on
Wait on PGN xx data to arrive
Got data from PGN xx so decode and store the data
If Index > 5 then Index = 0 else increment index
'Check for modbus request
Goto CheckCan
My Modbus will be on the USART and interrupt driven so it should jump to the modbus routines upon a request, process it, then go back to processing J1939 data. Would something like this work?
Richard