Using the Totalphase Cheetah interface with Matlab

Load, compile and interface to the Totalphase Cheetah SPI USB device
99 download
Aggiornato 20 giu 2016

Visualizza la licenza

In order to use the Cheetah SPI adapter from Totalphase (www.totalphase.com) you will need to compile the c-code and load the library into memory.
There are several dependencies that must be satisfied in order to properly compile, load and run the Cheetah SPI from the Matlab environment.
Here are the steps needed to make this work.
1) Install the proper compiler for your OS (in this case I will show how to use Windows 7)
1.1) I installed 'Microsoft Windows SDK 7.1 (C)' by using mex -setup
1.2) I needed to fix up my Windows environment by working through this link:
http://www.mathworks.com/matlabcentral/answers/95039-why-does-the-sdk-7-1-installation-fail-with-an-installation-failed-message-on-my-windows-system)
2) Install the cheetah application gui from Totalphase and connect the cheetah device to your usb and verify that you can connect and control the device. Close the application.

3) Download the cheetah.c, cheetah.h and cheetah.dll file from Totalphase web site and put them in an empty directory.
Note that you must match the dll version to the operating system version. Totalphase uses the same name for both their 32 bit dll and their 64 bit dll. You can check that you have the correct dll by opening a cmd prompt and typing "file cheetah.dll" from the command line in the directory where you have stored the file.
The 64 bit version will be "x86-64". The 32 bit version will be different.

4) Open Matlab and cd to the directory containing the 3 files that you just downloaded. Set the matlabpath to include this directory.

5) From the Matlab prompt type
[n, w] = loadlibrary('cheetah','cheetah.h','mfilename','cheetah_matlab');

This will create the following files:
cheetah_matlab.m
cheetah_thunk_pcwin64.lib
cheetah_thunk_pcwin64.dll
cheetah_thunk_pcwin64.obj
cheetah_thunk_pcwin64.exp

6) Place the spi2.m file from here in that directory.

7) Test that the device is functioning from Matlab. At the command prompt type:
>> dc=spi2;
>> dc

dc =

spi2 with properties:

cheetah: []
port_number: []
status: ''
bitrate: []
bytesShifted: 0
bytesInQueue: 0
miso: []
mosi: []
batchSize: 0
lastStatus: ''
queueSize: 0
lastError: []
CheetahStatus: [1x1 struct]
CheetahSpiPolarity: [1x1 struct]
CheetahSpiPhase: [1x1 struct]
CheetahSpiBitorder: [1x1 struct]
CheetahDefines: [1x1 struct]

>> dc.open;
>> dc

dc =

spi2 with properties:

cheetah: 1
port_number: 0
status: 'open'
bitrate: []
bytesShifted: 0
bytesInQueue: 0
miso: []
mosi: []
batchSize: 0
lastStatus: ''
queueSize: 0
lastError: []
CheetahStatus: [1x1 struct]
CheetahSpiPolarity: [1x1 struct]
CheetahSpiPhase: [1x1 struct]
CheetahSpiBitorder: [1x1 struct]
CheetahDefines: [1x1 struct]

>> dc.CheetahStatus

ans =

CH_OK: 0
CH_UNABLE_TO_LOAD_LIBRARY: -1
CH_UNABLE_TO_LOAD_DRIVER: -2
CH_UNABLE_TO_LOAD_FUNCTION: -3
CH_INCOMPATIBLE_LIBRARY: -4
CH_INCOMPATIBLE_DEVICE: -5
CH_INCOMPATIBLE_DRIVER: -6
CH_COMMUNICATION_ERROR: -7
CH_UNABLE_TO_OPEN: -8
CH_UNABLE_TO_CLOSE: -9
CH_INVALID_HANDLE: -10
CH_CONFIG_ERROR: -11
CH_UNKNOWN_PROTOCOL: -12
CH_STILL_ACTIVE: -13
CH_FUNCTION_NOT_AVAILABLE: -14
CH_OS_ERROR: -15
CH_SPI_WRITE_ERROR: -100
CH_SPI_BATCH_EMPTY_QUEUE: -101
CH_SPI_BATCH_SHORT_BUFFER: -102
CH_SPI_ASYNC_EMPTY: -103
CH_SPI_ASYNC_PENDING: -104
CH_SPI_ASYNC_MAX_REACHED: -105
CH_SPI_ASYNC_EXCESS_DELAY: -106

>> dc.find_devices()

ans =

32768

>> dc.showStatus()
Software rev: v3.08
Hardware rev: v1.00
Firmware rev: v3.08
Hardware revs for software: MAX:511, MIN:256
Firmware revs for software: MAX:776, MIN:776
Driver revs for software: MAX:511, MIN:257

Cita come

Patrick Moran (2025). Using the Totalphase Cheetah interface with Matlab (https://it.mathworks.com/matlabcentral/fileexchange/57775-using-the-totalphase-cheetah-interface-with-matlab), MATLAB Central File Exchange. Recuperato .

Compatibilità della release di MATLAB
Creato con R2016a
Compatibile con qualsiasi release
Compatibilità della piattaforma
Windows macOS Linux
Categorie
Scopri di più su Automotive in Help Center e MATLAB Answers
Community
Ulteriori file sono disponibili nella  Power Electronics Control Community

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Versione Pubblicato Note della release
1.0.0.0