yildi1337 / DAQv2

A Dual-Channel, 24-Bit, 256 kS/s Real-Time Hi-Speed USB 2.0 Data Acquisition (DAQ) Device based on STM32H7
22 stars 11 forks source link

VISA communication and automatic USB transfer #1

Open evenlund opened 1 year ago

evenlund commented 1 year ago

I was not sure where to ask you questions, as I don't have your contact details: This project is just a gem! I stumbled across this series of projects after more or less giving up on trying to send data from 7 I2S microphones (7 mics 3 bytes 44.1 ksamples/s * 8 bits/byte=7.4 Mbit/s) to the computer via USB-CDC FS, and now I am encouraged to continue.

Unfortunately I am not great at writing code and I am a bit unsure of how to start with the files in your firmware folder. I tried adding to an empty project, but it could not find the hal-files (not sure how to include them) and in a second try I started with a CUBEMX-generated project and overwrote the files in the core-folders. I have always used the route of letting CUBEMX generate the starting code.

In my own project I am sucessfully receiving the 7 I2S buffers with DMA ringbuffers which I transfer to two new data buffers, one for each I2S half complete when the interrupts are called. When all DMA to data transfers are done I send them to the USB buffer for transfer to the computer. I tried to use some primitive python code on the computer side to convert the 24-bit unsigned data to signed. There is no control of the data, so I miss pieces and am unable to get it to work.

I am not sure if I understand your code completely:

yildi1337 commented 1 year ago

Hi @evenlund!

I assume that transmitting data of your 7 mics with a data rate of 7.4 Mbit/s shouldn't be a problem because I am transmitting data at 16.384 Mbit/s. Which type of microcontroller are you using? I am using an external phy to support USB Hi-Speed (> 12 Mbit/s), however you should be fine with USB Full-Speed.

First of all it is important to include the relevant files for the USB connection from my project into your project:

As you mentioned you'll need the following files:

These files come from the STM32 USB Device Library: See here I don't remember exactly but I think that I downloaded these files from the mentioned repository and included it into my project in STM32CubeIDE.

Once this is done and your project compiles, you may need to adjust the USB connection settings. Especially the device descriptor in usb_data_device_descriptor.c (see main.h for the values of the defines). If the device is then correctly recognized by the USB host (PC), you can take care of sending the data. I am transmitting data simply via the function USB_DATA_TxEndpoint1 from usb_data.c.

Maybe try to include all the relevant files and to establish a connection to your PC. We can that talk again about how to transmit all data.

PS: On the PC side I used NI-VISA drivers in order to be able to simply receive all data in LabVIEW. Of course, you can also use another driver on the PC side.

evenlund commented 1 year ago

Hi @yildi1337,

Thank you for answering me so fast!

I am using the low performance F411RE (nucleo board) as it is the only stm32 device that I am aware of that has this many I2Ses except for the H7 with the SAIs. I have the H7 nucleo as well, but I will not use it if not necessary.

My dilemma if I should modify my current project is that I might break something related to the project being setup in CubeIDE/CubeMX initially, e.g. USB settings. The following files have been automatically added through CubeMX: Under USB_DEVICE\App

I seem to have all the STM32_USB_Device_Library include files except for "usbd_conf.h"

Do you suggest I try to remove all the USB_DEVICE files from CubeMX and add the ones you mention or that I start from an empty project and add your files, the hal library and the USB device library? I have never done the latter before and smell trouble. Perhaps it would be easier if you could export the old cubeide-project for the h7 and send through (if you still have it..)

PS! I like the idea that it is tightly integrated with LabVIEW, as this will probably also be my analysis/gui software.

yildi1337 commented 12 months ago

I can only support and answer questions if you use the corresponding USB files from my project. When using other files, even if they are similarly named, I can unfortunately not help, because I do not know them.

evenlund commented 11 months ago

Sorry to be of disturbance: I would be happy to use the corresponding USB files from DAQv2 if I was able to use them. The problem I see other people are struggling with also is that you need to specify some type of USB class when starting and generating a project in CubeIDE if you want to use the USB middleware. A custom USB class is not available from ST and USB is disabled if a class is not selected.

Did you use CubeIDE to generate the initial code or only as a debugging tool? How would you recommend I start if I want to use your USB-code in a new project for a different MCU than the STM32H753ZIT6 that you use? I can always use the STM32H743ZIT6 with a nucleo board if this can use the code directly.

thanhviet228 commented 1 week ago

Hello @yildi1337 . This is one of the best DAQ projects I have ever seen on the internet. If you can use ethernet to transmit data to the computer, it will be perfect. USB protocol is high speed but susceptible to interference and does not transmit far. Many times DAQ systems in industry must be placed near the sensor and cannot be placed near the control computer.