Page 1 of 1

Support for CAN Module?

Posted: Tue Apr 17, 2007 7:25 am
by malife
I have to say Wow! Shocked this is a really nice blockset, congratulations!

I have a question: is CAN support in the roadmap?

Thanks

Posted: Tue Apr 17, 2007 10:28 pm
by LubinKerhuel
Well,

I do not use CAN bus in my project due to its complex electronics.
Right now, I do not plan to build the CAN blockset since the documentation is very long and that it will take me quite a lot of time to achieve the user interface for all the options available.
So, depending how many people ask for it, I will read carefully the CAN chapter. But I guess that most people use SPI or I2C bus for small distance communication with fixed ground reference voltage.

Note that the "C function" block is there for you to implement unsupported peripheral (also, for recycling your "old fashion C written" algorithm you are proud of ! )

Lubin

Most projects I do also use CAN

Posted: Wed Aug 08, 2007 3:42 pm
by mlove
Its worth developing the CAN driver blocks as its is widely used. SPI and I2C are ok for on board devices like A/D etc, but CAN is far superior for noisy enviroments and long cable runs.

CAN Drivers

Posted: Sat Aug 11, 2007 7:06 pm
by p.erasmus
Hello Lubin

I would also like to see some CAN modules as CAN is widely used and will be in the industrie for some years to come.
I work with CAN intensivly and have a CAN test bench with a couple off CAN nodes on a Bus .
If it would help you I can help you in testing and running the code generated from the toolbox in realtime for you or supply you with the CAN basics which you may need .
This is just a offer that could help us to generate the modules for the toolbox.

Best Regards
Peter

Re: Support for CAN Module?

Posted: Tue Feb 19, 2008 11:59 pm
by LubinKerhuel
CAN peripheral is available on current version of the dsPIC blockset. I will write the doccumentation soon.
ECAN is not available yet. Is anybody interrested by ECAN ?

Yes, ECAN, please!

Posted: Tue Aug 26, 2008 12:21 pm
by Bernard Leak
We are very interested indeed in getting an ECAN block working.
We are using PIC variants which have ECAN but not CAN, and
that's what we will be offering our customers.
Our customers are certainly using CAN (as do we), often with
the MathWorks CANdb support), and we want to be able to offer
them CAN in their own models with the fullest possible
interoperability with (e.g.) CANdb support in MathWorks.
This will greatly encourage them to become dsPIC block-set
customers themselves!

Bernard Leak.

Re: Support for CAN Module?

Posted: Mon Sep 01, 2008 3:30 am
by malife
Yes I second that. ECAN Please :-)!!

Re: Support for CAN Module?

Posted: Wed Feb 11, 2009 7:06 pm
by Ender
One more Lumbin, Thanks. :D

Re: Support for CAN Module?

Posted: Wed Jul 15, 2009 11:13 pm
by gladiac
Very interested in ECAN. Hope it will come soon.Thanks Lubin!

Re: Support for CAN Module?

Posted: Mon Jul 27, 2009 8:00 pm
by bmairs
I would also like to vote for supporting ECAN. I have the 33f with ECAN and would like to be able to use it as a block.

It seems like a few different people are looking for this, are you thinking about developing an ECAN block?

Re: Support for CAN Module?

Posted: Thu Jul 30, 2009 11:08 am
by LubinKerhuel
Hello,

ECAN has lots of possibility and it is still difficult to start to work on it.
It's even more difficult now because I'm writing my PhD report and have some change planned in my private life (getting married soon).

Btw, if anyone has knowledge on ECAN and Simulink, I would be happy to discuss about the best way to implement it. How to make ECAN blocks that could provide all ECAN functions (like respond to a specific message...)
Would it be better to have as many ECAN blocks that there are different functions, of only a few (like CAN blocks)

Any suggestions are welcome.
I will start to works on it as soon as I can get enough free time.

Lubin

Re: Support for CAN Module?

Posted: Mon Jan 11, 2010 7:41 pm
by bmairs
I have currently started work on an ECAN library and corresponding blockset. It would be great to get your input on this, Lubin. The current codebase is available here: https://github.com/Susurrus/ECAN_dspic

Re: Support for CAN Module?

Posted: Tue Jan 12, 2010 12:53 pm
by LubinKerhuel
Hello,

thanks for sharing this work.
It would be very interresting to get an ECAN module compatible with the blockset.
I try to have a close look within few weeks (2 or 3) and provide my comments.

anyway, I wasn't able to clone the git repository, is it open access ? (I get the last zip file of the project)

Lubin

Re: Support for CAN Module?

Posted: Tue Jan 12, 2010 9:20 pm
by bmairs
I've fixed the repo. Should be publicly clonable. I'll try and add more documentation to it within the week to clear up some things.

Re: Support for CAN Module?

Posted: Sun Feb 07, 2010 12:51 am
by bmairs
I just wanted to update this thread briefly.

I'm currently stuck on an Embedded MATLAB block issue where it doesn't want to respect an infinite sampling time. After that is fixed, there blockset should be close to if not fully functional.

Re: Support for CAN Module?

