Support for CAN Module?

Post Reply
malife
Expert
Posts: 56
Joined: Tue Apr 17, 2007 7:24 am
Location: Santa Cruz, CA
Contact:

Support for CAN Module?

Post by malife » Tue Apr 17, 2007 7:25 am

I have to say Wow! Shocked this is a really nice blockset, congratulations!

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

Thanks

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Bayonne- France
Contact:

Post by LubinKerhuel » Tue Apr 17, 2007 10:28 pm

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

mlove
Posts: 4
Joined: Wed Aug 08, 2007 1:13 pm

Most projects I do also use CAN

Post by mlove » Wed Aug 08, 2007 3:42 pm

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.

p.erasmus
Posts: 12
Joined: Thu May 31, 2007 5:14 pm
Location: Mellingen
Contact:

CAN Drivers

Post by p.erasmus » Sat Aug 11, 2007 7:06 pm

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
Automotive Engineering

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Bayonne- France
Contact:

Re: Support for CAN Module?

Post by LubinKerhuel » Tue Feb 19, 2008 11:59 pm

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 ?

Bernard Leak
Posts: 18
Joined: Fri Aug 15, 2008 3:42 pm
Location: Armitage, Staffordshire, England

Yes, ECAN, please!

Post by Bernard Leak » Tue Aug 26, 2008 12:21 pm

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.

malife
Expert
Posts: 56
Joined: Tue Apr 17, 2007 7:24 am
Location: Santa Cruz, CA
Contact:

Re: Support for CAN Module?

Post by malife » Mon Sep 01, 2008 3:30 am

Yes I second that. ECAN Please :-)!!

Ender
Posts: 38
Joined: Thu Oct 09, 2008 5:20 pm
Location: Phoenix USA _ Grenoble Fr

Re: Support for CAN Module?

Post by Ender » Wed Feb 11, 2009 7:06 pm

One more Lumbin, Thanks. :D

gladiac
Posts: 17
Joined: Fri Jun 27, 2008 11:32 am
Location: Liverpool, UK

Re: Support for CAN Module?

Post by gladiac » Wed Jul 15, 2009 11:13 pm

Very interested in ECAN. Hope it will come soon.Thanks Lubin!

bmairs
Posts: 69
Joined: Mon Jul 27, 2009 7:51 pm

Re: Support for CAN Module?

Post by bmairs » Mon Jul 27, 2009 8:00 pm

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?

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Bayonne- France
Contact:

Re: Support for CAN Module?

Post by LubinKerhuel » Thu Jul 30, 2009 11:08 am

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

bmairs
Posts: 69
Joined: Mon Jul 27, 2009 7:51 pm

Re: Support for CAN Module?

Post by bmairs » Mon Jan 11, 2010 7:41 pm

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
Last edited by bmairs on Sat Dec 10, 2011 1:47 am, edited 1 time in total.

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Bayonne- France
Contact:

Re: Support for CAN Module?

Post by LubinKerhuel » Tue Jan 12, 2010 12:53 pm

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

bmairs
Posts: 69
Joined: Mon Jul 27, 2009 7:51 pm

Re: Support for CAN Module?

Post by bmairs » Tue Jan 12, 2010 9:20 pm

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.

bmairs
Posts: 69
Joined: Mon Jul 27, 2009 7:51 pm

Re: Support for CAN Module?

Post by bmairs » Sun Feb 07, 2010 12:51 am

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.

Bobes
Posts: 36
Joined: Wed Nov 25, 2009 11:27 am
Location: Brno, CZE
Contact:

Re: Support for CAN Module?

Post by Bobes » Sun Feb 07, 2010 9:12 pm

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

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Bayonne- France
Contact:

Re: Support for CAN Module?

Post by LubinKerhuel » Thu Feb 11, 2010 5:33 pm

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...)

Bobes
Posts: 36
Joined: Wed Nov 25, 2009 11:27 am
Location: Brno, CZE
Contact:

Re: Support for CAN Module?

Post by Bobes » Fri Mar 19, 2010 9:28 pm

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)

