Code for 'Smart Regulator' featured in 'Model Engineer', November 2020 on. Contains all work to August 2020 including all code described. Top level algorithm development is quite spares, leaving some work for you! Any questions - jon@jons-workshop.com
Dependencies: mbed BufferedSerial Servo2 PCT2075 I2CEeprom FastPWM
Alternator.h
- Committer:
- JonFreeman
- Date:
- 2020-08-07
- Revision:
- 4:28cc0cf01570
- Parent:
- 3:43cb067ecd00
- Child:
- 5:6ca3e7ffc553
File content as of revision 4:28cc0cf01570:
#define GPS_ // Not the crap one I tried! const double ALTERNATOR_DESIGN_VOLTAGE = 14.0; // Used to scale down max field pwm when available voltage higher than this const double DRIVER_NEUTRAL = 0.18; // Proportion of driver's pot travel deemed to be zero power request const uint32_t eeprom_page = 17; // Determines where in eeprom 'settings' reside const int eeprom_page_size = 32; const int PWM_PERIOD_US = 1800 ; // Was 2400, May want to reduce this, note would require change of resistor value on board enum {TABL0, TABL1, TABL2, TABL3, TABL4, TABL5, TABL6, TABL7, TABL8, TABL9, TABL10, TABL11, TABL12, TABL13, TABL14, TABL15, TABL16, TABL17, TABL18, TABL19, TABL20, WARM_UP_DELAY, WARMUP_SERVO_POS, OP_MODE, SPEED_CTRL_P, SERVO_DIR, FUT27, FUT28, FUT29, FUT30, FUT31 } ; struct sldandt { const uint32_t min, max, de_fault; // min, max, default const char * txt; // description char val; } ; class ee_settings_2020 { char new_settings[eeprom_page_size + 2]; public: ee_settings_2020 () ; // Constructor int load () ; int save () ; char rd (uint32_t i) ; bool wr (char c, uint32_t i) ; // Write one setup char value to private buffer 'settings' sldandt * inform (uint32_t which) ; } ; const int MAX_PARAMS = 12; // Up from 10 May 2020 struct parameters { // Used in Command Line Interpreter, stores user input values int32_t position_in_list, numof_dbls; double dbl[MAX_PARAMS]; } ; /* - Position the Cursor: \033[<L>;<C>H Or \033[<L>;<C>f puts the cursor at line L and column C. - Move the cursor up N lines: \033[<N>A - Move the cursor down N lines: \033[<N>B - Move the cursor forward N columns: \033[<N>C - Move the cursor backward N columns: \033[<N>D - Clear the screen, move to (0,0): \033[2J - Erase to end of line: \033[K - Save cursor position: \033[s might not work - Restore cursor position: \033[u might not work */