Prev: Find approximate root of function of integer variable
Next: How to export a 26x11594 array into a excel file?
From: John on 13 Aug 2010 19:44 "Doug Olney" <olney_doug(a)keithley.com> wrote in message <eefa4ca.3(a)webx.raydaftYaTP>... > It is possible to call the ftdi dll directly from Matlab 7.0. The > trick is to create a reasonable .h file. I'm not good with MEX > files, so I just grabbed the FTDI documentation and created my own. > The key routines I use appear like this in the header file: > > long FT_Open( > int deviceNumber, > unsigned long int *pHandle > ); > > long FT_Close( > unsigned long ftHandle > ); > > long FT_Read( > unsigned long ftHandle, > unsigned long * lpBuffer, > unsigned long nBufferSize, > unsigned long * lpBytesReturned > ); > > > long FT_Write( > unsigned long ftHandle, > ussigned long * lpBuffer, > unsigned long nBufferSize, > unsigned long * lpBytesWritten > ); > > etc. > > Notice that I don't call ftHandle a void * - Matlab tends to crash > when I do that. So, I treat it as a 32 bit number I have to cart > around. > > With a good version of the .h file, the matlab syntax is: > > loadlibrary('FTD2XX.dll','myFTD2XXheader.h') > usbMem = uint32(0); > handlePtr = libpointer('uint32Ptr',usbMem); > deviceNum = 0; > retval = calllib('FTD2XX', 'FT_Open', deviceNum, handlePtr); > > handle = get(handlePtr,'Value'); > > The handle is then the first pass parameter to all the functions. > You have to FT_Close when you are done. If you are reading short > messages (one or two words) back, don't forget to use > FT_SetLatencyTimer to 1 ms, so the FTDI will flush out the partial > buffer. > > This was done on windows. > > Doug Olney > > Luiz Henrique Kleinmayer wrote: > > > > > > Hi... > > > > Jarrett, > > Did you make an implementation which uses > > ftd2xx.h / ftd2xx.lib to talk to an ftdi chip? > > I´m trying to do it, but it´s not working. > > Can you help me? > > > > Thanks > > Kleinmayer > > Stellar information. Do you have anymore code to share? I'm having a heck of a time setting the bit mode and writing to the device. Sadly, the VCP will not work for me.. I need to toggle individual pins. thanks. |