Matlab to PSOC3

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

 Hi!

   

 

   

I wanted to send a matlab data file (.mat) to the psoc flash periodically via USB. 

   

So i wanted to ask where to start? How would I convert the .mat file to an acceptable transfer file type? 

   

 

   

Regards

   

Masab

0 Likes
16 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

For the transmission of data you may use the USBUART on the PSoC side and an emulated serial  interface (COMn:) on the PC-side.

   

Storing data in flash can be done with the emulated EEProm usermodule (latest Creator update!).

   

The question I have is: What do you intend to do with the matlab-file on the PSoC?

   

 

   

Bob

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

This just depends on what you want to do with this data file. Since my crystal ball is still in repair and you didn't tell us about your project, I would guess that a CSV file might be the simplest solution.

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

Forgot to mention that Matlab can write CSV directly: www.mathworks.com/help/matlab/ref/csvwrite.html

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

@HLI, what about of creating a CBRC (Crystal Ball Repair Center, I would be in the boat!

   

 

   

Bob

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

Sure, as long as I don't need to promise any success with the repairs 🙂 I will only promise that it will be expensive...

0 Likes
Anonymous
Not applicable

Many thanks for the reply

   

I actually wanted to transmit a large speech signal from a converted matlab data file (about 3Mb in size) onto the PSOC EEPROM, with the data being overwritten to the EEPROM after it gets full (like a runtime acquisition of data using a FIFO). I'm using the CY8C001 kit.

   

i need to send the matlab file from the PSOC to an FPGA.

   

Will i have to write a seperate program on my PC to send this data?

   

Regards

   

Masab

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored
        Is the streaming in realtime? If yes, there is no need to write to the EEPROM (which not really large). If no - then the memory of the PSoC won't be enough to hold the file.   
Depending on the sample rate of the wave file you can get away witrh not needing a special program on the PC side. Using an UART would give you about 10 kbytes/second transfer rate, using an USBUART gives you at most 100kbytes per second.   
Both can be used with any program on the PC side being able to write to a serial port. For a wav file, I would suggest really generating one from the MatLab file, and then decode it on the PSoC side. Or maybe you extract the pure waveform stuff, and send just this over, in binary form (to save bandwidth).   
Can you explain a little bit more what this project is about?   
0 Likes
Anonymous
Not applicable

I actually wanted to stream neural signals (stored in my matlab data files) to the PSoC, real time would be better. These signals have been sampled at 20Kb/sec. 

   

I dont have a serial port in my PC, so i wanted to do it using the USB port. 

   

I then have to transmit these stored samples serially from the PSoC to an FPGA, on which the processing will be done. I'm not transmitting the samples directly to the FPGA because the transmission wouldnt remain synchornous.

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

A PSoC3 (looking at e.g. CY8C3866AXI-040) as 8kb of RAM, so it will be able to hold about 1/10th of a second worth of data in memory. It has up to 64kb of Flash, this would be up to 3 seconds of data.

   

So we are talking about continous data transfer here. If the PSoC has no other tasks, it would be just work as an USB pridge. In that case, using a specialized one might be better. Lokk at the FT232 chips (and their newer counterparts). Or e.g. the MCP2210 which is a USB-to-SPI bridge (which might make the FPGA part simpler).

0 Likes
Anonymous
Not applicable
        I would rather recommend using a Cypress EZ-USB FX2LP microcontroller with a dual port RAM chip. the FX2 can easily serve as a hight speed bridge and write data to ram that could be used later by the FPGA.   
0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

Silly me to forget about the Cypress parts 😞

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

At 20 Kb/s, read  2.5 KB/s, seems like no shortage of ways to do this.

   

Serial one wire could do this 🙂    

   

 

   

USB > PSOC > One wire/SPI/I2C/RS232/RS485/LVDS...........

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

 Yes, communication between the PSOC and an FPGA is no problem. 

But i have to do this using the PSOC3 on the CY8C001 kit only. So i only have to write the data to the USB serially, then read it on the PSOC using USBUART functions?

   

Also, does matlab write directly to a USB port?

   

Thanks

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Yes to both.

   

 

   

This might help.

   

 

   

http://forums.ni.com/t5/Multifunction-DAQ/simultaneous-input-output-USB-Daq-in-Matlab/td-p/681206

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

hi,

   

can any one help me, will matlab generate a c code automatically for a psoc embedded core?

0 Likes
Anonymous
Not applicable

Hi, No matlab does not create a C code for PSoC. You need to use PSoC Creator IDE to write code for PSoC. 

0 Likes