Skip to content

Commit

Permalink
minor update for calibration function
Browse files Browse the repository at this point in the history
calibrates in 1s now, and more reliably

also some minor changes to the schematic, fixing glitches
  • Loading branch information
jaustindavid committed Oct 17, 2014
1 parent c069a47 commit 66929c9
Show file tree
Hide file tree
Showing 6 changed files with 147 additions and 191 deletions.
20 changes: 12 additions & 8 deletions Wiiceiver/ElectronicSpeedController.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 12 additions & 7 deletions Wiiceiver/Wiiceiver.ino
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@
#include <Servo.h>
#include <EEPROM.h>

#define WIICEIVER_VERSION "1.2"
#define WIICEIVER_VERSION "1.2.2"

// addys for vars stored in EEPROM
#define EEPROM_Y_ADDY 0
#define EEPROM_AUTOCRUISE_ADDY 1
#define EEPROM_WDC_ADDY 2


// #define DEBUGGING
#define DEBUGGING

#include "Blinker.h"

Expand Down Expand Up @@ -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();
Expand All @@ -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
Expand Down Expand Up @@ -280,7 +285,7 @@ bool waitForActivity(void) {
#endif

return chuck.isActive();
}
} // bool waitForActivity()


// dead code?
Expand Down
6 changes: 3 additions & 3 deletions Wiiceiver/pinouts.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
93 changes: 46 additions & 47 deletions eagle/wiiceiver v1.brd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<setting alwaysvectorfont="yes"/>
<setting verticaltext="up"/>
</settings>
<grid distance="0.05" unitdist="inch" unit="inch" style="lines" multiple="1" display="yes" altdistance="0.025" altunitdist="inch" altunit="inch"/>
<grid distance="0.025" unitdist="inch" unit="inch" style="lines" multiple="1" display="yes" altdistance="0.025" altunitdist="inch" altunit="inch"/>
<layers>
<layer number="1" name="Top" color="4" fill="1" visible="yes" active="yes"/>
<layer number="16" name="Bottom" color="1" fill="1" visible="yes" active="yes"/>
Expand Down Expand Up @@ -61,10 +61,10 @@
<wire x1="56.82" y1="72.38" x2="21.59" y2="72.38" width="0" layer="20"/>
<wire x1="21.59" y1="72.38" x2="21.59" y2="21.59" width="0" layer="20"/>
<text x="26.67" y="22.86" size="1.27" layer="25">austindavid.com/wiiceiver</text>
<text x="24.13" y="29.21" size="1.778" layer="25" rot="MR0">+</text>
<text x="24.13" y="38.1" size="1.778" layer="25" rot="MR0">+</text>
<text x="-5.08" y="22.86" size="1.778" layer="16" rot="MR0">V1 14/06/02</text>
<text x="26.67" y="25.4" size="0.6096" layer="25">V1 14/06/02</text>
<text x="30.48" y="29.21" size="1.778" layer="25" rot="MR0">+</text>
<text x="29.21" y="38.1" size="1.778" layer="25" rot="MR0">+</text>
<text x="26.67" y="25.4" size="0.6096" layer="25">V1.1 14/08/25</text>
<text x="22.86" y="70.485" size="1.27" layer="25">http://diyelectricskateboard.com</text>
</plain>
<libraries>
<library name="ic-package">
Expand Down Expand Up @@ -183,30 +183,6 @@ Extended by Federico Battaglin &lt;author&gt;&amp;lt;federico.rd@fdpinternationa
<rectangle x1="-2.794" y1="-0.254" x2="-2.286" y2="0.254" layer="51"/>
<rectangle x1="2.286" y1="-0.254" x2="2.794" y2="0.254" layer="51"/>
</package>
<package name="1X02">
<description>&lt;b&gt;PIN HEADER&lt;/b&gt;</description>
<wire x1="-1.905" y1="1.27" x2="-0.635" y2="1.27" width="0.1524" layer="21"/>
<wire x1="-0.635" y1="1.27" x2="0" y2="0.635" width="0.1524" layer="21"/>
<wire x1="0" y1="0.635" x2="0" y2="-0.635" width="0.1524" layer="21"/>
<wire x1="0" y1="-0.635" x2="-0.635" y2="-1.27" width="0.1524" layer="21"/>
<wire x1="-2.54" y1="0.635" x2="-2.54" y2="-0.635" width="0.1524" layer="21"/>
<wire x1="-1.905" y1="1.27" x2="-2.54" y2="0.635" width="0.1524" layer="21"/>
<wire x1="-2.54" y1="-0.635" x2="-1.905" y2="-1.27" width="0.1524" layer="21"/>
<wire x1="-0.635" y1="-1.27" x2="-1.905" y2="-1.27" width="0.1524" layer="21"/>
<wire x1="0" y1="0.635" x2="0.635" y2="1.27" width="0.1524" layer="21"/>
<wire x1="0.635" y1="1.27" x2="1.905" y2="1.27" width="0.1524" layer="21"/>
<wire x1="1.905" y1="1.27" x2="2.54" y2="0.635" width="0.1524" layer="21"/>
<wire x1="2.54" y1="0.635" x2="2.54" y2="-0.635" width="0.1524" layer="21"/>
<wire x1="2.54" y1="-0.635" x2="1.905" y2="-1.27" width="0.1524" layer="21"/>
<wire x1="1.905" y1="-1.27" x2="0.635" y2="-1.27" width="0.1524" layer="21"/>
<wire x1="0.635" y1="-1.27" x2="0" y2="-0.635" width="0.1524" layer="21"/>
<pad name="1" x="-1.27" y="0" drill="1.016" shape="long" rot="R90"/>
<pad name="2" x="1.27" y="0" drill="1.016" shape="long" rot="R90"/>
<text x="-2.6162" y="1.8288" size="1.27" layer="25" ratio="10">&gt;NAME</text>
<text x="-2.54" y="-3.175" size="1.27" layer="27">&gt;VALUE</text>
<rectangle x1="-1.524" y1="-0.254" x2="-1.016" y2="0.254" layer="51"/>
<rectangle x1="1.016" y1="-0.254" x2="1.524" y2="0.254" layer="51"/>
</package>
<package name="1X04">
<description>&lt;b&gt;PIN HEADER&lt;/b&gt;</description>
<wire x1="0" y1="0.635" x2="0.635" y2="1.27" width="0.1524" layer="21"/>
Expand Down Expand Up @@ -1722,7 +1698,7 @@ design rules under a new name.</description>
<attribute name="VALUE" x="30.861" y="28.575" size="1.27" layer="27" ratio="10" rot="R90"/>
</element>
<element name="JP1" library="pinhead" package="1X03" value="Servo" x="46.99" y="30.48" rot="R270"/>
<element name="JP2" library="pinhead" package="1X02" value="BEC" x="52.07" y="29.21" rot="R270"/>
<element name="JP2" library="pinhead" package="1X03" value="BEC" x="52.07" y="30.48" rot="R270"/>
<element name="CLK" library="crystal" package="HC49U" value="16MHz" x="30.48" y="44.45" smashed="yes" rot="R270">
<attribute name="OC_NEWARK" value="unknown" x="-11.43" y="25.4" size="1.778" layer="27" rot="R270" display="off"/>
<attribute name="MPN" value="" x="-11.43" y="25.4" size="1.778" layer="27" rot="R270" display="off"/>
Expand All @@ -1732,7 +1708,7 @@ design rules under a new name.</description>
<attribute name="VALUE" x="23.749" y="49.53" size="1.27" layer="27" ratio="10" rot="R270"/>
</element>
<element name="JP4" library="pinhead" package="1X04" value="Nunchuck Hole" x="49.53" y="62.23" smashed="yes" rot="R270">
<attribute name="NAME" x="51.3588" y="62.3062" size="1.27" layer="25" ratio="10" rot="R270"/>
<attribute name="NAME" x="48.1838" y="67.3862" size="1.27" layer="25" ratio="10"/>
<attribute name="VALUE" x="46.355" y="67.31" size="1.27" layer="27" rot="R270"/>
</element>
<element name="C1" library="resistor" package="B45181A" value="22uF" x="49.53" y="49.53" smashed="yes" rot="R180">
Expand Down Expand Up @@ -1772,6 +1748,9 @@ design rules under a new name.</description>
<attribute name="NAME" x="25.781" y="63.5" size="1.27" layer="25" ratio="10" rot="R270"/>
<attribute name="VALUE" x="26.289" y="64.77" size="1.27" layer="27" ratio="10" rot="R270"/>
</element>
<element name="JP3" library="pinhead" package="1X04" value="" x="54.61" y="62.23" smashed="yes" rot="R270">
<attribute name="VALUE" x="51.435" y="67.31" size="1.27" layer="27" rot="R270"/>
</element>
</elements>
<signals>
<signal name="N$1">
Expand Down Expand Up @@ -1811,13 +1790,21 @@ design rules under a new name.</description>
<wire x1="52.07" y1="49.53" x2="50.8" y2="49.53" width="0.4064" layer="1"/>
<contactref element="IC2" pad="2"/>
<wire x1="48.26" y1="40.64" x2="52.07" y2="40.64" width="0.4064" layer="1"/>
<contactref element="JP3" pad="3"/>
<contactref element="JP3" pad="2"/>
<wire x1="54.61" y1="63.5" x2="49.53" y2="63.5" width="0.4064" layer="1"/>
<wire x1="49.53" y1="60.96" x2="54.61" y2="60.96" width="0.4064" layer="1"/>
<wire x1="54.61" y1="60.96" x2="54.61" y2="63.5" width="0" layer="19" extent="1-1"/>
</signal>
<signal name="N$21">
<contactref element="JP4" pad="1"/>
<contactref element="IC1" pad="28"/>
<contactref element="R6" pad="1"/>
<wire x1="43.18" y1="66.04" x2="45.72" y2="66.04" width="0.4064" layer="1"/>
<wire x1="45.72" y1="66.04" x2="49.53" y2="66.04" width="0.4064" layer="1"/>
<contactref element="JP3" pad="1"/>
<wire x1="43.18" y1="66.04" x2="49.53" y2="66.04" width="0.4064" layer="1"/>
<wire x1="49.53" y1="66.04" x2="54.61" y2="66.04" width="0.4064" layer="1"/>
</signal>
<signal name="N$22">
<contactref element="IC1" pad="27"/>
Expand Down Expand Up @@ -1845,8 +1832,6 @@ design rules under a new name.</description>
<contactref element="C3" pad="2"/>
<contactref element="R5" pad="2"/>
<contactref element="JP4" pad="4"/>
<contactref element="JP2" pad="2"/>
<contactref element="JP1" pad="3"/>
<contactref element="C2" pad="-"/>
<contactref element="IC1" pad="22"/>
<contactref element="IC1" pad="13"/>
Expand All @@ -1861,7 +1846,6 @@ design rules under a new name.</description>
<wire x1="33.02" y1="35.56" x2="35.56" y2="35.56" width="0.4064" layer="1"/>
<wire x1="43.18" y1="50.8" x2="48.26" y2="50.8" width="0.4064" layer="16"/>
<wire x1="48.26" y1="50.8" x2="49.53" y2="50.8" width="0.4064" layer="16"/>
<wire x1="52.07" y1="27.94" x2="46.99" y2="27.94" width="0.4064" layer="16"/>
<wire x1="26.67" y1="52.07" x2="29.21" y2="52.07" width="0.4064" layer="16"/>
<wire x1="29.21" y1="44.45" x2="29.21" y2="48.26" width="0.4064" layer="16"/>
<wire x1="29.21" y1="48.26" x2="29.21" y2="52.07" width="0.4064" layer="16"/>
Expand All @@ -1872,7 +1856,6 @@ design rules under a new name.</description>
<wire x1="48.26" y1="43.18" x2="39.37" y2="43.18" width="0.4064" layer="16"/>
<wire x1="49.53" y1="58.42" x2="49.53" y2="50.8" width="0.4064" layer="16"/>
<wire x1="48.26" y1="49.53" x2="48.26" y2="50.8" width="0.4064" layer="16"/>
<wire x1="46.99" y1="27.94" x2="40.64" y2="27.94" width="0.4064" layer="16"/>
<wire x1="40.64" y1="27.94" x2="39.37" y2="26.67" width="0.4064" layer="16"/>
<wire x1="39.37" y1="35.56" x2="39.37" y2="33.02" width="0.4064" layer="16"/>
<wire x1="39.37" y1="33.02" x2="36.83" y2="30.48" width="0.4064" layer="16"/>
Expand All @@ -1882,35 +1865,42 @@ design rules under a new name.</description>
<contactref element="SV1" pad="5"/>
<wire x1="29.21" y1="58.42" x2="29.21" y2="55.88" width="0.4064" layer="16"/>
<wire x1="29.21" y1="55.88" x2="29.21" y2="52.07" width="0.4064" layer="16"/>
<contactref element="C2" pad="+"/>
<contactref element="R7" pad="2"/>
<contactref element="R6" pad="2"/>
<contactref element="R8" pad="1"/>
<contactref element="SV1" pad="1"/>
<contactref element="JP1" pad="3"/>
<wire x1="33.02" y1="68.58" x2="29.21" y2="68.58" width="0.4064" layer="1"/>
<contactref element="JP2" pad="3"/>
<wire x1="52.07" y1="27.94" x2="46.99" y2="27.94" width="0.4064" layer="16"/>
<wire x1="46.99" y1="27.94" x2="40.64" y2="27.94" width="0.4064" layer="16"/>
<wire x1="33.02" y1="68.58" x2="45.72" y2="68.58" width="0.4064" layer="1"/>
<wire x1="45.72" y1="60.96" x2="45.72" y2="48.26" width="0.4064" layer="1"/>
<contactref element="JP3" pad="4"/>
<wire x1="54.61" y1="58.42" x2="49.53" y2="58.42" width="0.4064" layer="16"/>
<wire x1="45.72" y1="60.96" x2="45.72" y2="68.58" width="0" layer="19" extent="1-1"/>
<wire x1="48.26" y1="49.53" x2="45.72" y2="48.26" width="0" layer="19" extent="1-1"/>
<wire x1="39.37" y1="29.21" x2="40.64" y2="27.94" width="0" layer="19" extent="16-16"/>
</signal>
<signal name="VIN">
<contactref element="JP2" pad="1"/>
<contactref element="JP1" pad="2"/>
<contactref element="IC1" pad="21"/>
<contactref element="IC1" pad="20"/>
<contactref element="IC1" pad="7"/>
<contactref element="C3" pad="1"/>
<contactref element="C2" pad="+"/>
<contactref element="R7" pad="2"/>
<contactref element="R6" pad="2"/>
<contactref element="R8" pad="1"/>
<wire x1="33.02" y1="68.58" x2="39.37" y2="68.58" width="0.4064" layer="1"/>
<wire x1="39.37" y1="68.58" x2="39.37" y2="50.8" width="0.4064" layer="1"/>
<wire x1="39.37" y1="50.8" x2="35.56" y2="50.8" width="0.4064" layer="1"/>
<wire x1="43.18" y1="45.72" x2="43.18" y2="48.26" width="0.4064" layer="1"/>
<wire x1="45.72" y1="68.58" x2="39.37" y2="68.58" width="0.4064" layer="1"/>
<wire x1="46.99" y1="30.48" x2="52.07" y2="30.48" width="0.4064" layer="1"/>
<wire x1="35.56" y1="50.8" x2="31.75" y2="50.8" width="0.4064" layer="1"/>
<wire x1="31.75" y1="50.8" x2="31.75" y2="52.07" width="0.4064" layer="1"/>
<wire x1="43.18" y1="48.26" x2="45.72" y2="48.26" width="0.4064" layer="1"/>
<wire x1="45.72" y1="48.26" x2="45.72" y2="60.96" width="0.4064" layer="1"/>
<wire x1="39.37" y1="30.48" x2="46.99" y2="30.48" width="0.4064" layer="1"/>
<wire x1="39.37" y1="48.26" x2="43.18" y2="48.26" width="0.4064" layer="1"/>
<wire x1="39.37" y1="30.48" x2="39.37" y2="48.26" width="0.4064" layer="1"/>
<wire x1="39.37" y1="48.26" x2="39.37" y2="50.8" width="0.4064" layer="1"/>
<wire x1="39.37" y1="29.21" x2="39.37" y2="30.48" width="0.4064" layer="1"/>
<contactref element="SV1" pad="1"/>
<wire x1="33.02" y1="68.58" x2="29.21" y2="68.58" width="0.4064" layer="1"/>
<contactref element="JP2" pad="2"/>
<wire x1="52.07" y1="30.48" x2="46.99" y2="30.48" width="0.4064" layer="1"/>
</signal>
<signal name="DIP12">
<contactref element="LED1" pad="A"/>
Expand All @@ -1929,6 +1919,15 @@ design rules under a new name.</description>
<contactref element="SV1" pad="2"/>
<wire x1="29.21" y1="66.04" x2="33.02" y2="66.04" width="0.4064" layer="1"/>
</signal>
<signal name="N$3">
<contactref element="IC1" pad="26"/>
</signal>
<signal name="N$4">
<contactref element="JP2" pad="1"/>
<contactref element="IC1" pad="16"/>
<wire x1="52.07" y1="33.02" x2="49.53" y2="35.56" width="0.4064" layer="1"/>
<wire x1="49.53" y1="35.56" x2="43.18" y2="35.56" width="0.4064" layer="1"/>
</signal>
</signals>
<errors>
<approved hash="19,16,ce02d85cd849ce17"/>
Expand Down
Loading

0 comments on commit 66929c9

Please sign in to comment.