I have a 10m long twisted-pair CANbus terminated at each end with 120R. I have two identical nodes, each using a Teensy 3.2 and an MCP2562 transceiver (Vdd=5v, Vio=3v3), operating at 50Kbps. Node 1 just transmits a single message and then awaits any received messages and prints them. Node 2 awaits a received message, prints it, and transmits a single message in response.
This works fine. But I was interested in putting node 2 into STANDBY mode and having it wake up when it receives a message. I can't make this work because node 2 in STANDBY never receives the message sent by node 1 (although its transceiver does).
In more detail, from top to bottom, scope traces are:
node 2 transceiver RXD (yellow)
node 2 transceiver TXD (cyan)
CANH (dark blue)
CANL (magenta)
Here is the one where both nodes are in NORMAL mode. It works, and we see node 2 transmit an ACK:
Here is the one where node 2 transceiver is in STANDBY mode:
I expect the yellow trace (RXD) to see the message since RXD is active in STANDBY. I expect the recessive voltage levels to be lower since the node 2 transceiver passive load is at 0v rather than Vdd/2. What I did not expect is that the CANbus firwware in the node 2 Teensy would assert (what appears to be) an error frame on TXD. Also, even if the Teensy did assert something on TXD, I did not expect it to appear on the CANbus because node 2 is in STANDBY and cannot write to the bus.
One possibility is that the error frame (if it is one) seen on the CANbus is actually written by node 1 because it has not seen an ACK?? But why then, seperately, is node 2 writing to TXD? BTW node 1 does repeatedly transmit the message because it got no ACK.
More importantly, the software in node 2 Teensy does not see the message (can0.available() never true). I did not really expect node 2 to be able to read the message correctly whilst it is in STANDBY, but I was hoping it would read something, or get some interrupt, so that I can switch the transceiver to NORMAL mode and then recommence normal communications.
Note that for this test I am holding node 2 in STANDBY by wiring STBY pin to 1, the Teensy doesn't actually know that is so.
I have no idea what version of the CANbus library I am using (it is the default). How can I find out?
So my real question is: is there some way I can configure the software so I get a callback when a message is received whilst transciever is in STANDBY?
I don't think the Arduino programs are terribly relevant but extract them below anyway.
Node 1
Node 2
This works fine. But I was interested in putting node 2 into STANDBY mode and having it wake up when it receives a message. I can't make this work because node 2 in STANDBY never receives the message sent by node 1 (although its transceiver does).
In more detail, from top to bottom, scope traces are:
node 2 transceiver RXD (yellow)
node 2 transceiver TXD (cyan)
CANH (dark blue)
CANL (magenta)
Here is the one where both nodes are in NORMAL mode. It works, and we see node 2 transmit an ACK:
Here is the one where node 2 transceiver is in STANDBY mode:
I expect the yellow trace (RXD) to see the message since RXD is active in STANDBY. I expect the recessive voltage levels to be lower since the node 2 transceiver passive load is at 0v rather than Vdd/2. What I did not expect is that the CANbus firwware in the node 2 Teensy would assert (what appears to be) an error frame on TXD. Also, even if the Teensy did assert something on TXD, I did not expect it to appear on the CANbus because node 2 is in STANDBY and cannot write to the bus.
One possibility is that the error frame (if it is one) seen on the CANbus is actually written by node 1 because it has not seen an ACK?? But why then, seperately, is node 2 writing to TXD? BTW node 1 does repeatedly transmit the message because it got no ACK.
More importantly, the software in node 2 Teensy does not see the message (can0.available() never true). I did not really expect node 2 to be able to read the message correctly whilst it is in STANDBY, but I was hoping it would read something, or get some interrupt, so that I can switch the transceiver to NORMAL mode and then recommence normal communications.
Note that for this test I am holding node 2 in STANDBY by wiring STBY pin to 1, the Teensy doesn't actually know that is so.
I have no idea what version of the CANbus library I am using (it is the default). How can I find out?
So my real question is: is there some way I can configure the software so I get a callback when a message is received whilst transciever is in STANDBY?
I don't think the Arduino programs are terribly relevant but extract them below anyway.
Node 1
Code:
void loop(void)
{
CAN_message_t inMsg;
while (Can0.available())
{
Can0.read(inMsg);
Serial.print("RX: "); hexDump(8, inMsg.buf);
}
if (once) {
once = false;
msg.buf[0]++;
Can0.write(msg);
Serial.println(F("TX"));
}
delay(100);
}
Code:
void loop(void)
{
CAN_message_t inMsg;
while (Can0.available())
{ // This loop never executes when transceiver in STANDBY
Can0.read(inMsg);
Serial.print("RX: "); hexDump(8, inMsg.buf);
msg.buf[0]++;
Can0.write(msg);
Serial.println("TX");
delay(100);
}
delay(100);
}