Hey, another question: I've adjusted the void send to send multiple messages after eachother using a counter. I can enter the specific data pretty easily.
void send() {
if(counter==0) {
//--------Global Start nodes
data[0] = (char)(0x01); // NMT Start RemoteNode
data[1] = (char)(0x00); // Global
data[2] = (char)(0x00);
data[3] = (char)(0x00);
data[4] = (char)(0x00);
data[5] = (char)(0x00);
data[6] = (char)(0x00);
data[7] = (char)(0x00);
if(can1.write(CANMessage(0000,data,2))) {
printf("Startup sent \n");
}
led1 = !led1;
counter ++;
}
......
Now, when I first send a message with data[0] to data[7] all 0xFF and a datalength of 8, and then after that a message with data[0] 0x01 and the rest 0x00 with a datalength of 1, the following happens. The 0x01 overwrites, but the 0xFF's in the other data stays the same, even tho I specificly put them to 0x00 before putting the data in the CANmessage... (see full code and try entering the example I gave above)
With this program you can configure and run a CAN compatible (also LSS protocol compatible) motor through the mbed\'s CANbus.
Further more it gives a basic template that lets you create your own CAN messages.
I\'ve implemented a configuration and a running example that the program runs through.
Also there\'s 2 kinds of loops it can go into after it\'s ran through it\'s configuration and/or speed setting. It can continuously ask for the motor\'s status (node guarding kind of thing) OR it can continuously ask for the motor\'s position.
Make sure you have a if, (elsif), else structure so the counter doesn\'t run out of control.
I\'ve tried to put as many comments in as I could.
I hope it helps you in understanding the basics of CAN and running devices.
I\'m new to it myself, so any critisism is welcome.
Enjoy.
So this means atleast 2 things: 1). The limited length of the second message doesn't seem to cancel out any data in the bytes that aren't used.
2). Somehow the data 0xFF is stored? Perhaps because the new data IS cancelled out after all?
Anything I did wrong in my code? Am I beeing to specific for these forums? :p
Thanks,
Melchior
Hey, another question: I've adjusted the void send to send multiple messages after eachother using a counter. I can enter the specific data pretty easily.
Now, when I first send a message with data[0] to data[7] all 0xFF and a datalength of 8, and then after that a message with data[0] 0x01 and the rest 0x00 with a datalength of 1, the following happens. The 0x01 overwrites, but the 0xFF's in the other data stays the same, even tho I specificly put them to 0x00 before putting the data in the CANmessage... (see full code and try entering the example I gave above)
Import programCANtest
With this program you can configure and run a CAN compatible (also LSS protocol compatible) motor through the mbed\'s CANbus. Further more it gives a basic template that lets you create your own CAN messages. I\'ve implemented a configuration and a running example that the program runs through. Also there\'s 2 kinds of loops it can go into after it\'s ran through it\'s configuration and/or speed setting. It can continuously ask for the motor\'s status (node guarding kind of thing) OR it can continuously ask for the motor\'s position. Make sure you have a if, (elsif), else structure so the counter doesn\'t run out of control. I\'ve tried to put as many comments in as I could. I hope it helps you in understanding the basics of CAN and running devices. I\'m new to it myself, so any critisism is welcome. Enjoy.
Last commit 14 Feb 2011 by Melchior Pau
So this means atleast 2 things: 1). The limited length of the second message doesn't seem to cancel out any data in the bytes that aren't used. 2). Somehow the data 0xFF is stored? Perhaps because the new data IS cancelled out after all?
Anything I did wrong in my code? Am I beeing to specific for these forums? :p
Thanks,
Melchior