SEN0386 Update Rate Change Not Working

userHead DennisUnruh 2022-07-27 06:22:43 1243 Views2 Replies

Changed FREQUENCY_10HZ to FREQUENCY_5HZ in the ardunio sketch supplied by DfRobot.   The update rate did not change.

 

Here is the final sketch

 

/*!
  @file getLightIntensity.ino
  @Set the frequency of data output by the sensor, read the acceleration, angular velocity, and angle of X, Y, and Z axes.
  @n Experimental phenomenon: when the sensor starts, it outputs data at the set frequency and the data will be displayed on serial monitor
  @copyright   Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
  @licence     The MIT License (MIT)
  @author [huyujie]([email protected])
  @version  V1.0
  @date  2020-12-03
  @https://github.com/DFRobot
*/
#include <DFRobot_WT61PC.h>
#include <SoftwareSerial.h>

//Use software serial port RX:10,TX:11
SoftwareSerial mySerial(10, 11);

DFRobot_WT61PC sensor(&mySerial);
long int prevTime = millis();
int resultCount = 0;

void setup()
{
 //Use Serial as debugging serial port 
 Serial.begin(9600);
 //Use software serial port mySerial as communication seiral port 
 mySerial.begin(9600);
 //Revise the data output data frequncy of sensor FREQUENCY_0_1HZ for 0.1Hz, FREQUENCY_0_5HZ for 0.5Hz, FREQUENCY_1HZ for 1Hz, FREQUENCY_2HZ for 2Hz, 
 //                        FREQUENCY_5HZ for 5Hz, FREQUENCY_10HZ for 10Hz, FREQUENCY_20HZ for 20Hz, FREQUENCY_50HZ for 50Hz, 
 //                        FREQUENCY_100HZ for 100Hz, FREQUENCY_125HZ for 125Hz, FREQUENCY_200HZ for 200Hz.
 sensor.modifyFrequency(FREQUENCY_5HZ);
 Serial.println("DfRobot Test setup FREQUENCY_5HZ");
}


void loop()
{
 if (sensor.available()) {
   resultCount = resultCount + 1;
   if (resultCount > 5) {
     exit(0);
   }
   long int curTime = millis();
   long int deltaTime = curTime - prevTime;
   prevTime = curTime;
   Serial.print("deltaTime "); Serial.println(deltaTime);
   Serial.print("Acc\t"); Serial.print(sensor.Acc.X); Serial.print("\t"); Serial.print(sensor.Acc.Y); Serial.print("\t"); Serial.println(sensor.Acc.Z); //acceleration information of X,Y,Z
   Serial.print("Gyro\t"); Serial.print(sensor.Gyro.X); Serial.print("\t"); Serial.print(sensor.Gyro.Y); Serial.print("\t"); Serial.println(sensor.Gyro.Z); //angular velocity information of X,Y,Z
   Serial.print("Angle\t"); Serial.print(sensor.Angle.X); Serial.print("\t"); Serial.print(sensor.Angle.Y); Serial.print("\t"); Serial.println(sensor.Angle.Z); //angle information of X, Y, Z 
   Serial.println(" ");
 }


}

 

 

2023-01-24 16:46:21

It seems that it keeps not working. Also in the attached sample output, deltaTime=100msec, while at 5Hz it should have been 200. The same happens in my pc (at least so far): I measure a rate of about 10Sa/s, regardless of the selected frequency. 

Moreover, the old (incomplete) sketch is the only spreadly found in the websites of the SEN0386 commercial distributors.

userHeadPic Valerio.Biancalana
2022-07-27 06:36:02

I forgot to attach sample output.

 

DfRobot Test setup FREQUENCY_5HZdeltaTime 56Acc -0.29 -0.29 9.81Gyro 0.00 0.00 0.00Angle -1.72 1.68 0.13deltaTime 100Acc -0.29 -0.31 9.82Gyro 0.00 0.00 0.00Angle -1.72 1.68 0.13deltaTime 100Acc -0.29 -0.31 9.82Gyro 0.00 0.00 0.00Angle -1.72 1.68 0.13deltaTime 100Acc -0.28 -0.30 9.82Gyro 0.00 0.00 0.00Angle -1.72 1.68 0.13deltaTime 100Acc -0.28 -0.31 9.82Gyro 0.00 0.00 0.00Angle -1.72 1.68 0.13 

 

userHeadPic DennisUnruh