Go Down

Topic: How to change sample rate for a sensor (LSM6DSOX) with Arduino Due code (Read 628 times) previous topic - next topic

tinuboss

Hello Forum

I have bought a couple of Adafruit LSM6DSOX sensors, code and data taken from here:  https://learn.adafruit.com/lsm6dsox-and-ism330dhc-6-dof-imu/arduino 

From the code, I am not able to see how I can change the sample rate. It samples by default with 104 Hz, and I want it to sample with either 3.3 kHz or 6.6 kHz, which should be possible. 

I'm quite new, but my guess is that the choosing part belongs to this part of the code:
Code: [Select]
// sox.setAccelDataRate(LSM6DS_RATE_12_5_HZ);
  Serial.print("Accelerometer data rate set to: ");
  switch (sox.getAccelDataRate()) {
    case LSM6DS_RATE_SHUTDOWN:
      Serial.println("0 Hz");
      break;
    case LSM6DS_RATE_12_5_HZ:
      Serial.println("12.5 Hz");
      break;
    case LSM6DS_RATE_26_HZ:
      Serial.println("26 Hz");
      break;
    case LSM6DS_RATE_52_HZ:
      Serial.println("52 Hz");
      break;
    case LSM6DS_RATE_104_HZ:
      Serial.println("104 Hz");
      break;
    case LSM6DS_RATE_208_HZ:
      Serial.println("208 Hz");
      break;
    case LSM6DS_RATE_416_HZ:
      Serial.println("416 Hz");
      break;
    case LSM6DS_RATE_833_HZ:
      Serial.println("833 Hz");
      break;
    case LSM6DS_RATE_1_66K_HZ:
      Serial.println("1.66 KHz");
      break;
    case LSM6DS_RATE_3_33K_HZ:
      Serial.println("3.33 KHz");
      break;
    case LSM6DS_RATE_6_66K_HZ:
      Serial.println("6.66 KHz");
      break;
  }


My Arduino code is this: 
Code: [Select]
// Basic demo for accelerometer & gyro readings from Adafruit
// LSM6DSOX sensor

#include <Adafruit_LSM6DSOX.h>

// For SPI mode, we need a CS pin
#define LSM_CS 10
// For software-SPI mode we need SCK/MOSI/MISO pins
#define LSM_SCK 13
#define LSM_MISO 12
#define LSM_MOSI 11

