Arduino Nano and CAN coms (2)
Moderator: Benj
-
- Posts: 186
- Joined: Wed Jan 23, 2013 3:43 pm
- Has thanked: 2 times
- Been thanked: 21 times
- Contact:
Arduino Nano and CAN coms (2)
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!
Chris
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!
Chris
-
- Posts: 186
- Joined: Wed Jan 23, 2013 3:43 pm
- Has thanked: 2 times
- Been thanked: 21 times
- Contact:
Re: Arduino Nano and CAN coms (2)
Ooops, forgot to load the programme....
- Attachments
-
- Arduino Nano Test.fcfx
- (8.33 KiB) Downloaded 257 times
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Arduino Nano and CAN coms (2)
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 186
- Joined: Wed Jan 23, 2013 3:43 pm
- Has thanked: 2 times
- Been thanked: 21 times
- Contact:
Re: Arduino Nano and CAN coms (2)
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
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
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: Arduino Nano and CAN coms (2)
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
Are you using your own MCP2515 hardware? (Or our e-block)
If so, are you using a 20MHz crystal/clock on MCP2515?
Leigh
-
- Posts: 186
- Joined: Wed Jan 23, 2013 3:43 pm
- Has thanked: 2 times
- Been thanked: 21 times
- Contact:
Re: Arduino Nano and CAN coms (2)
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
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
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: Arduino Nano and CAN coms (2)
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
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
-
- Posts: 186
- Joined: Wed Jan 23, 2013 3:43 pm
- Has thanked: 2 times
- Been thanked: 21 times
- Contact:
Re: Arduino Nano and CAN coms (2)
LeighM,
That's great and would be really useful
have you any idea when you might be able to add a solution? Please let me know how things go.
regards,
Chris
That's great and would be really useful
have you any idea when you might be able to add a solution? Please let me know how things go.
regards,
Chris
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: Arduino Nano and CAN coms (2)
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
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
- Attachments
-
- CAN.fcpx
- (23.21 KiB) Downloaded 248 times
-
- Posts: 186
- Joined: Wed Jan 23, 2013 3:43 pm
- Has thanked: 2 times
- Been thanked: 21 times
- Contact:
Re: Arduino Nano and CAN coms (2)
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
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
-
- Posts: 186
- Joined: Wed Jan 23, 2013 3:43 pm
- Has thanked: 2 times
- Been thanked: 21 times
- Contact:
Re: Arduino Nano and CAN coms (2)
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?
regards,
Chris
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?
regards,
Chris
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: Arduino Nano and CAN coms (2)
Yes it will now that you have confirmed that it works
Thanks,
Leigh
Thanks,
Leigh