You need to log in to create posts and topics.

Is possible to plot data from arduino

Hello Mr. Arcachofo and friends, I would like to know if it is possible (or how to do it) to graph serial data from an Arduino like the Arduino IDE serial grapher does, i mean, the easy way. I see that I can connect a serial port to another program, perhaps to do the graphing job, but in Linux it is not easy for me.

I am simulating an IIR filter and I would like to see how it works, like in the oscilloscope. Any ideas are greatly appreciated
Of course, I take this opportunity to thank Mr. Arcachofo and his team for this wonderful software.

Best regards.

Hi.

I don't see an easy way to plot serial data.

I have no idea how is your project, but why don't you connect an Oscilloscope to the actual "output"?

Hello Mr. Arcachofo i saw your last videos on youtube about the script and how to make components, well if i find the way to do that i need i will post in this forum. The IIR digital filters are matematics filters with coeficients used in dsp world. I can use the oscilloscope the waves are not analog, because they are values (int or float) at fixed sample rate.

Best regards.

Pablo

P.D: Gracias por responder, ya veo que tienes acento Andaluz, asi que no seras de lejos de Santander. Muy buen trabajo amigo.

Hi.

I have been thinking about this.
Creating a plotter as an script is not that easy and the performance will not be good.

I think a simple and more efficient solution is an script that receive serial data and convert to a pin voltage.
Then connect an Oscilloscope to that pin.

A simple example would be like this:

Script:

IoPin@ txPin  = component.getPin("Tx");
IoPin@ outPin = component.getPin("Out");

const int BAUDRATE = 115200;

string m_buffer;

void setup() // Executed when Component is created
{
    print("Serial Plotter  setup() OK"); 
}

void reset() // Executed at Simulation start
{
    Uart0.setBaudRate( BAUDRATE );
    
    txPin.setOutState( true );
    txPin.setPinMode( 3 ); // Output
    
    outPin.setPinMode( 3 ); // Output
    
    m_buffer = "";
}

void byteReceived( uint d )
{
    if( d == 13 )  // String end at new line ( 13 = \n )
    {
        float voltage = parseFloat( m_buffer );
        outPin.setVoltage( voltage );
        m_buffer = "";
    }else{
        string c = " ";
        c[0] = d;
        m_buffer += c;
    }
}

 

.mcu file:

<iou name="Serial to Volt" core="scripted" script="Serial_to_Volt.as" >

  <ioport name="PORTA" pins="Rx,Tx,Out" />

  <usart name="Uart0" number="1">
    <trunit type="tx" pin="Tx" />
    <trunit type="rx" pin="Rx" />
  </usart>

</iou>

And then create a package with those 3 pins (Rx,Tx,Out) and connect to Arduino Tx and Rx.
In this case Arduino is sending float values from 0 to 5.

For example:

void setup() {
    Serial.begin( 115200 );
}
void loop() {
    int value = analogRead( A0 );
    float voltage = float(value)*5/1023;
    Serial.println( voltage );
}

 

Hello, Arcachofo, thank you very much for having dedicated your time and effort to resolve the issue. It works well, although as we increase the frequency the representation on the oscilloscope is not adequate, perhaps too many calculations. I will do the simulations on digital filters with frequencies from 10 to 200 Hz, I am sure your work will help me a lot.
Thank you very much again, I wish you the best.
Pablo