Post by keduro on Jul 16, 2020 16:31:11 GMT
Rowan - Rowan, no other optimisations as such to add. A couple of things I have done though are:
(a) added additional code in sendData (both overloads) so that when in DEBUG_MODE the identifier and value are printed in plain text rather than being encoded. I've found this useful when debugging eChook code as the output is easily viewed in the serial monitor window in the IDE using a wired connection to the nano in place of bluetooth. Avoids needing to run an additional app to decipher the code (though (as you are aware) I have also put together a windows app which does just that!!)
(b) added macros to Calibration.h to allow different configuration parameters for different cars whilst sharing the same code files. I found it easier to remember to change a #define in Calibration.h than to manage multiple calibration files for multiple cars, or managing multiple copies of the code. Here's an abridged version of our current Calibration.h (I've also added a couple of additional calibration values CAL_INVERT_BRAKE and CAL_THROTTLE):
Ben ... I'll post a separate reply re your current sensor testing as we're probably breaking all forum etiquette by discussing multiple topics in a single reply let alone within a single thread!
-- Keith.
(a) added additional code in sendData (both overloads) so that when in DEBUG_MODE the identifier and value are printed in plain text rather than being encoded. I've found this useful when debugging eChook code as the output is easily viewed in the serial monitor window in the IDE using a wired connection to the nano in place of bluetooth. Avoids needing to run an additional app to decipher the code (though (as you are aware) I have also put together a windows app which does just that!!)
(b) added macros to Calibration.h to allow different configuration parameters for different cars whilst sharing the same code files. I found it easier to remember to change a #define in Calibration.h than to manage multiple calibration files for multiple cars, or managing multiple copies of the code. Here's an abridged version of our current Calibration.h (I've also added a couple of additional calibration values CAL_INVERT_BRAKE and CAL_THROTTLE):
/*
* This file contains all the values used to calibrate your eChook board.
* By seperating these it makes it possible to update to newer code without
* having to copy your calibrations across - just make sure you keep this file!
*
* The values provided by default are for the eChook's team dev board, but each
* board is different. These defaults will give readings in the right ballpark,
* but for accuracy, see the documentation to calibrate your own board.
*
* Every variable in this file begins with CAL_ so that it is identifiable in
* the main code as being defined in this file.
*
*/
//================================================================================================================================
//
// SELECT eChook BOARD -- IMPORTANT !!
//
// Only ONE of the following BOARD_xxxxxx should be defined at any one time. Other defines should be commented out.
//
//#define BOARD_ELECTRON
#define BOARD_PHOTON
//
//================================================================================================================================
// Banchory Academy Electron (nee Fifty Shades of Green)
#if defined(BOARD_ELECTRON)
// Bluetooth Settings
const String CAL_BT_NAME = "eChook"; // Whatever you want to name your car's bluetooth
const String CAL_BT_PASSWORD = "1234"; // Changing password from default "1234" tends not to work yet - apologies!
// Car Specific Settings
const int CAL_WHEEL_MAGNETS = 3; // Number of magnets on wheel
const int CAL_MOTOR_MAGNETS = 6; // Number of magnets on motor shaft for hall effect sensor
const float CAL_WHEEL_CIRCUMFERENCE = 1.429; // Outer circumference of tyre, in Meters. i.e. the distance travelled in one revolution
const bool CAL_INVERT_BRAKE = false; // Invert brake output value - needed if brake input is normally low
// Board Specific Calibrations
const float CAL_REFERENCE_VOLTAGE = 5; // Voltage seen on the arduino 5V rail
const float CAL_BATTERY_TOTAL = (82000.0 + 16000.0) / 16000.0 * 0.993; // which should be 6.125, not 6.15 as provided originally. Final multiplier added to make eChook battery total match Fluke meter reading
const float CAL_BATTERY_LOWER = (82000.0 + 16000.0) / 16000.0 * 1.003; // which should be 6.125, not 6.15 as provided originally. Final multiplier added to make eChook battery lower match Fluke meter reading
const float CAL_CURRENT = 37.55; // Current Multiplier - See documentation for calibration method
// Board and Sensor Specific Calibrations
const float CAL_THERM_A = 0.001871300068; // Steinhart-Hart constants - See documentation for calibration method
const float CAL_THERM_B = 0.00009436080271;
const float CAL_THERM_C = 0.0000007954800125;
// Throttle adjustment
const float CAL_THROTTLE = 100.0 / 96.5; // Throttle scalar to account for throttle pot being supplied +5 from power controller and not from eChook
#endif
// Banchory Academy Photon
#if defined(BOARD_PHOTON)
// Bluetooth Settings
const String CAL_BT_NAME = "___kChook___"; // Whatever you want to name your car's bluetooth
const String CAL_BT_PASSWORD = "1234"; // Changing password from default "1234" tends not to work yet - apologies!
// Car Specific Settings
const int CAL_WHEEL_MAGNETS = 6; // Number of magnets on wheel
const int CAL_MOTOR_MAGNETS = 3; // Number of magnets on motor shaft for hall effect sensor
const float CAL_WHEEL_CIRCUMFERENCE = 1.181; // Outer circumference of tyre, in Meters. i.e. the distance travelled in one revolution
const bool CAL_INVERT_BRAKE = true; // Invert brake output value - needed if brake input is normally low
const float CAL_REFERENCE_VOLTAGE = 5; // Voltage seen on the arduino 5V rail
const float CAL_BATTERY_TOTAL = (82000.0 + 16000.0) / 16000.0 * 1.000; // which should be 6.125, not 6.15 as provided originally. Final multiplier added to make eChook battery total match Fluke meter reading
const float CAL_BATTERY_LOWER = (82000.0 + 16000.0) / 16000.0 * 1.000; // which should be 6.125, not 6.15 as provided originally. Final multiplier added to make eChook battery lower match Fluke meter reading
const float CAL_CURRENT = 37.55; // Current Multiplier - See documentation for calibration method
// Board and Sensor Specific Calibrations
const float CAL_THERM_A = 0.001871300068; // Steinhart-Hart constants - See documentation for calibration method
const float CAL_THERM_B = 0.00009436080271;
const float CAL_THERM_C = 0.0000007954800125;
// Throttle adjustment
const float CAL_THROTTLE = 100.0 / 96.5; // Throttle scalar to account for throttle pot being supplied +5 from power controller and not from eChook
#endif
Ben ... I'll post a separate reply re your current sensor testing as we're probably breaking all forum etiquette by discussing multiple topics in a single reply let alone within a single thread!
-- Keith.