Bläddra i källkod

LowLatencyLogger mods

main
Bill Greiman 8 år sedan
förälder
incheckning
4afa5c15e8
7 ändrade filer med 36 tillägg och 15 borttagningar
  1. +8
    -2
      SdFat/examples/LowLatencyLogger/LowLatencyLogger.ino
  2. +5
    -5
      SdFat/examples/LowLatencyLogger/UserFunctions.cpp
  3. +2
    -2
      SdFat/examples/LowLatencyLogger/UserTypes.h
  4. +8
    -2
      SdFat/examples/LowLatencyLoggerADXL345/LowLatencyLogger.ino
  5. +3
    -0
      SdFat/examples/LowLatencyLoggerADXL345/UserFunctions.cpp
  6. +1
    -1
      SdFat/examples/LowLatencyLoggerADXL345/UserTypes.h
  7. +9
    -3
      SdFat/examples/LowLatencyLoggerMPU6050/LowLatencyLogger.ino

+ 8
- 2
SdFat/examples/LowLatencyLogger/LowLatencyLogger.ino Visa fil

@@ -95,7 +95,7 @@ const uint8_t BUFFER_BLOCK_COUNT = 12;
// Temporary log file. Will be deleted if a reset or power failure occurs.
#define TMP_FILE_NAME "tmp_log.bin"