Adafruit_LSM6DSOX sox;
void setup(void) {
  Serial.begin(115200);
  while (!Serial)
    delay(10); // will pause Zero, Leonardo, etc until serial console opens

  Serial.println("Adafruit LSM6DSOX test!");

  if (!sox.begin_I2C()) {
    // if (!sox.begin_SPI(LSM_CS)) {
    // if (!sox.begin_SPI(LSM_CS, LSM_SCK, LSM_MISO, LSM_MOSI)) {
    // Serial.println("Failed to find LSM6DSOX chip");
    while (1) {
      delay(10);
    }
  }

  Serial.println("LSM6DSOX Found!");

  // sox.setAccelRange(LSM6DS_ACCEL_RANGE_2_G);
  Serial.print("Accelerometer range set to: ");
  switch (sox.getAccelRange()) {
    case LSM6DS_ACCEL_RANGE_2_G:
      Serial.println("+-2G");
      break;
    case LSM6DS_ACCEL_RANGE_4_G:
      Serial.println("+-4G");
      break;
    case LSM6DS_ACCEL_RANGE_8_G:
      Serial.println("+-8G");
      break;
    case LSM6DS_ACCEL_RANGE_16_G:
      Serial.println("+-16G");
      break;
  }

  // sox.setGyroRange(LSM6DS_GYRO_RANGE_250_DPS );
  Serial.print("Gyro range set to: ");
  switch (sox.getGyroRange()) {
    case LSM6DS_GYRO_RANGE_125_DPS:
      Serial.println("125 degrees/s");
      break;
    case LSM6DS_GYRO_RANGE_250_DPS:
      Serial.println("250 degrees/s");
      break;
    case LSM6DS_GYRO_RANGE_500_DPS:
      Serial.println("500 degrees/s");
      break;
    case LSM6DS_GYRO_RANGE_1000_DPS:
      Serial.println("1000 degrees/s");
      break;
    case LSM6DS_GYRO_RANGE_2000_DPS:
      Serial.println("2000 degrees/s");
      break;
    case ISM330DHCX_GYRO_RANGE_4000_DPS:
      break; // unsupported range for the DSOX
  }

  // sox.setAccelDataRate(LSM6DS_RATE_12_5_HZ);
  Serial.print("Accelerometer data rate set to: ");
  switch (sox.getAccelDataRate()) {
    case LSM6DS_RATE_SHUTDOWN:
      Serial.println("0 Hz");
      break;
    case LSM6DS_RATE_12_5_HZ:
      Serial.println("12.5 Hz");
      break;
    case LSM6DS_RATE_26_HZ:
      Serial.println("26 Hz");
      break;
    case LSM6DS_RATE_52_HZ:
      Serial.println("52 Hz");
      break;
    case LSM6DS_RATE_104_HZ:
      Serial.println("104 Hz");
      break;
    case LSM6DS_RATE_208_HZ:
      Serial.println("208 Hz");
      break;
    case LSM6DS_RATE_416_HZ:
      Serial.println("416 Hz");
      break;
    case LSM6DS_RATE_833_HZ:
      Serial.println("833 Hz");
      break;
    case LSM6DS_RATE_1_66K_HZ:
      Serial.println("1.66 KHz");
      break;
    case LSM6DS_RATE_3_33K_HZ:
      Serial.println("3.33 KHz");
      break;
    case LSM6DS_RATE_6_66K_HZ:
      Serial.println("6.66 KHz");
      break;
  }

  // sox.setGyroDataRate(LSM6DS_RATE_12_5_HZ);
  Serial.print("Gyro data rate set to: ");
  switch (sox.getGyroDataRate()) {
    case LSM6DS_RATE_SHUTDOWN:
      Serial.println("0 Hz");
      break;
    case LSM6DS_RATE_12_5_HZ:
      Serial.println("12.5 Hz");
      break;
    case LSM6DS_RATE_26_HZ:
      Serial.println("26 Hz");
      break;
    case LSM6DS_RATE_52_HZ:
      Serial.println("52 Hz");
      break;
    case LSM6DS_RATE_104_HZ:
      Serial.println("104 Hz");
      break;
    case LSM6DS_RATE_208_HZ:
      Serial.println("208 Hz");
      break;
    case LSM6DS_RATE_416_HZ:
      Serial.println("416 Hz");
      break;
    case LSM6DS_RATE_833_HZ:
      Serial.println("833 Hz");
      break;
    case LSM6DS_RATE_1_66K_HZ:
      Serial.println("1.66 KHz");
      break;
    case LSM6DS_RATE_3_33K_HZ:
      Serial.println("3.33 KHz");
      break;
    case LSM6DS_RATE_6_66K_HZ:
      Serial.println("6.66 KHz");
      break;
  }
}

void loop() {

  //  /* Get a new normalized sensor event */
  sensors_event_t accel;
  sensors_event_t gyro;
  sensors_event_t temp;
  sox.getEvent(&accel, &gyro, &temp);

 // Serial.print("\t\tTemperature ");
 // Serial.print(temp.temperature);
 // Serial.println(" deg C");

  /* Display the results (acceleration is measured in m/s^2) */
  Serial.print("\t\tAccel X: ");
  Serial.print(accel.acceleration.x);
  Serial.print(" \tY: ");
  Serial.print(accel.acceleration.y);
  Serial.print(" \tZ: ");
  Serial.print(accel.acceleration.z);
  Serial.println(" m/s^2 ");

  /* Display the results (rotation is measured in rad/s) */
 // Serial.print("\t\tGyro X: ");
  //Serial.print(gyro.gyro.x);
 // Serial.print(" \tY: ");
 // Serial.print(gyro.gyro.y);
 // Serial.print(" \tZ: ");
//  Serial.print(gyro.gyro.z);
 // Serial.println(" radians/s ");
 // Serial.println();

  delay(100);

  //  // serial plotter friendly format

  //  Serial.print(temp.temperature);
  //  Serial.print(",");

  // Serial.print(accel.acceleration.x);
  //  Serial.print(","); Serial.print(accel.acceleration.y);
  //  Serial.print(","); Serial.print(accel.acceleration.z);
  //  Serial.print(",");

  // Serial.print(gyro.gyro.x);
  // Serial.print(","); Serial.print(gyro.gyro.y);
  // Serial.print(","); Serial.print(gyro.gyro.z);
  // Serial.println();
  //  delayMicroseconds(10000);
}