Ender
Posts: 38
Joined: Thu Oct 09, 2008 5:20 pm
Location: Phoenix USA _ Grenoble Fr

Re: Support for CAN Module?

Post by Ender » Wed Mar 31, 2010 4:55 pm

Hi,
What do you mean by UART is not enough ?

Bobes
Posts: 36
Joined: Wed Nov 25, 2009 11:27 am
Location: Brno, CZE
Contact:

Re: Support for CAN Module?

Post by Bobes » Wed Mar 31, 2010 8:13 pm

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)

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Bayonne- France
Contact:

Re: Support for CAN Module?

Post by LubinKerhuel » Wed Mar 31, 2010 11:36 pm

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

Ender
Posts: 38
Joined: Thu Oct 09, 2008 5:20 pm
Location: Phoenix USA _ Grenoble Fr

Re: Support for CAN Module?

Post by Ender » Thu Apr 01, 2010 8:09 am

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.

Bobes
Posts: 36
Joined: Wed Nov 25, 2009 11:27 am
Location: Brno, CZE
Contact:

Re: Support for CAN Module?

Post by Bobes » Fri Apr 02, 2010 4:12 pm

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!

Bobes
Posts: 36
Joined: Wed Nov 25, 2009 11:27 am
Location: Brno, CZE
Contact:

Re: Support for CAN Module?

Post by Bobes » Sat Apr 03, 2010 2:57 pm

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...

Bobes
Posts: 36
Joined: Wed Nov 25, 2009 11:27 am
Location: Brno, CZE
Contact:

Re: Support for CAN Module?

Post by Bobes » Sun Apr 04, 2010 11:30 pm

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!
Attachments
100403_ECAN_100404.rar
model + generated files + mplab project
(475.21 KiB) Downloaded 1135 times

Bobes
Posts: 36
Joined: Wed Nov 25, 2009 11:27 am
Location: Brno, CZE
Contact:

Re: Support for CAN Module?

Post by Bobes » Tue Apr 06, 2010 9:51 pm

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)
Last edited by Bobes on Tue Apr 06, 2010 11:17 pm, edited 1 time in total.

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Bayonne- France
Contact:

Re: Support for CAN Module?

Post by LubinKerhuel » Tue Apr 06, 2010 10:45 pm

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

Bobes
Posts: 36
Joined: Wed Nov 25, 2009 11:27 am
Location: Brno, CZE
Contact:

Re: Support for CAN Module?

Post by Bobes » Tue Apr 06, 2010 11:44 pm

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 :/
Attachments
MPLAB debug
MPLAB debug
MPLAB release
MPLAB release
config bits via MATLAB
config bits via MATLAB

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Bayonne- France
Contact:

Re: Support for CAN Module?

Post by LubinKerhuel » Thu Apr 08, 2010 8:05 pm

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

Bobes
Posts: 36
Joined: Wed Nov 25, 2009 11:27 am
Location: Brno, CZE
Contact:

Re: Support for CAN Module?

Post by Bobes » Sat Apr 10, 2010 1:32 pm

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

Bobes
Posts: 36
Joined: Wed Nov 25, 2009 11:27 am
Location: Brno, CZE
Contact:

Re: Support for CAN Module?

Post by Bobes » Fri May 07, 2010 11:48 pm

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.

Bobes
Posts: 36
Joined: Wed Nov 25, 2009 11:27 am
Location: Brno, CZE
Contact:

Re: Support for CAN Module?

Post by Bobes » Wed Jun 09, 2010 6:00 pm

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...

bmairs
Posts: 69
Joined: Mon Jul 27, 2009 7:51 pm

Re: Support for CAN Module?

Post by bmairs » Sat Dec 10, 2011 1:46 am

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.

ambersil
Posts: 5
Joined: Thu Mar 24, 2011 10:30 pm

Re: Support for CAN Module?

Post by ambersil » Mon Apr 16, 2012 9:21 pm

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.

ambersil
Posts: 5
Joined: Thu Mar 24, 2011 10:30 pm

Re: Support for CAN Module?

Post by ambersil » Sat May 05, 2012 11:12 pm

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests