From 66929c91481c0a721235fdb53c2f0a6e2fb975b5 Mon Sep 17 00:00:00 2001 From: Austin David Date: Fri, 17 Oct 2014 00:14:31 -0700 Subject: [PATCH] minor update for calibration function calibrates in 1s now, and more reliably also some minor changes to the schematic, fixing glitches --- Wiiceiver/ElectronicSpeedController.h | 20 +-- Wiiceiver/Wiiceiver.ino | 19 ++- Wiiceiver/pinouts.h | 6 +- eagle/wiiceiver v1.brd | 93 ++++++------- eagle/wiiceiver v1.sch | 192 +++++++++----------------- factory_reset/factory_reset.ino | 8 +- 6 files changed, 147 insertions(+), 191 deletions(-) diff --git a/Wiiceiver/ElectronicSpeedController.h b/Wiiceiver/ElectronicSpeedController.h index 6c4d1ac..f1d3c00 100644 --- a/Wiiceiver/ElectronicSpeedController.h +++ b/Wiiceiver/ElectronicSpeedController.h @@ -156,14 +156,18 @@ void setLevel(float level) { // startup sequence: some small range of inputs, then idle void syncESC(void) { -/* - sweep(0, SYNC_LIMIT, SYNC_LIMIT/2); - delay(500); - sweep(SYNC_LIMIT, -SYNC_LIMIT, -SYNC_LIMIT/2); - delay(500); -*/ - sweep(-SYNC_LIMIT, 0, SYNC_LIMIT/2); - delay(1000); + setLevel(0); + delay(100); + setLevel(1); + delay(50); + setLevel(-1); + delay(50); + setLevel(0); + delay(100); + setLevel(1); + delay(100); + setLevel(0); + delay(100); } // void syncESC(void) }; // class ElectronicSpeedController diff --git a/Wiiceiver/Wiiceiver.ino b/Wiiceiver/Wiiceiver.ino index 2525167..13a88ed 100644 --- a/Wiiceiver/Wiiceiver.ino +++ b/Wiiceiver/Wiiceiver.ino @@ -32,7 +32,7 @@ #include #include -#define WIICEIVER_VERSION "1.2" +#define WIICEIVER_VERSION "1.2.2" // addys for vars stored in EEPROM #define EEPROM_Y_ADDY 0 @@ -40,7 +40,7 @@ #define EEPROM_WDC_ADDY 2 -// #define DEBUGGING +#define DEBUGGING #include "Blinker.h" @@ -128,14 +128,19 @@ void maybeCalibrate(void) { int ctr = 0; int i = 0; - chuck.update(); + for (i = 0; i < 10; i++) { + chuck.update(); + delay(10); + } if (chuck.C != 1 || ! chuck.isActive()) { return; } red.update(10); green.update(10); - while (i < 250 && chuck.C) { + i = 0; + #define C_COUNT 50 + while (i <= C_COUNT && chuck.C) { chuck.update(); red.run(); green.run(); @@ -145,11 +150,11 @@ void maybeCalibrate(void) { } #ifdef DEBUGGING - Serial.print("C = "); + Serial.print("C ctr = "); Serial.println(ctr); #endif - if (chuck.C == 1 && chuck.isActive()) { + if (ctr >= C_COUNT && chuck.isActive()) { chuck.calibrateCenter(); chuck.writeEEPROM(); // side effect: reset the WDC @@ -280,7 +285,7 @@ bool waitForActivity(void) { #endif return chuck.isActive(); -} +} // bool waitForActivity() // dead code? diff --git a/Wiiceiver/pinouts.h b/Wiiceiver/pinouts.h index 6c0c875..7f3c1cb 100644 --- a/Wiiceiver/pinouts.h +++ b/Wiiceiver/pinouts.h @@ -98,9 +98,9 @@ int pinLocation(int pinID) { {7, 6, 6}, // GREEN_LED any digital pin {10, 9, 9}, // ESC_PPM PWM required {9, 11, 5}, // WII_POWER any digital pin - {19, 19, 19}, // WII_SCL A5, don't change - {18, 18, 18}, // WII_SDA A4, don't change - {0, 10, 10}, // ESC2_PPM PWM required + {19, 19, 19}, // WII_SCL A5, don't change + {18, 18, 18}, // WII_SDA A4, don't change + {0, 10, 10}, // ESC2_PPM PWM required }; if (CSEL < 0) { diff --git a/eagle/wiiceiver v1.brd b/eagle/wiiceiver v1.brd index aec8c61..f49ccb9 100644 --- a/eagle/wiiceiver v1.brd +++ b/eagle/wiiceiver v1.brd @@ -6,7 +6,7 @@ - + @@ -61,10 +61,10 @@ austindavid.com/wiiceiver -+ -+ -V1 14/06/02 -V1 14/06/02 ++ ++ +V1.1 14/08/25 +http://diyelectricskateboard.com @@ -183,30 +183,6 @@ Extended by Federico Battaglin <author>&lt;federico.rd@fdpinternationa - -<b>PIN HEADER</b> - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - - <b>PIN HEADER</b> @@ -1722,7 +1698,7 @@ design rules under a new name. - + @@ -1732,7 +1708,7 @@ design rules under a new name. - + @@ -1772,6 +1748,9 @@ design rules under a new name. + + + @@ -1811,6 +1790,11 @@ design rules under a new name. + + + + + @@ -1818,6 +1802,9 @@ design rules under a new name. + + + @@ -1845,8 +1832,6 @@ design rules under a new name. - - @@ -1861,7 +1846,6 @@ design rules under a new name. - @@ -1872,7 +1856,6 @@ design rules under a new name. - @@ -1882,35 +1865,42 @@ design rules under a new name. + + + + + + + + + + + + + + + + + - - - - - - - - - - - - + + @@ -1929,6 +1919,15 @@ design rules under a new name. + + + + + + + + + diff --git a/eagle/wiiceiver v1.sch b/eagle/wiiceiver v1.sch index 91b83a7..4bc8d53 100644 --- a/eagle/wiiceiver v1.sch +++ b/eagle/wiiceiver v1.sch @@ -1903,50 +1903,6 @@ Source: www.kingbright.com - -<b>PIN HEADER</b> - - - - - - - - - - - - - - - - - ->NAME ->VALUE - - - - -<b>PIN HEADER</b> - - - - - - - - - - - ->NAME ->VALUE - - - - - <b>PIN HEADER</b> @@ -2036,16 +1992,6 @@ Source: www.kingbright.com - - - - - ->NAME ->VALUE - - - @@ -2088,32 +2034,6 @@ Source: www.kingbright.com - -<b>PIN HEADER</b> - - - - - - - - - - - - - - - - - - - - - - - - <b>PIN HEADER</b> @@ -12167,7 +12087,7 @@ W = angled<p> - + @@ -12180,6 +12100,7 @@ W = angled<p> + @@ -12190,7 +12111,7 @@ W = angled<p> - + @@ -12204,6 +12125,7 @@ W = angled<p> + @@ -12262,17 +12184,27 @@ W = angled<p> + + + + + - + + + + + + @@ -12316,17 +12248,8 @@ W = angled<p> - - - - - - - - - - @@ -12365,36 +12288,8 @@ W = angled<p> - - - - - - - - - - - - - - - - - - - - - - - + @@ -12416,6 +12311,42 @@ W = angled<p> + + + + + + + + + + + + + + + + + + + + + + @@ -12446,6 +12377,21 @@ W = angled<p> + + + + + + + + + + + + + + + diff --git a/factory_reset/factory_reset.ino b/factory_reset/factory_reset.ino index 4f51850..0dee8ab 100644 --- a/factory_reset/factory_reset.ino +++ b/factory_reset/factory_reset.ino @@ -6,15 +6,17 @@ * do in a working wiiceiver, but it might help troubleshooting in * specific cases. * + * This also wipes out any saved history (all 1024 byets of flash) + * * To reset a wiiceiver the easy way: * 1) start it and hold C; count to 10 - * 2) hold down until the wheels stop, then all the way right for 5 secs + * 2) hold C+Z+down until the wheels stop, then C+Z+right for 5 secs * * This will re-calibrate the nunchuck stick, and set auto-cruise to 0 * * If for whatever reason you want to do the hard way: * 1) upload this to your wiiceiver - * 2) observe both red & green LEDs lot solid + * 2) observe both red & green LEDs lit solid * 3) upload the wiiceiver code * 4) observe wiiceiver acting like a "new" device, with * default settings for the joystick calibration and auto-cruise @@ -41,7 +43,7 @@ boolean fixValue(int address, byte desiredValue) { void setup() { Serial.begin(115200); - for (int addy = 0; addy <= 2; addy ++) { + for (int addy = 0; addy < 3; addy ++) { if (fixValue(addy, 255)) { Serial.print("fixed address #"); Serial.println(addy);