Using PCAN in simulink real-time workshop

The free CAN Software API (Application Programming Interface) for Windows®
Frainville
Posts: 7
Joined: Thu 31. Mar 2011, 20:25

Using PCAN in simulink real-time workshop

Post by Frainville » Mon 4. Apr 2011, 19:37

Hi everybody,

I am currently working on an implementation of PCANbasic.dll into a matlab S-function to use the Pcan_usb in simulink real-time workshop for an hardware in the loop simulation setup.

I have been able to produce the S-function and make simulink communicate on the can network but i can't use it in real-time workshop because when i build the rtw model, i have unreferenced objects error (can_write, can_open and can_close)

is there anyone who done that before? i would like to have a hint on how to get the rtw compiler to find those dependencies.

it seems to be a problem with the __stdcall use in the .h since i tried with the lcc compiler i have the same error but when using mingw everything is correct (there are known issue with __stdcall in lcc)

if you have any ideas i could try out please advice me. i can give the code i use if you ask.

once working i plan to share the code open source

Thanks for your help.

Frainville
Posts: 7
Joined: Thu 31. Mar 2011, 20:25

Re: Using PCAN in simulink real-time workshop

Post by Frainville » Tue 5. Apr 2011, 15:04

I found a link on the matworks website wich indicate that the windows dll cannont be used with Real-time windows target. and we haeve to rewrite the whole device driver from scratch (using memory addresses)

http://www.mathworks.com/support/soluti ... on=1-190OK

is there any information available about the usb stream we have to send to use the Pcan_usb device?

is there any possibility that i could have help from peak-System to write these RTW drivers?

i think that a lot of people in the industry are using Hardware in the loop simulation and that the peak driver would be a good thing because we would not have to buy another can device from another manufacturer.

User avatar
U.Wilhelm
Sales & Support
Sales & Support
Posts: 1327
Joined: Fri 10. Sep 2010, 19:34

Re: Using PCAN in simulink real-time workshop

Post by U.Wilhelm » Tue 5. Apr 2011, 16:38

We have no experience in MatLab Simulink. But we have a Simulink and MatLab implementation for the older PCAN-Light API. Maybe this could help to start your work.
Attachments
Free-Version-Incl.SIMULINK-BLOCK.zip
Matlab & Simulink for PCAN-Light
(96.21 KiB) Downloaded 1331 times
--------------------------------
PEAK-System Technik
Technical Support Team
support@peak-system.com
-------------------------------

Frainville
Posts: 7
Joined: Thu 31. Mar 2011, 20:25

Re: Using PCAN in simulink real-time workshop

Post by Frainville » Tue 5. Apr 2011, 17:01

THank you very much, i will check what i can do with this!

rehofman
Posts: 7
Joined: Thu 17. Feb 2011, 22:30

Re: Using PCAN in simulink real-time workshop

Post by rehofman » Mon 11. Apr 2011, 08:43

U.Wilhelm wrote:We have no experience in MatLab Simulink. But we have a Simulink and MatLab implementation for the older PCAN-Light API. Maybe this could help to start your work.
Is there a 64bit implementation of this?

User avatar
U.Wilhelm
Sales & Support
Sales & Support
Posts: 1327
Joined: Fri 10. Sep 2010, 19:34

Re: Using PCAN in simulink real-time workshop

Post by U.Wilhelm » Tue 12. Apr 2011, 15:32

The pcan-light and pcan-basic DLLs are available as 64Bit version, so it should be possible to use this DLLs for build a 64Bit Version of a SimuLink Interface.

PCAN-Basic files (32/64Bit):
http://www.peak-system.com/fileadmin/me ... -basic.zip

PCAN-Light files (32/64Bit):
http://www.peak-system.com/fileadmin/me ... -light.zip
--------------------------------
PEAK-System Technik
Technical Support Team
support@peak-system.com
-------------------------------

rehofman
Posts: 7
Joined: Thu 17. Feb 2011, 22:30

Re: Using PCAN in simulink real-time workshop

Post by rehofman » Tue 12. Apr 2011, 18:25

My programming-skills aren't good enought for building a 64Bit Version. I'm now using the 32Bit Version, which works fine, but I have to use another computer for that. If somebody compiled this Simulink implementation for 64Bit, it would be nice if he would share it.

User avatar
U.Wilhelm
Sales & Support
Sales & Support
Posts: 1327
Joined: Fri 10. Sep 2010, 19:34

Re: Using PCAN in simulink real-time workshop

Post by U.Wilhelm » Wed 13. Apr 2011, 11:08

I do not think that you need to do anythink special for building a 64Bit SimuLink Interface if Simulink run on 64Bit, but maybe someone else could help us who have the background knowledge ?
Last edited by U.Wilhelm on Wed 1. Jun 2011, 09:12, edited 1 time in total.
--------------------------------
PEAK-System Technik
Technical Support Team
support@peak-system.com
-------------------------------

Frainville
Posts: 7
Joined: Thu 31. Mar 2011, 20:25

Re: Using PCAN in simulink real-time workshop

Post by Frainville » Wed 13. Apr 2011, 20:36

Personally, i use a 32bit matlab into a vmware virtual machine. (real-time workshop is not available for 64bit with my version of matlab) but i guess you can recompile the s-functions using the matlab mex function.

rehofman
Posts: 7
Joined: Thu 17. Feb 2011, 22:30

Re: Using PCAN in simulink real-time workshop

Post by rehofman » Wed 13. Apr 2011, 21:37

I use it now in a WindowsXP 32bit in Oracle VirtualBox. I tried to recompile the s-functions, but I get errors. I don't have enough background knowledge and the time to make it myself. Thanks for the help and if someone compiled it for 64bit, it would be nice if he would share it.

Post Reply