Arduino Software and FlowCode difference using CanBus-shield

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
kennethnilsen69
Posts: 101
Joined: Tue Sep 01, 2015 9:37 pm
Been thanked: 14 times
Contact:

Arduino Software and FlowCode difference using CanBus-shield

Post by kennethnilsen69 »

Hi I have a little trouble with understanding the difference between Arduino software and FlowCode using CAN component.

I've created two identical CAN send applications. 1 in FlowCode and 1 in Arduino software.

I connect my Arduino to my computer with ixxat CAN-To-USB interface and monitors traffic with my CananAnlyser Software.

When I use the file from Arduino Software everything works as it should and I can see the message in my CanAnalyser software.

When I use the file from FlowCode then I can not see any traffic in CanAnalyser Software.
But the file from FlowCode works and if I connect an Arduino reseiver which is programd with FlowCode resiever app then it sends messages properly. but I still can not see any traffic with CanAnalyser on my computer.
and if I connect an Arduino reseiver which is programmed with Arduino Software to this canbus which is programmed with FlowCode then everything gets unstable and no message arrives to the Arduino reseiver
All of them are set to the same baud-rate 500

Here are my two example files:
https://dl.dropboxusercontent.com/u/209 ... _Send.fcfx
and
https://dl.dropboxusercontent.com/u/209 ... m/send.ino


Is There some of you who can look at my files to see what is wrong?.

Do FlowCode use a completely different protocol or what?

I've never experienced that my IXXAT equipment fails to monitor traffic between CANbuses

if I stick to Arduino software then it works out all good and those units can be connected to a car that has an existing Canbus line.
but if I stick only to FlowCode then I can not use them in a car that has an existing Canbus net.

I have just purchased the pro version of flowcode so it had been the best if I could use it :-)

Thanks

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: Arduino Software and FlowCode difference using CanBus-sh

Post by kersing »

Have you checked the baudrate? (Or does the analyzer automatically determine the speed?) With two Flowcode programs the baudrate will match even if the setting does not reflect the required baudrate but other components using the correct speed will not see any data.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: Arduino Software and FlowCode difference using CanBus-sh

Post by LeighM »

You also might need to check the Tx ID.
Your Flowcode component is set to "Standard Only" you might need "Extended", as your ID seems to be outside the Standard range?
Also the SetTxID(0,100,0) macro expects the ID in MCP2515 register format,
you probably need to use SetTxIdent() macro

Another issue might be the Chip Select on Port B 2
This is the Slave Select input and I think this pin can cause issues,

kennethnilsen69
Posts: 101
Joined: Tue Sep 01, 2015 9:37 pm
Been thanked: 14 times
Contact:

Re: Arduino Software and FlowCode difference using CanBus-sh

Post by kennethnilsen69 »

kersing wrote:Have you checked the baudrate? (Or does the analyzer automatically determine the speed?) With two Flowcode programs the baudrate will match even if the setting does not reflect the required baudrate but other components using the correct speed will not see any data.
Yes I have, they all have the same baud-rate (500)
I am an experienced user of CanAnalyser so this program I have control over.
it's so strange it works fine when I program them with Arduino Software but not with FlowCode

and thank you for your input :-)
Last edited by kennethnilsen69 on Mon Sep 07, 2015 10:39 am, edited 1 time in total.

kennethnilsen69
Posts: 101
Joined: Tue Sep 01, 2015 9:37 pm
Been thanked: 14 times
Contact:

Re: Arduino Software and FlowCode difference using CanBus-sh

Post by kennethnilsen69 »

LeighM wrote:You also might need to check the Tx ID.
Your Flowcode component is set to "Standard Only" you might need "Extended", as your ID seems to be outside the Standard range?
Also the SetTxID(0,100,0) macro expects the ID in MCP2515 register format,
you probably need to use SetTxIdent() macro

Another issue might be the Chip Select on Port B 2
This is the Slave Select input and I think this pin can cause issues,
I have now set FlowCode to standard and extended format but it had no impact.
CanAnalyer also accepts standard and extended ID format.
I have now set CanAnalyser to Error Frame Detection and now I see the traffic but then only as error messages.


1. Can you explain a little closer about this?
Also the SetTxID (0,100,0) macro Expect the ID in MCP2515 register format,

SetTxID (0.100.0) is well standard format and not extended?
100 = 0x64 hex that is not extended format? or do I miss understand something here?.
do you mean standard format shall be like this? SetTxID (0.0.100)
but anyway I get the same result with this

2. Can you explain a little closer about this?
you probably need two use SetTxIdent () macro
How do I use this? you have an example to me

3. Regarding chip select portb2. It is this port I was informed by matix suport to use with my can shield. I did not get it to initialise before I put it to this port.

Which port you think it should be?
here is the CAN shield card I use
http://www.elecfreaks.com/store/canbus- ... p-746.html

Tanks

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: Arduino Software and FlowCode difference using CanBus-sh

Post by LeighM »

Hi
The SetTxID expects the high byte and low byte to be as to be written to the MCP2515 registers, which is the ID shifted left 5 bits.
So, in actual fact, sorry, yes, your 100,0 is within the Standard range.