// Size of file base name. Must not be larger than six.
// Size of file base name.
const uint8_t BASE_NAME_SIZE = sizeof(FILE_BASE_NAME) - 1;
const uint8_t FILE_NAME_DIM = BASE_NAME_SIZE + 7;
char binName[FILE_NAME_DIM] = FILE_BASE_NAME "00.bin";
@@ -550,13 +550,19 @@ void setup(void) {
if (sizeof(block_t) != 512) {
error("Invalid block size");
}
// Allow userSetup access to SPI bus.
pinMode(SD_CS_PIN, OUTPUT);
digitalWrite(SD_CS_PIN, HIGH);
// Setup sensors.
userSetup();
// Initialize at the highest speed supported by the board that is
// not over 50 MHz. Try a lower speed if SPI errors occur.
if (!sd.begin(SD_CS_PIN, SD_SCK_MHZ(50))) {
sd.initErrorPrint(&Serial);
fatalBlink();
}
userSetup();
}
//------------------------------------------------------------------------------
void loop(void) {

+ 5
- 5
SdFat/examples/LowLatencyLogger/UserFunctions.cpp Visa fil

@@ -2,7 +2,7 @@
// User data functions. Modify these functions for your data items.

// Start time for data
uint32_t startTime;
static uint32_t startMicros;

// Acquire a data record.
void acquireData(data_t* data) {
@@ -14,10 +14,10 @@ void acquireData(data_t* data) {

// Print a data record.
void printData(Print* pr, data_t* data) {
if (startTime == 0) {
startTime = data->time;
if (startMicros == 0) {
startMicros = data->time;
}
pr->print(data->time - startTime);
pr->print(data->time - startMicros);
for (int i = 0; i < ADC_DIM; i++) {
pr->write(',');
pr->print(data->adc[i]);
@@ -27,7 +27,7 @@ void printData(Print* pr, data_t* data) {

// Print data header.
void printHeader(Print* pr) {
startTime = 0;
startMicros = 0;
pr->print(F("micros"));
for (int i = 0; i < ADC_DIM; i++) {
pr->print(F(",adc"));

+ 2
- 2
SdFat/examples/LowLatencyLogger/UserTypes.h Visa fil

@@ -5,8 +5,8 @@
#define FILE_BASE_NAME "adc4pin"
const uint8_t ADC_DIM = 4;
struct data_t {
unsigned long time;
unsigned short adc[ADC_DIM];
uint32_t time;
uint16_t adc[ADC_DIM];
};
void acquireData(data_t* data);
void printData(Print* pr, data_t* data);

+ 8
- 2
SdFat/examples/LowLatencyLoggerADXL345/LowLatencyLogger.ino Visa fil

@@ -95,7 +95,7 @@ const uint8_t BUFFER_BLOCK_COUNT = 12;
// Temporary log file. Will be deleted if a reset or power failure occurs.
#define TMP_FILE_NAME "tmp_log.bin"

// Size of file base name. Must not be larger than six.
// Size of file base name.
const uint8_t BASE_NAME_SIZE = sizeof(FILE_BASE_NAME) - 1;
const uint8_t FILE_NAME_DIM = BASE_NAME_SIZE + 7;
char binName[FILE_NAME_DIM] = FILE_BASE_NAME "00.bin";
@@ -550,13 +550,19 @@ void setup(void) {
if (sizeof(block_t) != 512) {
error("Invalid block size");
}
// Allow userSetup access to SPI bus.
pinMode(SD_CS_PIN, OUTPUT);
digitalWrite(SD_CS_PIN, HIGH);
// Setup sensors.
userSetup();
// Initialize at the highest speed supported by the board that is
// not over 50 MHz. Try a lower speed if SPI errors occur.
if (!sd.begin(SD_CS_PIN, SD_SCK_MHZ(50))) {
sd.initErrorPrint(&Serial);
fatalBlink();
}
userSetup();
}
//------------------------------------------------------------------------------
void loop(void) {

+ 3
- 0
SdFat/examples/LowLatencyLoggerADXL345/UserFunctions.cpp Visa fil

@@ -16,10 +16,13 @@ const uint8_t DATAZ0 = 0x36; //Z-Axis Data 0
const uint8_t DATAZ1 = 0x37; //Z-Axis Data 1

void writeADXL345Register(const uint8_t registerAddress, const uint8_t value) {
// Max SPI clock frequency is 5 MHz with CPOL = 1 and CPHA = 1.
SPI.beginTransaction(SPISettings(5000000, MSBFIRST, SPI_MODE3));
digitalWrite(ADXL345_CS, LOW);
SPI.transfer(registerAddress);
SPI.transfer(value);
digitalWrite(ADXL345_CS, HIGH);
SPI.endTransaction();
}

void userSetup() {

+ 1
- 1
SdFat/examples/LowLatencyLoggerADXL345/UserTypes.h Visa fil

@@ -7,7 +7,7 @@
// User data types. Modify for your data items.
const uint8_t ACCEL_DIM = 3;
struct data_t {
unsigned long time;
uint32_t time;
int16_t accel[ACCEL_DIM];
};
void acquireData(data_t* data);

+ 9
- 3
SdFat/examples/LowLatencyLoggerMPU6050/LowLatencyLogger.ino Visa fil

@@ -50,7 +50,7 @@ const uint8_t SD_CS_PIN = SS;
#ifdef ERROR_LED_PIN
#undef ERROR_LED_PIN
#endif // ERROR_LED_PIN
const int8_t ERROR_LED_PIN = 3;
const int8_t ERROR_LED_PIN = -1;
//------------------------------------------------------------------------------
// File definitions.
//
@@ -95,7 +95,7 @@ const uint8_t BUFFER_BLOCK_COUNT = 12;
// Temporary log file. Will be deleted if a reset or power failure occurs.
#define TMP_FILE_NAME "tmp_log.bin"

// Size of file base name. Must not be larger than six.
// Size of file base name.
const uint8_t BASE_NAME_SIZE = sizeof(FILE_BASE_NAME) - 1;
const uint8_t FILE_NAME_DIM = BASE_NAME_SIZE + 7;
char binName[FILE_NAME_DIM] = FILE_BASE_NAME "00.bin";
@@ -550,13 +550,19 @@ void setup(void) {
if (sizeof(block_t) != 512) {
error("Invalid block size");
}
// Allow userSetup access to SPI bus.
pinMode(SD_CS_PIN, OUTPUT);
digitalWrite(SD_CS_PIN, HIGH);
// Setup sensors.
userSetup();
// Initialize at the highest speed supported by the board that is
// not over 50 MHz. Try a lower speed if SPI errors occur.
if (!sd.begin(SD_CS_PIN, SD_SCK_MHZ(50))) {
sd.initErrorPrint(&Serial);
fatalBlink();
}
userSetup();
}
//------------------------------------------------------------------------------
void loop(void) {

Laddar…
Avbryt
Spara