Hello everyone. I am Soichiro (Sam), an university student working in a robotics lab.
I am working on a project of humanoid robot's low level controller right now. The current objective is to obtain a sensor data from ATI mini45 with Net F/T board using Arduino + Seeed CAN-BUS shield v1.2.
What I am trying to do is to make a board to send a sensor data to Arduino. The Net F/T board is supposed to return a sensor data when Arduino sends a message request through CAN network.
However, currently it is not working the way it's supposed to. After Arduino receives a few messages from Net F/T board, it receives nothing. Also indicator LED flashes greeen, which means CAN connection is not established. (I also attached a few details about this issue.)
As I'm no expert about CAN protocol, I am doing what I can do. But I cannot figure out how to make this work. Can anyone help me with this issue? I would really appreciate it.
Your code sends a continuous stream of requests with no time gap to allow the F/T board to respond.
The documentation says "If a data request message is received during an ongoing transmission, the ongoing transmission will be terminated and the new request processed."
Therefore after sending a request you need to wait for a response before sending the next request.
Your code needs to do the following:
Send a request message.
Sit in a 'while loop' repeatedly checking to see if any data has arrived.
Only once you have received a message should you exit this while loop and send the next request.
There is no need for delay(). This just limits the rate at which you can send requests.
I have tried to wait the response with while loop under the condition below:
unsigned char smtp[1] = {0x01};
CAN.sendMsgBuf(0x1B0, 1, 1, stmp);
while (CAN.checkReceive() != CAN_MSGAVAIL) ;
//wait until there are available messages coming in
CAN.readMsgBuf(&len, buf);
//read a data coming in
But it does not seem like it's working.
What I'm getting from the board is:
CAN.checkReceive() gives the int value 4
CAN_MSGAVIAL gives the int value 3
I have finally fixed the problem. The thing was the configuration setting of the Net F/T board. After I changed the communication protocol, CAN_BUS communication got working.