Posted: Sun Feb 07, 2010 9:12 pm
by Bobes
Hello
that is great news, I am really looking forward to that as I will need ECAN soon to implement in my project (I am now waiting for some parts delivery, and PCB to be made) so in few weeks if not days I will be able to test. In case you need some help testing or so, I hope I will be able to help.
Thanks a lot
Josef

Re: Support for CAN Module?

Posted: Thu Feb 11, 2010 5:33 pm
by LubinKerhuel
I didn't get time yet to have a close look into the code.
(I just moved on 1st February, new job and whatever, but no yet internet home, thus, I am not really in right now )

Anyway, I will try to do it.
If I can help to find a workaround on the sampling time problem, let me know
Also, if some part of code needs to be included into the core code of the blockset to works fine, let me know also...
I just must be careful to maintain compatibility with others peripheral (potential problem may appear with DMA...)

Re: Support for CAN Module?

Posted: Fri Mar 19, 2010 9:28 pm
by Bobes
Hello,
are there any news? I have run in some problems with communication (UART is not enough :) ). I would like to try ECAN. Should I try using your code (or try to make mine), or should I wait?
Thanks
Kind regards
Josef
(sorry for me being inpatient, its just that the project deadline is getting closer)

Re: Support for CAN Module?

Posted: Wed Mar 31, 2010 4:55 pm
by Ender
Hi,
What do you mean by UART is not enough ?

Re: Support for CAN Module?

Posted: Wed Mar 31, 2010 8:13 pm
by Bobes
1/ I need to communicate between more than two dsPICs
2/ I need to send and receive more bytes in one time step (sending is not a problem, but receiving is slightly a problem)

Re: Support for CAN Module?

Posted: Wed Mar 31, 2010 11:36 pm
by LubinKerhuel
Hey,

Few news from ECAN : Bryant (bmair on the forum) is updating his code for ECAN. This code can be found (see previous post)
I would advise to use it.

I will do an ECAN block based on his code (with his agreement), anyway, I haven't do it yet (as you may see I just release new blockset supporting matlab 64bits, and working on windows 7 (64 bits) !)

I couldn't give date as I always have to postpone it, but this is in the pipe anyway ! I hope to do it soon !

Lubin

Re: Support for CAN Module?

Posted: Thu Apr 01, 2010 8:09 am
by Ender
Bobes wrote:1/ I need to communicate between more than two dsPICs
2/ I need to send and receive more bytes in one time step (sending is not a problem, but receiving is slightly a problem)
It's very good news from Lubin and Bryant. :D

But, if your deadline is very short, maybe you better have to build a multipoint with the Uart and some RS422 / RS485 tranceivers.
If the speed at 921600kbaud/s is enough sure.

Re: Support for CAN Module?

Posted: Fri Apr 02, 2010 4:12 pm
by Bobes
thanks, that is good idea. But I did agree in the beginning of the project to CAN, just did not realize some other things that I have to do, so I am in a bit of stress now :)
Anyway... I have noticed new toolbox version, thanks for the debugging support! I will start with the ECAN part of my project now, as there is a new uC unit for the BUS. I have less than 2 months now to finish my project and write my diploma work... uff.
Sorry for the off topic :)
Thanks once again!

Re: Support for CAN Module?

Posted: Sat Apr 03, 2010 2:57 pm
by Bobes
When I use the "configure ECAN1" block from the "blocks.mdl" I get an error:

Code: Select all

The function 'gcb' is not supported by Embedded MATLAB for code generation. See the documentation for eml.extrinsic to learn how you can use this function in simulation.