The SetTxIdent takes the numeric value for the Identifier (without shifting).

Also, as kersing asked, just to check, is the on-wire data rate actually 500Kbs?
Does the analyzer give any clues with the error reporting?

The Flowcode component assumes a 20MHz crystal on the MCP2515, I've just noticed that the shield uses 16MHz!

I'll see if I can come up with a code fix.

Leigh

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: Arduino Software and FlowCode difference using CanBus-sh

Post by LeighM »

Try this inside a C icon placed just after the can::Initialise call.

Code: Select all

    FC_CAN_SPI_CAN_Config_1(128);
    FC_CAN_SPI_CAN_Write_1(42, 0x01);
    FC_CAN_SPI_CAN_Write_1(41, 0xc9);
    FC_CAN_SPI_CAN_Write_1(40, 0x02);
    FC_CAN_SPI_CAN_Config_1(0);

kennethnilsen69
Posts: 101
Joined: Tue Sep 01, 2015 9:37 pm
Been thanked: 14 times
Contact:

Re: Arduino Software and FlowCode difference using CanBus-sh

Post by kennethnilsen69 »

LeighM wrote:Try this inside a C icon placed just after the can::Initialise call.

Code: Select all

    FC_CAN_SPI_CAN_Config_1(128);
    FC_CAN_SPI_CAN_Write_1(42, 0x01);
    FC_CAN_SPI_CAN_Write_1(41, 0xc9);
    FC_CAN_SPI_CAN_Write_1(40, 0x02);
    FC_CAN_SPI_CAN_Config_1(0);

this is fantastic :-) this did the trick. :-)))
Now everything works as it should.
Do you have time to explain these 5 sentences?
I expect them to set it to 16MHz?

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: Arduino Software and FlowCode difference using CanBus-sh

Post by LeighM »

Code: Select all

// Set CAN bit time segments
// SyncSeg = 1, PropSeg = 2, PhaseSeg1 = 2, PhaseSeg2 = 3
// Total bits = 8 @ 16MHz/4 gives CAN Bit Time for 500kbs
FC_CAN_SPI_CAN_Config_1(128);		// put MCP2515 into CONFIG mode
FC_CAN_SPI_CAN_Write_1(42, 0x01);	// set CNF1 register to 0b00000001
FC_CAN_SPI_CAN_Write_1(41, 0xc9);	// set CNF2 register to 0b11001001
FC_CAN_SPI_CAN_Write_1(40, 0x02);	// set CNF3 register to 0b00000010
FC_CAN_SPI_CAN_Config_1(0);			// put MCP2515 into NORMAL mode
I've added some comments to the code.
Have a look at the MCP2515 datasheet for more info about the CNF registers.

Leigh

kennethnilsen69
Posts: 101
Joined: Tue Sep 01, 2015 9:37 pm
Been thanked: 14 times
Contact:

Re: Arduino Software and FlowCode difference using CanBus-sh

Post by kennethnilsen69 »

LeighM wrote:

Code: Select all

// Set CAN bit time segments
// SyncSeg = 1, PropSeg = 2, PhaseSeg1 = 2, PhaseSeg2 = 3
// Total bits = 8 @ 16MHz/4 gives CAN Bit Time for 500kbs
FC_CAN_SPI_CAN_Config_1(128);		// put MCP2515 into CONFIG mode
FC_CAN_SPI_CAN_Write_1(42, 0x01);	// set CNF1 register to 0b00000001
FC_CAN_SPI_CAN_Write_1(41, 0xc9);	// set CNF2 register to 0b11001001
FC_CAN_SPI_CAN_Write_1(40, 0x02);	// set CNF3 register to 0b00000010
FC_CAN_SPI_CAN_Config_1(0);			// put MCP2515 into NORMAL mode
I've added some comments to the code.
Have a look at the MCP2515 datasheet for more info about the CNF registers.

Leigh
Thanks so much Leigh. this is perfect :-)

is it possible you can help with a similar problem that I have with LCD 20x4 connected via this i2c card
http://www.ebay.com/itm/310565362720?_t ... EBIDX%3AIT
and this lcd
http://www.ebay.com/itm/400985247785?_t ... EBIDX%3AIT

the problem here is almost the same but here works lcd screen in Flow Code. it's just that it work so slowly that it becomes completely useless.
again here it works fine when I programerer with Arduino software but with Flow Code as it becomes insanely slow.
Here's my LCD i2c test file
https://dl.dropboxusercontent.com/u/209 ... code1.fcfx
Here's a youtube movie showing how slow it is.
https://www.youtube.com/watch?v=XlMkezQqFZA

hvodan can I speed up the i2c bus in flowcode?

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: Arduino Software and FlowCode difference using CanBus-sh

Post by LeighM »

Hi
These issues aren't related, might be best if you could start a new thread with this question,
then it will get the attention of anyone with experience with the I2C LCD component.
Thanks,

User avatar
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 Software and FlowCode difference using CanBus-sh

Post by Benj »

The I2C problem is answered on your other thread.

http://www.matrixtsl.com/mmforums/viewt ... 54&t=16828

Post Reply