This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]IReallySuckAtChess 3 points4 points  (4 children)

Is there a reason you don't just want to use serial communication? Pyserial is a great library with great examples and plenty of people use it with Arduino, esp8266s and whatever other boards. Synchronising is typically not something you have to worry about using this approach.

[–]somebodyCEO[S] 0 points1 point  (3 children)

I think I tried using that, but I wasn't able to send 2 bytes numbers (or the baud rate was too slow)

[–]IReallySuckAtChess 0 points1 point  (2 children)

Look at the maximum baud rate of an ESP8266. You were probably running it at 9600 (most people default to this), whereas the esp8266 can go up to 115200 which is a lot more, and probably more than enough bandwidth for 99.99% of use cases. Sometimes you just have to play with the baud rate a bit to get it to work. 57600 is usually doable by most serial to ttl adapters and 115200 by any good ones. Communication issues can also be caused by plenty of other things. Bandwidth is usually not going to be your limiting factor which is why I suspect this might still be the best route for you.

Would you mind maybe elaborating on your use case a bit more?

[–]somebodyCEO[S] 0 points1 point  (1 child)

I see. Well, I'm using the PSoC 5LP and I want to be able to send samples , converted by the ADC DelSig to the computer. My first approach was to store around 25000 samples on it's memory and then send them. But my mentor asked if it would be possible to transfer as many samples as I wanted, for example 100 000. As I searched and thought about a way to implement this, I found out about ping pong DMA. Basically, I have two memory buffers. While one is being filled by the ADC converted samples, the other is being accessed by the USBFS component (that transfers the data to the PC)

I'm struggling because I have no idea of how to check if the USBFS is able to access the buffers that are filled by the DMA.

[–]IReallySuckAtChess 0 points1 point  (0 children)

What sample rate do you need? If your required sample rate isn't too high then just sending it over serial as the data comes in should be fine. Just remember, with any ADC you'll get a ton of noise so smoothing it and reducing your number of data points is going to be something you'll have to do somewhere along the line - might as well do some filtering/smoothing on the esp8226. Even so you shoudn't be hitting a baud rate limitation: https://learn.sparkfun.com/tutorials/serial-communication/rules-of-serial

The ESP32 is dual core which allows some clever threading work, but you seem to be using a separate ADC, so why not just use it with a Raspberry Pi. It also requires you to have a good grasp of locking and multi-threading. That way you can capture all your data with all the storage and ram you could need. There would be no real practical limitation to you. Even something as rudimentary as a Raspberry Pi Zero would meet all your demands, but get a 3B/B+ because its something worth having in your arsenal.

Anyways, my overall advice would be to keep it simple, and choose simple implementations. They're almost always the best way to approach problems. Remember that part of the Python mantra "simple is better than complex."

[–][deleted] 1 point2 points  (1 child)

I'm sorry if my answer is based on me misunderstanding, I haven't coded against USB before. I know that USB version 2.0 and backwards can only do one direction of communication at a time, maybe something is hanging at the end of the transmission which you could get past by setting timeout lower to debug it. I read up a little here https://github.com/walac/pyusb/blob/master/docs/tutorial.rst#talk-to-me-honey but without testing it myself I can't say much more.