Announcement

Collapse
No announcement yet.

Basic graph of sensor data

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Basic graph of sensor data

    Hello,

    I am very new to Arduino. I am trying to make a device that plots one axis of accelerometer data to the 2.4" TFT display on the 4Duino. I am using the 9 Axes Motion Shield.

    I currently have it running code which steams the data through serial and it is graphed on PC using the serial plotter feature of Arduino IDE.

    Does anyone know how I can convert this to graph on the LCD display instead?

    Below is the code that I am currently using to output through serial. (The sketch code file is attached as well)

    *I will send a small cash incentive via PayPal to anyone who can help me get this working. :-)

    Any help is greatly appreciated.

    Thanks!


    #include "NAxisMotion.h"
    #include <Wire.h>

    NAxisMotion mySensor;
    unsigned long lastStreamTime = 0;
    const int streamPeriod = 20; //To stream at 50Hz without using additional timers (time period(ms) =1000/frequency(Hz))
    bool updateSensorData = true; //Flag to update the sensor data. Default is true to perform the first read before the first stream

    void setup() //This code is executed once
    {
    //Peripheral Initialization
    Serial.begin(115200); //Initialize the Serial Port to view information on the Serial Monitor
    I2C.begin(); //Initialize I2C communication to the let the library communicate with the sensor.

    //Sensor Initialization
    mySensor.initSensor(); //The I2C Address can be changed here inside this function in the library
    mySensor.setOperationMode(OPERATION_MODE_NDOF); //Can be configured to other operation modes as desired
    mySensor.setUpdateMode(MANUAL); //The default is AUTO. Changing to MANUAL requires calling the relevant update functions prior to calling the read functions
    //Setting to MANUAL requires fewer reads to the sensor
    }

    void loop()
    {
    if (updateSensorData) //Keep the updating of data as a separate task
    {
    mySensor.updateLinearAccel();
    mySensor.updateCalibStatus(); //Update the Calibration Status
    updateSensorData = false;
    }

    if ((millis() - lastStreamTime) >= streamPeriod)
    {
    lastStreamTime = millis();

    //Acceleration

    //Serial.print(" AccelZ: ");
    Serial.print(mySensor.readLinearAccelZ());
    Serial.print(", ");


    Serial.println();

    updateSensorData = true;
    }
    }
    Attached Files

  • #2
    Hello Ryan,

    You can do this using the Draw Line & Move Origin command to plot this on the 4Duino and the redraw it when the trace reches the end so instead of passing data to the 4Duino, you will be using the 4Duino to plot the lines on the display.

    Using Workshop you can paste your code above into the skeleton sketch when you start a new 4Duino project and just add the commands to plot the data on the display.

    I hope this helps

    Best regards

    Paul

    Comment


    • #3
      Thanks Paul! I will try out workshop tomorrow. I have been using the Arduino IDE.

      Comment

      Working...
      X