nathandunk / BetterSerialPlotter

A drop-in replacement for the arduino serial plotter
MIT License
162 stars 25 forks source link

Support for Larger Baud Rates? #5

Open justiceamoh opened 2 years ago

justiceamoh commented 2 years ago

Incredible work with this Serial Plotter tool. I was keeping Arduino just for it's serial plotter function but yours is much better and completely replaces that.

Is it possible to support higher baud rates like 460800, 921600, etc. ? A number of recent arduino compatible boards like Sparkfun's Artemis have USB-serial chips that can tolerate much higher baudrates. I tried adding more baud rates in the header file:

https://github.com/nathandunk/BetterSerialPlotter/blob/173559047a3afbb6e7c3771088f7d484707d2db5/include/BetterSerialPlotter/SerialManager.hpp#L81-L96

But that didn't seem to work. Any suggestions?

nathandunk commented 1 year ago

Hi @justiceamoh. Glad you like the tool! Unfortunately, it seems like I didn't get a notification for this thread.

The baud rates are limited by the windows serial communication interface here, which only supports up to 256000. I haven't done any investigation to whether or not it could go higher with another resource, but it would probably be a large effort to change that at this point if it had to go to a different system.

justiceamoh commented 1 year ago

Thanks for getting back @nathandunk.

Ah makes sense that windows was the limit. I'm using macOS and the serial drivers there allow for higher baud rates. I agree it won't be trivial to transition to another serial driver. I appreciate your consideration though. Thanks!

maleiter commented 1 year ago

I tried adding more baud rates in the header file:

https://github.com/nathandunk/BetterSerialPlotter/blob/173559047a3afbb6e7c3771088f7d484707d2db5/include/BetterSerialPlotter/SerialManager.hpp#L81-L96

But that didn't seem to work. Any suggestions?

@justiceamoh You have to edit rs232.cpp of mahi-com as well. The function RS232_OpenComport has a switch-case statement, where you have to add the new baud rate.

This way, I can add support for up to 3Mbaud (tested on Windows).

nathandunk commented 1 year ago

@maleiter, thanks for the suggestion. If I were to add it to the main branch, do you have thoughts on whether it should have a new set of default baud rates? Or add a way to input your own baud rate? I would love to add the functionality without giving an overwhelming amount of options for a typical user.

maleiter commented 1 year ago

@nathandunk I'd suggest, that you keep the current set of default baud rates, but add the possibility to enter a custom baud rate. But this requires some changes in mahi-com. See https://github.com/maleiter/mahi-com/commit/6eebbf0da3f5588b457c2dc75781eb65fc2fce48 (implemented for Windows only)

nathandunk commented 1 year ago

So I have this implemented in Windows (attached), but apparently custom baud rates in linux is a mess... I would like to implement it in both before I add it to a release though. For now, this could be usable. BetterSerialPlotter-Windows-Custom-Baud.zip

ctadlock commented 1 year ago

FYI, for Teensy 4 the USB serial runs at the full 480 Mbit regardless of the baud setting. The app cant handle this and only draws the chart at the very end. Im assuming that is because some data buffer is full. If I add a 1 or 2 ms delay on each loop the app handles it better, which in effect is slowing the data rate. Also the app regularly silently crashes which is annoying.

https://www.pjrc.com/teensy/td_serial.html

image

nathandunk commented 1 year ago

@ctadlock, can you clarify what platform you are testing on and what release version you are using? I think this could likely be a problem with how I handled the data buffer which was just set to a number of data points, rather than scaling it by the data rate. So when the data rate is higher, it is still limited to that buffer size.

Can you zoom in the x-axis by scrolling and confirm whether or not the data looks correct based on your data rate, and there is just a small section of it at a time, or whether the data is just misrepresented entirely, which could be a different problem?

timoxd7 commented 1 year ago

@nathandunk i have the same problem. I took the current master branch and added a Baurate for me (921600) in the SerialManager.hpp only. Works fine so far, but i have the same problem as @ctadlock. For me, the x-axis has is only half filled but the values seem correct. On pause, i can double click and it fits perfectly in the whole x-length. Also, after doing this once, on resume it also fits like it should, removing the problem at all, also for newly added plots.

I use Windows, compiled with VS 2022 and use an ESP32.

nathandunk commented 1 year ago

Hi @timoxd7, rather than adding your own baudrate in source, can you see if using the custom baudrate test exe in the comment I made above also works with setting that baud rate? I don't have a Teensy, but I tested with an Arduino with the same baudrate and was able to get it to work. I will address the buffer size in your other post!

arbitur commented 1 year ago

Hi @justiceamoh. Glad you like the tool! Unfortunately, it seems like I didn't get a notification for this thread.

The baud rates are limited by the windows serial communication interface here, which only supports up to 256000. I haven't done any investigation to whether or not it could go higher with another resource, but it would probably be a large effort to change that at this point if it had to go to a different system.

The library states:

The baud rate at which the communications device operates. This member can be an actual baud rate value, or one of the following indexes.

I dont see the docs say you cannot use a baud above 256000.

timoxd7 commented 1 year ago

@nathandunk Works fine, same result as my compiled version before. I attached the picture below. Seems like about half of the graph is cut away. I don't know what i did, but once i was able to see the whole graph with the version i compiled, after pausing and moving the graph a bit around. But now i was not able to do this anymore and i don't know a way to redo this.

grafik