Hopefully this is a easy fix. 



ard_newbie

Firstly, you should look over your sensor datasheet (Adafruit LSM6DSOX) and see what's the maximum permitted sample rate.

Next, take into account that any Serial.println() in loop() takes several tens of us. If you really need to see your sensor outputs on Serial monitor, you had better log into a buffer a serie of results obtained througout a precise sample frequency, AND after e.g. n results, output the buffer on Serial monitor.

To sample at a precise frequency, you might use an interrupt triggered by a Timer Counter (because 1/ 6.6 KHz ~151.5 us) rather than micros().
Search for antodom DUE Timer Counter library on github.

tinuboss

Hello Forum

I have bought a couple of Adafruit LSM6DSOX sensors, code and data taken from here:  https://learn.adafruit.com/lsm6dsox-and-ism330dhc-6-dof-imu/arduino

From the code, I am not able to see how I can change the sample rate seeing in serial monitor or putty to an exact value of 3.3kHz or 6.6kHz. The sensor samples by default with 104 Hz, and I want it to sample with either 3.3 kHz or 6.6 kHz, which I thought as an easy fix by using the sentence:
Code: [Select]
sox.setAccelDataRate(LSM6DS_RATE_3_33K_HZ);
sox.setGyroDataRate(LSM6DS_RATE_3_33K_HZ)


Super, know with that done I saw the code changing to say it samples with 3.3kHz, but the serial monitor sampled with approximately 9 hz. Hmm then I found a delay at the end which coursed this, and I then removed it. When now running the code I can't imagine what is causing the lower sampling rate. When I take a section of samples from the serial monitor, copying it into excel, I can see that it samples with approximately 315hz, which is less lower than 3.3kHz.

Im using arduino due and the programming port. I have tried using the native port, but can't get that up running. Is that the only way to fix this, and how can I use that in this case?
Code: [Select]



My Arduino code is this:
Code: [Select]


Code: [Select]
// Basic demo for accelerometer & gyro readings from Adafruit
// LSM6DSOX sensor

#include <Adafruit_LSM6DSOX.h>

// For SPI mode, we need a CS pin
#define LSM_CS 10
// For software-SPI mode we need SCK/MOSI/MISO pins
#define LSM_SCK 13
#define LSM_MISO 12
#define LSM_MOSI 11

Adafruit_LSM6DSOX sox;
void setup(void) {
  Serial.begin(115200);
  while (!Serial)
    delay(10); // will pause Zero, Leonardo, etc until serial console opens

  Serial.println("Adafruit LSM6DSOX test!");

  if (!sox.begin_I2C()) {
    // if (!sox.begin_SPI(LSM_CS)) {
    // if (!sox.begin_SPI(LSM_CS, LSM_SCK, LSM_MISO, LSM_MOSI)) {
    // Serial.println("Failed to find LSM6DSOX chip");
    while (1) {
      //delay(10);
    }
  }

  Serial.println("LSM6DSOX Found!");

  // sox.setAccelRange(LSM6DS_ACCEL_RANGE_2_G);
  Serial.print("Accelerometer range set to: ");
  switch (sox.getAccelRange()) {
  case LSM6DS_ACCEL_RANGE_2_G:
    Serial.println("+-2G");
    break;
  case LSM6DS_ACCEL_RANGE_4_G:
    Serial.println("+-4G");
    break;
  case LSM6DS_ACCEL_RANGE_8_G:
    Serial.println("+-8G");
    break;
  case LSM6DS_ACCEL_RANGE_16_G:
    Serial.println("+-16G");
    break;
  }

  // sox.setGyroRange(LSM6DS_GYRO_RANGE_250_DPS );
  Serial.print("Gyro range set to: ");
  switch (sox.getGyroRange()) {
  case LSM6DS_GYRO_RANGE_125_DPS:
    Serial.println("125 degrees/s");
    break;
  case LSM6DS_GYRO_RANGE_250_DPS:
    Serial.println("250 degrees/s");
    break;
  case LSM6DS_GYRO_RANGE_500_DPS:
    Serial.println("500 degrees/s");
    break;
  case LSM6DS_GYRO_RANGE_1000_DPS:
    Serial.println("1000 degrees/s");
    break;
  case LSM6DS_GYRO_RANGE_2000_DPS:
    Serial.println("2000 degrees/s");
    break;
  case ISM330DHCX_GYRO_RANGE_4000_DPS:
    break; // unsupported range for the DSOX
  }

  sox.setAccelDataRate(LSM6DS_RATE_6_66K_HZ);
  Serial.print("Accelerometer data rate set to: ");
  switch (sox.getAccelDataRate()) {
  case LSM6DS_RATE_SHUTDOWN:
    Serial.println("0 Hz");
    break;
  case LSM6DS_RATE_12_5_HZ:
    Serial.println("12.5 Hz");
    break;
  case LSM6DS_RATE_26_HZ:
    Serial.println("26 Hz");
    break;
  case LSM6DS_RATE_52_HZ:
    Serial.println("52 Hz");
    break;
  case LSM6DS_RATE_104_HZ:
    Serial.println("104 Hz");
    break;
  case LSM6DS_RATE_208_HZ:
    Serial.println("208 Hz");
    break;
  case LSM6DS_RATE_416_HZ:
    Serial.println("416 Hz");
    break;
  case LSM6DS_RATE_833_HZ:
    Serial.println("833 Hz");
    break;
  case LSM6DS_RATE_1_66K_HZ:
    Serial.println("1.66 KHz");
    break;
  case LSM6DS_RATE_3_33K_HZ:
    Serial.println("3.33 KHz");
    break;
  case LSM6DS_RATE_6_66K_HZ:
    Serial.println("6.66 KHz");
    break;
  }

  // sox.setGyroDataRate(LSM6DS_RATE_12_5_HZ);
  Serial.print("Gyro data rate set to: ");
  switch (sox.getGyroDataRate()) {
  case LSM6DS_RATE_SHUTDOWN:
    Serial.println("0 Hz");
    break;
  case LSM6DS_RATE_12_5_HZ:
    Serial.println("12.5 Hz");
    break;
  case LSM6DS_RATE_26_HZ:
    Serial.println("26 Hz");
    break;
  case LSM6DS_RATE_52_HZ:
    Serial.println("52 Hz");
    break;
  case LSM6DS_RATE_104_HZ:
    Serial.println("104 Hz");
    break;
  case LSM6DS_RATE_208_HZ:
    Serial.println("208 Hz");
    break;
  case LSM6DS_RATE_416_HZ:
    Serial.println("416 Hz");
    break;
  case LSM6DS_RATE_833_HZ:
    Serial.println("833 Hz");
    break;
  case LSM6DS_RATE_1_66K_HZ:
    Serial.println("1.66 KHz");
    break;
  case LSM6DS_RATE_3_33K_HZ:
    Serial.println("3.33 KHz");
    break;
  case LSM6DS_RATE_6_66K_HZ:
    Serial.println("6.66 KHz");
    break;
  }
}

void loop() {

  //  /* Get a new normalized sensor event */
  sensors_event_t accel;
  sensors_event_t gyro;
  sensors_event_t temp;
  sox.getEvent(&accel, &gyro, &temp);

 // Serial.print("\t\tTemperature ");
 // Serial.print(temp.temperature);
//  Serial.println(" deg C");

  /* Display the results (acceleration is measured in m/s^2) */
  Serial.print("\t\tAccel X: ");
  Serial.print(accel.acceleration.x);
  Serial.print(" \tY: ");
  Serial.print(accel.acceleration.y);
  Serial.print(" \tZ: ");
  Serial.print(accel.acceleration.z);
  Serial.println(" m/s^2 ");

  /* Display the results (rotation is measured in rad/s) */
 // Serial.print("\t\tGyro X: ");
 // Serial.print(gyro.gyro.x);
  //Serial.print(" \tY: ");
 // Serial.print(gyro.gyro.y);
 // Serial.print(" \tZ: ");
 // Serial.print(gyro.gyro.z);
 // Serial.println(" radians/s ");
 // Serial.println();

 // delayMicroseconds(4);

  //  // serial plotter friendly format

  //  Serial.print(temp.temperature);
  //  Serial.print(",");

  //  Serial.print(accel.acceleration.x);
  //  Serial.print(","); Serial.print(accel.acceleration.y);
  //  Serial.print(","); Serial.print(accel.acceleration.z);
  //  Serial.print(",");

  // Serial.print(gyro.gyro.x);
  // Serial.print(","); Serial.print(gyro.gyro.y);
  // Serial.print(","); Serial.print(gyro.gyro.z);
  // Serial.println();
  //  delayMicroseconds(10000);
}




Hopefully this is a easy fix.

dyso

