Skip to content

Commit

Permalink
Add a clear calibration settings option and update calibration messages
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyLindsay committed Oct 11, 2017
1 parent 2c10836 commit 721d9ca
Show file tree
Hide file tree
Showing 15 changed files with 268 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
ActivityBot Display Calibration Results.c
Clear calibration data. ActivityBot360 will use default values
and may not perform as well.
*/

#include "simpletools.h"
#include "servo360.h"
#include "abcalibrate360.h"

int main()
{
cal_clear();
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ActivitiyBot Clear Calibration Settings.c
>compiler=C
>memtype=cmm main ram compact
>optimize=-Os
>-m32bit-doubles
>-fno-exceptions
>defs::-std=c99
>-lm
>BOARD::ACTIVITYBOARD
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,18 @@ int main()
servo360_connect(12, 14);
servo360_feedback(12, 0);

int n, y1, y2, x1, x2;
int mVccw, mVcw, bVccw, bVcw;
int increases = 0, decreases = 0;
int angle = servo360_getAngle(12);
int anglep = angle;
int diffCount = 0;
int n, x, angle, angleP;
int mVccwL, mVcwL, bVccwL, bVcwL;
int mVccwR, mVcwR, bVccwR, bVcwR;
int increases = 0, decreases = 0, diffCount = 0;

servo360_set(12, 1500+240);
pause(2000);
x1 = servo360_getAngle12Bit(12);
print("x1 = %d\r", x1);
x = servo360_getAngle12Bit(12);
print("x = %d\r", x);
pause(1000);
x1 = servo360_getAngle12Bit(12) - x1;
print("x1 = %d\r", x1);
x = servo360_getAngle12Bit(12) - x;
print("x = %d\r", x);
//x1 &= 0xFFF;
//print("x1 = %d\r", x1);

Expand All @@ -35,38 +33,39 @@ int main()
pause(2000);

angle = servo360_getAngle(12);
anglep = angle;
angleP = angle;

for(n = 0; n < 60; n++)
{
servo360_set(12, 1500 + n);
angle = servo360_getAngle(12);
print("angle = %d\r", angle);
if(angle != anglep) increases++;
if(angle != angleP) increases++;
if(increases > 3) break;
pause(20);
angleP = angle;
}

bVccw = (n - 4) * 10 * 2 / 3;
print("bVccw = %d\r", bVccw);
bVccwL = (n - 4) * 10 * 2 / 3;
print("bVccwL = %d\r", bVccwL);

servo360_set(12, 1500);

mVccw = 1000 * (2200 - 266) / x1;
mVccwL = 1000 * (2200 - bVccwL) / x;

print("mVccw = %d\r", mVccw);
print("mVccwL = %d\r", mVccwL);


// Left servo clockwise


servo360_set(12, 1500-240);
pause(2000);
x1 = servo360_getAngle12Bit(12);
print("x1 = %d\r", x1);
x = servo360_getAngle12Bit(12);
print("x = %d\r", x);
pause(1000);
x1 = abs(servo360_getAngle12Bit(12) - x1);
print("x1 = %d\r", x1);
x = abs(servo360_getAngle12Bit(12) - x);
print("x = %d\r", x);
//x1 &= 0xFFF;
//print("x1 = %d\r", x1);

Expand All @@ -75,28 +74,122 @@ int main()
pause(2000);

angle = servo360_getAngle(12);
anglep = angle;
angleP = angle;

for(n = 0; n > -60; n--)
{
servo360_set(12, 1500 + n);
angle = servo360_getAngle(12);
print("angle = %d\r", angle);
if(angle != anglep) decreases++;
if(angle != angleP) decreases++;
if(decreases > 3) break;
pause(20);
angleP = angle;
}

bVcw = abs((n + 4) * 10 * 2 / 3);
print("bVcw = %d\r", bVcw);
bVcwL = abs((n + 4) * 10 * 2 / 3);
print("bVcwL = %d\r", bVcwL);

servo360_set(12, 1500);

mVcw = 1000 * (2200 - 266) / x1;
mVcwL = 1000 * (2200 - bVcwL) / x;

print("mVccw = %d\r", mVcw);
print("mVccwL = %d\r", mVcwL);

while(1);

// Right servo counterclockwise

servo360_connect(13, 15);
servo360_feedback(13, 0);

servo360_set(13, 1500+240);
pause(2000);
x = servo360_getAngle12Bit(13);
print("x = %d\r", x);
pause(1000);
x = servo360_getAngle12Bit(13) - x;
print("x = %d\r", x);
//x1 &= 0xFFF;
//print("x1 = %d\r", x1);

servo360_set(13, 1500);

pause(2000);

angle = servo360_getAngle(13);
angleP = angle;
increases = 0;

for(n = 0; n < 60; n++)
{
servo360_set(13, 1500 + n);
angle = servo360_getAngle(13);
print("angle = %d\r", angle);
if(angle != angleP) increases++;
if(increases > 3) break;
pause(20);
angleP = angle;
}

bVccwR = (n - 4) * 10 * 2 / 3;
print("bVccwR = %d\r", bVccwR);

servo360_set(13, 1500);

mVccwR = 1000 * (2200 - bVccwR) / x;

print("mVccwR = %d\r", mVccwR);


// Right servo clockwise


servo360_set(13, 1500-240);
pause(2000);
x = servo360_getAngle12Bit(13);
print("x = %d\r", x);
pause(1000);
x = abs(servo360_getAngle12Bit(13) - x);
print("x1 = %d\r", x);
//x1 &= 0xFFF;
//print("x1 = %d\r", x1);

servo360_set(13, 1500);

pause(2000);

angle = servo360_getAngle(13);
angleP = angle;
decreases = 0;

for(n = 0; n > -60; n--)
{
servo360_set(13, 1500 + n);
angle = servo360_getAngle(13);
print("angle = %d\r", angle);
if(angle != angleP) decreases++;
if(decreases > 3) break;
pause(20);
angleP = angle;
}

bVcwR = abs((n + 4) * 10 * 2 / 3);
print("bVcwR = %d\r", bVcwR);

servo360_set(13, 1500);

mVcwR = 1000 * (2200 - bVcwR) / x;

print("mVcwR = %d\r", mVcwR);

print("\r=== Summary ===\r", mVcwR);
print("mVccw = %d\r", mVccwL);
print("bVccwL = %d\r", bVccwL);
print("mVcwL = %d\r", mVcwL);
print("bVcwL = %d\r", bVcwL);
print("mVccwR = %d\r", mVccwR);
print("bVccwR = %d\r", bVccwR);
print("mVcwR = %d\r", mVcwR);
print("bVcwR = %d\r", bVcwR);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
ActivityBot Display Calibration Results.c
Clear calibration data. ActivityBot360 will use default values
and may not perform as well.
*/

#include "simpletools.h"
#include "servo360.h"
#include "abcalibrate360.h"

int main()
{
cal_clear();
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ActivitiyBot Clear Calibration Settings.c
>compiler=C
>memtype=cmm main ram compact
>optimize=-Os
>-m32bit-doubles
>-fno-exceptions
>defs::-std=c99
>-lm
>BOARD::ACTIVITYBOARD
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
ActivityBot Display Calibration Results.c
Display interpolation table values from calibration
http://learn.parallax.com/activitybot/calibrate-your-activitybot
*/

#include "simpletools.h"
#include "servo360.h"
#include "abcalibrate360.h"

int main()
{
cal_displayResults();
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ActivitiyBot Display Calibration Results.c
>compiler=C
>memtype=cmm main ram compact
>optimize=-Os
>-m32bit-doubles
>-fno-exceptions
>defs::-std=c99
>-lm
>BOARD::ACTIVITYBOARD
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
ActivityBot Display Calibration.c
Display interpolation table values from calibration
http://learn.parallax.com/activitybot/calibrate-your-activitybot
*/

#include "simpletools.h"
#include "servo360.h"
#include "abcalibrate360.h"

int main()
{
cal_displayData();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ActivitiyBot Display Calibration.c
>compiler=C
>memtype=cmm main ram compact
>optimize=-Os
>-m32bit-doubles
>-fno-exceptions
>defs::-std=c99
>-lm
>BOARD::ACTIVITYBOARD
23 changes: 23 additions & 0 deletions Learn/Examples/Robots/ActivityBot360/ActivityBot Calibrate.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
ActivityBot Calibrate.c
Calibrate the ActivityBot's servos and encoders
http://learn.parallax.com/activitybot/calibrate-your-activitybot
*/

#include "simpletools.h"
#include "servo360.h"
#include "abcalibrate360.h"

int main()
{
cal_servoPins(12, 13);
cal_encoderPins(14, 15);

high(26);
high(27);
cal_activityBot();
low(26);
low(27);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ActivityBot Calibrate.c
>compiler=C
>memtype=cmm main ram compact
>optimize=-Os
>-m32bit-doubles
>-fno-exceptions
>defs::-std=c99
>-lm
>BOARD::ACTIVITYBOARD
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,8 @@ void cal_displayData(void)
}
else
{
print("There was a problem with the calibration.\r");
print("Try cal_displayResults() instead.\r");
print("Calibration data either not found or has errors.\r");
print("Try cal_displayResults() for more info.\r");
print("\rRaw data from EEPROM:\r\r");
for(int a = _AB360_EE_Start_; a < _AB360_EE_End_; a++)
{
Expand Down Expand Up @@ -410,14 +410,14 @@ void cal_displayResults(void)
{
print("Calibration started but did not complete.\r");
print("Verify the servo and encoder connections\r");
print("against the ones in the diagram and try\r");
print("against the ones in the diagrams and try\r");
print("again. Follow the instructions carefully.\r");
//return -1;
}
else if(!strcmp(str, "ActivityBot"))
{
print("There is a non-servo360 ActivityBot calibration.\r");
print("in the EEPROM. Maek sure to follow the instructions\r");
print("in the EEPROM. Make sure to follow the instructions\r");
print("for calibrating the ActivityBot360.\r");
//return -1;
}
Expand Down Expand Up @@ -479,6 +479,14 @@ void cal_displayResults(void)
*/
}


void cal_clear(void)
{
for(int addr = _AB360_EE_Start_; addr <_AB360_EE_End_; addr++)
{
ee_putByte(0xFF, addr);
}
}



Expand Down
Loading

0 comments on commit 721d9ca

Please sign in to comment.