Extreme Lag on Serial Line
in
Integration and Hardware
•
1 year ago
Hello, I've noticed that there have been multiple other posts about this problem but I haven't found that many of them have solutions and of the ones that do, none of them seemed to help with my lag. I'm working on a processing front panel to run a quadrotor I've built. When I use the Arduino serial terminal I get lightning fast serial connection and response, so i've been typing out all the feedback to the Arduino by hand. Obviously that's not practical, but a test to show wiring/OS is not the problem here, it has to be something in Processing.
The problem is right now I have feedback being sent to the dashboard about ten times per second and right now just the first bit of information is being parsed and displayed for simplicity purpose. This was extremely laggy so I decided to print to the terminal in processing. It appears that whenever the arduino sends "/t" or "/n" it will pause for 100 ms or so, just an estemate. Otherwise the chunks of text appear just as they should rapidly as they would in the Arduino term.
Another weird thing, just for thought is that the transmit is running lightning fast from the computer, I know this for sure because whenever I move the slider on the dashboard to change the throttle it will make the rx light on the quad pulse.
This is what I've got for the main code running the program:
- void setup() {
- size(360, 400);
- font = loadFont("BankGothicBT-Light-24.vlw");
- textFont(font);
- println(Serial.list());
- throttleBar = new VScrollbar(80, 20, 40, height - 95, 1);
- arduino = new Serial(this, Serial.list()[1], 57600);
- }
- void draw() {
- background(40);
- fill(255);
- lastThrottle = throttle;
- throttle = int(throttleBar.getPos());
- text("Throttle: \n" + throttle, 20, height - 50);
- text("xAng: " + xAng, 180, 45);
- throttleBar.update();
- throttleBar.display();
- sendData();
- //parseDashboardData();
- print(char(arduino.read()));
- }
- void sendData()
- {
- if (lastThrottle != throttle) {
- arduino.write("DAT:" + ((9 * throttle) + 1000) + ",");
- }
- //print(char(arduino.read()));
- }
Any help would be greatly appreciated.
Thanks!!
1