I don't think your sampling rate is the issue here. I think its your Baudrate. You are using 115,200 bits per seconds. Which is 14,400 Bytes per second.

https://stackoverflow.com/questions/4850241/how-many-bits-or-bytes-are-there-in-a-character#:~:text=An%20ASCII%20character%20in%208,32%20bits%20(4%20bytes).

Is there a good reason why you want this sampling rate?

Also, as a tip, don't print so much useless information, e.g. m/s^2, accel and so on.
Just have it in a simple format and you can print in your setup what they are.
So you will get:

t,ax,ay,az,gx,gy,gz
I learn from criticism. So please let me know if I am wrong.

J-M-L

you might be limited by the ability of Serial to print fast enough. Don't use
Code: [Select]
  Serial.begin(115200);try with
Code: [Select]
  Serial.begin(1000000);and open the console at 1,000,000 bauds
Hello - Please do not PM me for help,  others will benefit as well if you post your question publicly on the forums.
Bonjour Pas de messages privés SVP, postez dans le forum directement pour que ça profite à tous

UKHeliBob

Duplicate topics moved to the same forum section and merged

Cross-posting is against the rules of the forum. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend 15 minutes (or more) writing a detailed answer on this topic, without knowing that someone else already did the same in the other topic.

Repeated cross-posting will result in a timeout from the forum.

In the future, please take some time to pick the forum board that best suits the topic of your question and then only post once to that forum board. This is basic forum etiquette, as explained in the sticky "How to use this forum - please read." post you will find at the top of every forum board. It contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

tinuboss

Thanks for the answers, but I have now tried to change to native port and changing baudrate, and the desired sample rate is not obtained. 

I have simplified the code and tried with this form the programmable port:


Code: [Select]

#include <Adafruit_LSM6DSOX.h>

Adafruit_LSM6DSOX sox;
void setup(void) {
  Serial.begin(115200);
  while (!Serial)
    //delay(1); // will pause Zero, Leonardo, etc until Serial console opens

  Serial.println("Adafruit LSM6DSOX test!");

  if (!sox.begin_I2C()) {
 
  }
sox.setAccelDataRate(LSM6DS_RATE_6_66K_HZ);
}

void loop() {

  //  /* Get a new normalized sensor event */
  sensors_event_t accel;
  sensors_event_t gyro;
  sensors_event_t temp;
  sox.getEvent(&accel, &gyro, &temp);


    Serial.print(accel.acceleration.x);
    Serial.print(","); Serial.print(accel.acceleration.y);
    Serial.print(","); Serial.print(accel.acceleration.z);
  //  Serial.print(",");
 
   Serial.println();
   // delayMicroseconds(666);
}


From this, I got a sampling rate of approximately 380hz when I take the numbers copying them into excel and look at how many samples per second. 

Then I have tried this code with the Native port: 
Code: [Select]

#include <Adafruit_LSM6DSOX.h>

Adafruit_LSM6DSOX sox;
void setup(void) {
  SerialUSB.begin(115200);
  while (!SerialUSB)
    //delay(1); // will pause Zero, Leonardo, etc until SerialUSB console opens

  SerialUSB.println("Adafruit LSM6DSOX test!");

  if (!sox.begin_I2C()) {
 
  }
sox.setAccelDataRate(LSM6DS_RATE_6_66K_HZ);
}

void loop() {

  //  /* Get a new normalized sensor event */
  sensors_event_t accel;
  sensors_event_t gyro;
  sensors_event_t temp;
  sox.getEvent(&accel, &gyro, &temp);


    SerialUSB.print(accel.acceleration.x);
    SerialUSB.print(","); SerialUSB.print(accel.acceleration.y);
    SerialUSB.print(","); SerialUSB.print(accel.acceleration.z);
  //  SerialUSB.print(",");
 
   SerialUSB.println();
   // delayMicroseconds(666);
}


From this, I get a sampling rate of approximately 290hz. 

When I'm trying with higher Baudrate for the programming port, it will only give useless data or no data. Does someone have a guess of what ells I can try?

P.S.
UKHeliBob I'm sorry about my duplicate, it was not intentionally. I thought I could delete the other post.. But it will not happen again! 

dyso

#7
Dec 14, 2020, 11:27 am Last Edit: Dec 14, 2020, 11:52 am by dyso Reason: False statement
Instead of just deciding to give a baud rate of some random number, calculate the minimum required baudrate. Your MCU has limitations, try to keep it as efficient as possible.
I learn from criticism. So please let me know if I am wrong.

