Page 1 of 1

Arduino Nano and CAN coms (2)

Posted: Mon Jan 04, 2016 3:42 pm
by Chris_MIRA
Hi,
This may be me doing something silly OR may be a bug....
Im trying to use CAN comms with an arduino Nano. I set the baud rate in flowcode normally (see programme attached) but the speeds I get out are non-standard!

For instance, setting 500 Bus in flowcode gives a hardware output of 200 kbaud (measured) and setting 1000 bus rate in Flowcode gives a 400 kbaud output (measured).

Is this a scaling bug or something Im doing wrong?
Thanks in advance for your help!
:D
Chris

Re: Arduino Nano and CAN coms (2)

Posted: Mon Jan 04, 2016 3:43 pm
by Chris_MIRA
Ooops, forgot to load the programme....

Re: Arduino Nano and CAN coms (2)

Posted: Tue Jan 05, 2016 1:24 pm
by Benj
Hi Chris,

As your using the external CAN option via the MCP2515 chip the baud rate should be ok. The AVR is only responsible for the SPI rate which shouldn't effect the CAN data rate.

I know Leigh has fixed some bugs here recently for the internal CAN so I will ask him and see if he knows anything.

Re: Arduino Nano and CAN coms (2)

Posted: Tue Jan 05, 2016 2:55 pm
by Chris_MIRA
Hi Benj,
Thanks if you could ask, Im increasingly sure this is a bug rather than me doing something wrong, the CAN message id and data that is sent by the hardware is correct but the data rate (read directly from the hardware with resistor termination) is non-standard as I stated. Because the message is correct and is being sent at the correct time interval, Im not sure what else, other than a bug, it can be.... perhaps a scaling issue in the CAN macro?

regards,
Chris

Re: Arduino Nano and CAN coms (2)

Posted: Tue Jan 05, 2016 2:58 pm
by LeighM
Hi Chris,

Are you using your own MCP2515 hardware? (Or our e-block)
If so, are you using a 20MHz crystal/clock on MCP2515?

Leigh

Re: Arduino Nano and CAN coms (2)

Posted: Wed Jan 06, 2016 3:09 pm
by Chris_MIRA
Hi LeighM,

Im using a commercially available CAN module for the arduino Nano as it is to go into a product and is physically smaller. Im sure you have identified the problem as the oscillator on the module is 8Mhz rather than 20. As the Arduino CAN modules are very common and all seem to have the 8MHz clock (Ive just had a good look around on the internet and cant find any with other speeds), is it possible to provide a user input rate to the CAN module in FC6 or to accommodate different hardware clock speeds in another way? Im sure this would be very useful for others wanting to programme arduino and CAN in FC6.

Regards,
Chris

Re: Arduino Nano and CAN coms (2)

Posted: Wed Jan 06, 2016 3:37 pm
by LeighM
Hi Chris,

Thanks for the feedback, it looks like an 8Mhz/20Mhz option would be very useful, and shouldn't be too difficult to add to the component.
I'll try and get this done.

Leigh

Re: Arduino Nano and CAN coms (2)

Posted: Wed Jan 06, 2016 4:35 pm
by Chris_MIRA
LeighM,
That's great and would be really useful :D
have you any idea when you might be able to add a solution? Please let me know how things go.

regards,
Chris

Re: Arduino Nano and CAN coms (2)

Posted: Wed Jan 06, 2016 5:26 pm
by LeighM
Hi Chris,

Could you please try the attached updated component?
I've added the code, but not had chance to test it.

Thanks,
Leigh
ps. 1000 kbaud won't be very accurate at 8MHz xstal

Re: Arduino Nano and CAN coms (2)

Posted: Thu Jan 07, 2016 10:05 am
by Chris_MIRA
Leigh,
That's great, Im really impressed by the speed of response! Ive down loaded the file and hope to test later today... Ill let you know how I get on.
Thanks again for your response!

Regards

Chris

Re: Arduino Nano and CAN coms (2)

Posted: Thu Jan 07, 2016 1:02 pm
by Chris_MIRA
Leigh,

I have tried the new CAN component file and all seems to be working well! Thanks again.... Will this mod go into the next FC update? :D
regards,
Chris

Re: Arduino Nano and CAN coms (2)

Posted: Thu Jan 07, 2016 1:12 pm
by LeighM
Yes it will now that you have confirmed that it works :D

Thanks,
Leigh