Function 'Configure ECAN 1/Subsystem5/Embedded MATLAB Function' (#251.109.112), line 4, column 43:
"gcb"
There is this:

Code: Select all

% Set the MIDE bit
cirxmnsid = bitshift(str2double(get_param(gcb, 'mask_0_rm')),3);

% Set the SID bits
% Split the eid from the sid if necessary
sid = fi(get_param(gcb, 'mask_0'));
eid = 0;
if sid > 2^11-1
    eid = bitshift(sid, -11);
    sid = sis & 2047;
end
The config block from the example is somehow different and I can compile it without error... just there is obviously a difference there...

Re: Support for CAN Module?

Posted: Sun Apr 04, 2010 11:30 pm
by Bobes
somethink strange...
I am trying to get the ECAN alive (actually I am using just 2.0A)
when I compile the model in MATLAB, It get stuck after it transmits the message (I have USB-CAN to monitor the bus)
when I loaded the generated C code into MPLAB and run the debuger mode, or even compiled it in MPLAB, it works as I would expect...

If anyone has any idea where may be the problem.. please let me know
Thanks!

Re: Support for CAN Module?

Posted: Tue Apr 06, 2010 9:51 pm
by Bobes
new fact:
I have noticed similar behavior with I2C: my colleague is implementing I2C, He is not using I2C part of the block-set for sending and reading data, but he is using C-call. When we compiled through matlab, there was a problem with reading sequence, but when we used generated c code in MPLAB project, it started working! I do not have the code now on me to post it, but I am starting to think, that the problem may be somewhere in the compilation process, perhaps some argument settings for calling the MPLAB?

One note on block used in Example "Simulink echo": ECAN1 TX
I think, that the Sample Time has to be set (at least to -1) even when using trigger (I got errors, when I had left it in one value, and used another for some input)

Re: Support for CAN Module?

Posted: Tue Apr 06, 2010 10:45 pm
by LubinKerhuel
You may compare the configuration bits.

What if you compile/run in MPLAB with release mode ?
I often noticed very weird behavious using MPLAB debugger. Thus, I usually avoid using it.

If more option are required in the blockset for the compilation process, just let me know !
Lubin

Re: Support for CAN Module?

Posted: Tue Apr 06, 2010 11:44 pm
by Bobes
When I use MPLAB, it works both ways (debug, release)...
Config Bits:
There are differences on F80002 and F8000E... not that I do know why, but somehow It does not seem unexpected
I guess that the problem can be in F80002, as that is the difference between working and not working...

update: I am looking at note 25 - device config:
F80002 is FSS - Secure Code Segment Configuration Register
00FF
FFFF

If I read interpret those values correctly: according to section 25: bit 23-8 are Unimplemented, therefore there should be no difference between 00FF and FFFF hmm.. that is just 16 bits?

as for F8000R - FICD
FFDF 1111 1111 1101 1111
FF5F 1111 1111 0101 1111
5 bit: Jtag off when 0
7 bit: Reserved, do not use. ?!


I am confused :/

Re: Support for CAN Module?

Posted: Thu Apr 08, 2010 8:05 pm
by LubinKerhuel
Let me know how to force first 8 bits of FSS to 0.
I can't force them adding & 255 into :

Code: Select all

 _FSS( RSS_NO_RAM & SSS_NO_FLASH & SWRP_WRPROTECT_OFF & 255)
Lubin

Re: Support for CAN Module?

Posted: Sat Apr 10, 2010 1:32 pm
by Bobes
I will try to work that out, but it was done automaticly by MPLAB, when I used It to compile manually.. I did not change anything

Re: Support for CAN Module?

Posted: Fri May 07, 2010 11:48 pm
by Bobes
I have some further problems with buffers, I have started using more Rx and Tx blocks, Rx seems fine, but I dont see where to set Rx block for buffer which stores filtered data... Does the filter -> buffer feature work?

on Tx: when I set Tx buffers 1 2 3, and then for three Tx blocks use 1 2 and 3 it sends empty messages (only header, no data), I have all set to one buffer now, and that works, but the messages are not send at the rate they are supposed to. I have no (or couple) errors on the line.

I am using blocks from the example with circ buffer.

Re: Support for CAN Module?

Posted: Wed Jun 09, 2010 6:00 pm
by Bobes
Hi I have tried the new version, I have problems with the GCB command which seems not to be implemented in 2009a for embeded matlab. I have tried to work around this (passing the parameter by wire), there is still some small hinch I need to work out (mask = get_param(gcb,sprintf('filter_%d_mask',i)); - this is bit harder, but I am planning to use a vector maybe? not sure yet...). But I have noticed, that it also gave me an error for the "configure ECAN": in the mask, there is no filter_2_* defined only filter_0 and 1. I have added them... but I have to still finish the GCB workaround to see, if it will work. So that is all for now I think...

Re: Support for CAN Module?

Posted: Sat Dec 10, 2011 1:46 am
by bmairs
So I recently went through and updated my ECAN code. I also actively use these blocks, so it's known to be good. Link is here: https://github.com/Susurrus/ECAN_dspic. Just add it to your Matlab path as another library and you're good to go.

Re: Support for CAN Module?

Posted: Mon Apr 16, 2012 9:21 pm
by ambersil
bmairs wrote:So I recently went through and updated my ECAN code. I also actively use these blocks, so it's known to be good. Link is here: https://github.com/Susurrus/ECAN_dspic. Just add it to your Matlab path as another library and you're good to go.
Hello, I'm having a look at you blockset. I have C30 v3.23 and C32 v1.05 installed, with Matlab 2010a. Trying your two examples 'out of the box' I notice that a device which is targeted by the pic30 compiler failes to build because your code uses includes from the pic32 compiler (and vice versa). Does the toolbox require the new Microchip compiler ( I forget what it's called) which I understand targets all parts?

I'm a bit wary of having to upgrade the microchip tools in case it breaks somthing in Lubin's blockset. If anyone is using te ECAN code (and the dsPIC blockset) succesfully I would appreciate it if you could list the versions of the tools that you're using.

Re: Support for CAN Module?

Posted: Sat May 05, 2012 11:12 pm
by ambersil
Has anyone used bmairs ECAN blockset with a dsPIC33FJ256MC710 device?

I've spent a couple of days trying to transmit over CAN from the PIC with no success. I can transmit using the microchip code that accompanies AN1249 so I know that the hardware is OK.

I'm not sure if I'm doing something stupid or if there is a problem with bmairs code. If anyone has succesfully used it I'd appreciate a copy of a simple simulink model (that transmits) that is know to work so that I can see if it works with my setup.