J-M-L

Well, The maximum baudrate that the serial monitor has is 115200.
this is not a true statement...


----
You want to print stuff 6600 times per second.

Assuming you have ~60 characters on a line when you print, it means you need to be able to spit out 396 000 characters per second.

A character takes about 10 bits so it means your baud rate needs to be 3 960 000 bauds
You can't really go higher than 2 million bauds with your arduino and you require almost double that ==> won't work. Your Serial.print() will become the limiting factor as it's blocking the thread until it can spit the data out when its small buffer is full.

I would recommend to print way less data to the Serial console, just the values accX, accY and accZ separated with tabs without any extra text. With 2 digits after the decimal point like "0.48\t2.11\t9.57\n" this way
Code: [Select]
Serial.print(accX, 2);
Serial.write('\t');
Serial.print(accY, 2);
Serial.write('\t');
Serial.print(accZ, 2);
Serial.write('\n');

that will be ~15  bytes per line, and then 1 million bauds could possibly be working out (if not try 2 million bauds)





Hello - Please do not PM me for help,  others will benefit as well if you post your question publicly on the forums.
Bonjour Pas de messages privés SVP, postez dans le forum directement pour que ça profite à tous

dyso

I learn from criticism. So please let me know if I am wrong.

dyso

I learn from criticism. So please let me know if I am wrong.

ard_newbie

SerialUSB.write()  is waayyyyy faster. Try this out eventhough an interrupt triggered by a Timer Counter is certainly the right way to go.

tinuboss

J-M-L, I now tried your proposal to sample fewer data and but I can not figure out how to be able to use the higher baudrates in the serial monitor.
With this code, I can get the sampling rate up to 416 Hz, and that is absolutely better, but not yet good enough.

Code: [Select]
#include <Adafruit_LSM6DSOX.h>

Adafruit_LSM6DSOX sox;
void setup(void) {
  Serial.begin(115200);
  while (!Serial)
    //delay(1); // will pause Zero, Leonardo, etc until Serial console opens

    Serial.println("Adafruit LSM6DSOX test!");

  if (!sox.begin_I2C()) {

  }
  sox.setAccelDataRate(LSM6DS_RATE_6_66K_HZ);
  sox.setGyroDataRate(LSM6DS_RATE_6_66K_HZ);
}

void loop() {

  //  /* Get a new normalized sensor event */
  sensors_event_t accel;
  sensors_event_t gyro;
  sensors_event_t temp;
  sox.getEvent(&accel, &gyro, &temp);

Serial.print(accel.acceleration.x, 2);
Serial.write('\t');
Serial.print(accel.acceleration.y, 2);
Serial.write('\t');
Serial.print(accel.acceleration.z, 2);
Serial.write('\n');
  
  
}

 
If I instead use a higher Baudrate as you mention I get data in the format shown in the figure. Here I have been using 500000, but I tried with 1000000 and 2000000 as well, but only it got worse. This is data obtained with the programming port. If I instead use the Native port, I get no data no matter what I do.

ard_newbie, how do you propose to use the SerialUSB.write command? because it cannot be used with just:
Code: [Select]
Serial.write(accel.acceleration.x, 2);
Serial.write('\t');
Serial.write(accel.acceleration.y, 2);
Serial.write('\t');
Serial.write(accel.acceleration.z, 2);
Serial.write('\n');


And I would love to use the Timer Counter, but I definitely do not know how.



ard_newbie

A tip : Your favorite search engine is your best friend....

Plus search in the DUE sub forum either for SerialUSB.wrtite()/SerialUSB.print() or using a Timer counter with direct register programming or TC library from antodom on github with example sketches to trigger an interrupt.

J-M-L

Quote
ard_newbie, how do you propose to use the SerialUSB.write command? because it cannot be used with just:

Code: [Select]
Serial.write(accel.acceleration.x, 2);
Serial.write('\t');
Serial.write(accel.acceleration.y, 2);
Serial.write('\t');
Serial.write(accel.acceleration.z, 2);
Serial.write('\n');
I did not say to use write for everything.... use write only for the tabs or carriage return and print for the floats => cf the code I had provided.
Hello - Please do not PM me for help,  others will benefit as well if you post your question publicly on the forums.
Bonjour Pas de messages privés SVP, postez dans le forum directement pour que ça profite à tous

Go Up