chipKIT® Development Platform

Inspired by Arduino™

MAX32 and speed of serial data using Processing!?!

Created Thu, 23 Aug 2018 08:01:01 +0000 by aldoz


aldoz

Thu, 23 Aug 2018 08:01:01 +0000

Hi again, I am trying to get maximum performances about processing3 showing data of my MAX32 sketch.

When I used Arduino MEGA2560 I got great performances and my showed data (in the processing window) was almost in real time.

I used 115200 bits/s in Arduino sketch code and I AM NOT USING delay command on my Arduino main loop :

Serial.begin(115200 );

and I used this code to setup serial comunication in processing code:

port = new Serial(this, Serial.list()[1], 500000); // 115200 500000 initializing the object by assigning a port and baud rate (must match that of Arduino)
  port.clear();  // function from serial library that throws out the first reading, in case we started reading in the middle of a string from Arduino
  serial = port.readStringUntil(end); // function that reads the string from serial port until a println and then assigns string to our string variable (called 'serial')
  serial = null; // initially, the string will be null (empty)

Ok, so In the main loop of processing I have the following code that build a train of values arriving from Arduino sketch. I used cronoz variable to let processing waiting time to have all the ready strings (from Arduino) with certainty.

while (port.available() > 0) 
  { //as long as there is data coming from serial port, read it and store it 
    serial = port.readStringUntil(end);
  }
    if (serial != null) 
    {  //if the string is not empty, print the following
  
     String[] ax = split(serial, ','); //a new array (called 'a') that stores values into separate cells (separated by commas specified in your Arduino program)

     cronoz = cronoz + 1;
     if (cronoz >= 200)
     {
       cronoz = 200;// 

         for (int a = 0; a <= 63; a = a+1)  //a<=54
         {           
           val[a+1] = ax[a];
         }  
     }     
    }// fine if (serial != null)

Ok with Arduino just almost got real-time data show on my processing window! BUT If I use this configuration on my MAX32 just I get NOTHING.

So I tried to put 500000 instead 115200 in Arduino sketch and in the processing code too. Over that I need to delete "cronoz" variable so no more waiting time to have all the ready strings (from Arduino) with certainty.

Ok after these changes I get my processing window show my data but seems to be sloooow and with a lot of "frames per seconds" collapses.. In other words, NOTHING ABOUT REAL TIME.

what I need to do to configure it to take advance of big calculation power of my MAX32 and to get something similar to a real time data show on my processing window?

Thank you!