cancel
Showing results for 
Search instead for 
Did you mean: 

Receive high speed data from stm32 via com port

LSamc.1
Associate II

Hello. I am looking for an example or help, how i can receive data from stm32 at 100kHz with Python via com port ? ADC samples at around 100Khz and streams the data i am not sure how to receive it correctly at this high speed. Thanks  a lot 

5 REPLIES 5
TDK
Super User

Save data to a buffer and send out data in that buffer as it fills up. With USB, you will need to be able to handle random delays of 50ms or so.

In Python, the pyserial module can be used to connect to a serial port and read from it.

Start with sending a few bytes and ensure that works, then try more data once that is working.

If you feel a post has answered your question, please click "Accept as Solution".

Thank you for the reply. In my case, someone wrote a code that transmits data from stm32 at 100kHz, I don't know how to receive these data correctly via usb with python? how to unsure that the data is valid and what is actual speed at which i receive data?

thank you

If you're looking for help on building the PC-side application, this isn't anything STM32-specific. It's just a serial port at that point. As I said, try using the pyserial module.

If you feel a post has answered your question, please click "Accept as Solution".
Ozone
Principal

> ... how i can receive data from stm32 at 100kHz ... via com port ?
> ...ADC samples at around 100Khz  ...

I think this might not work out.
Even with only one channel and 12-bit samples, the throughput of your UART connection would have to be at least 100.000 x 2 x 10 bits per second. And this would be binary data, without any redundancy for error detection / correction. You need two bytes per sample, and at least 10 bits per byte (incl. start, stop, parity).

yes, I agree, according to my calculation i can only get 2880 samples per seconds.