Skip to content

Commit

Permalink
avoid voltage QA for V0; improve skills of Nybble
Browse files Browse the repository at this point in the history
  • Loading branch information
borntoleave committed Oct 10, 2024
1 parent 4ccd3e1 commit 80892c3
Show file tree
Hide file tree
Showing 7 changed files with 242 additions and 141 deletions.
14 changes: 7 additions & 7 deletions src/InstinctBittleESP_arm.h
Original file line number Diff line number Diff line change
Expand Up @@ -1733,14 +1733,14 @@ const int8_t clap[] PROGMEM = {
0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30, 30, 30, 30, 8, 0, 0, 0,
0, -5,-120, 0, 5, 5, 3, 3, 71, 71, -58, -58, -60, -60, 74, 74, 12, 0, 0, 0,
0, -4,-120, 0, 5, 5, 3, 3, 47, 47, -25, -25, 9, 9, 90, 90, 12, 0, 0, 0,
0, 110, 120, 0, 5, 5, 3, 3, 12, 12, -15, -15, -37, -37, 90, 90, 64, 5, 0, 0,
0, 30,-120, 0, 5, 5, 3, 3, -41, -41, -15, -15, 16, 16, 90, 90, 48, 2, 0, 0,
0, 110, 120, 0, 5, 5, 3, 3, 12, 12, -13, -13, -37, -37, 90, 90, 48, 5, 0, 0,
0, 30,-120, 0, 5, 5, 3, 3, -41, -41, -13, -13, 16, 16, 90, 90, 48, 2, 0, 0,
25, 110, 120, 0, 5, 5, 3, 3, 12, -85, -15, -15, -37, 60, 90, 90, 64, 4, 0, 0,
0, 30,-120, 0, 5, 5, 3, 3, -41, -41, -15, -15, 16, 16, 90, 90, 48, 2, 0, 0,
-25, 110, 120, 0, 5, 5, 3, 3, -85, 12, -15, -15, 60, -37, 90, 90, 64, 4, 0, 0,
0, 30,-120, 0, 5, 5, 3, 3, -41, -41, -15, -15, 16, 16, 90, 90, 48, 2, 0, 0,
0, 120,-120, 0, 5, 5, 3, 3, 90, 90, -54, -54, -60, -60, 25, 25, 8, 0, 0, 0,
0, 120,-120, 0, 5, 5, 3, 3, 71, 71, 31, 31, -60, -60, -28, -28, 12, 0, 0, 0,
0, 120,-120, 0, 5, 5, 3, 3, 71, 71, -45, -45, -56, -56, 50, 50, 8, 0, 0, 0,
0, 120,-120, 0, 5, 5, 3, 3, 71, 71, 72, 72, -56, -56, -51, -51, 12, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30, 30, 30, 30, 12, 0, 0, 0,
};
const int8_t cmh[] PROGMEM = {
Expand Down Expand Up @@ -1996,9 +1996,9 @@ const int8_t pickUp[] PROGMEM = {
0, 0, 0,
0, -10, 0, 0, 0, 0, 0, 0, 16, 16, 30, 30, 30, 30, 30, 30, 32, 0, 0, 0,
0, 40, 85, -10, 10, 10, -20, -20, 5, 5, 10, 10, 20, 20, 50, 50, 48, 0, 0, 0,
0, 40, 85, -10, 10, 10, -20, -20, 5, 5, 10, 10, 20, 20, 50, 50, 64, 0, 0, 0,
0, 105, 85, -10, 10, 10, -20, -20, 53, 53, 40, 40, -28, -28, 35, 35, 4, 0, 0, 0,
0, 105, 0, -10, 10, 10, -20, -20, 53, 53, 40, 40, -28, -28, 35, 35, 8, 0, 0, 0,
0, 20, 85, -10, 10, 10, -20, -20, 5, 5, 10, 10, 20, 20, 50, 50, 64, 0, 0, 0,
0, 97, 85, -10, 10, 10, -20, -20, 53, 53, 40, 40, -28, -28, 35, 35, 4, 0, 0, 0,
0, 97, 0, -10, 10, 10, -20, -20, 53, 53, 40, 40, -28, -28, 35, 35, 8, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 20, 20, 30, 30, 30, 30, 30, 30, 8, 0, 0, 0,
};
const int8_t pu[] PROGMEM = {
Expand Down
299 changes: 176 additions & 123 deletions src/InstinctNybbleESP.h

Large diffs are not rendered by default.

31 changes: 24 additions & 7 deletions src/OpenCat.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@
#else
#define BOARD "B"
#endif
#define DATE "240923" // YYMMDD
#define DATE "241009" // YYMMDD
String SoftwareVersion = "";

#define BIRTHMARK '@' // Send '!' token to reset the birthmark in the EEPROM so that the robot will know to restart and reset

#define BT_BLE // toggle Bluetooth Low Energy (BLE)
#define BT_SSP // toggle Bluetooth Secure Simple Pairing (BT_SSP)
#define BT_BLE // toggle Bluetooth Low Energy (BLE)
#define BT_SSP // toggle Bluetooth Secure Simple Pairing (BT_SSP)
#define GYRO_PIN // toggle the Inertia Measurement Unit (IMU), i.e. the gyroscope
#define SERVO_FREQ 240

Expand All @@ -106,8 +106,14 @@ String SoftwareVersion = "";
#define HEAD
#define TAIL // the robot arm's clip is assigned to the tail joint
#define LL_LEG

#ifndef MINI
#define REGULAR P1S
#define KNEE P1S
#else
#define REGULAR P50
#define KNEE P50
#endif
#ifdef ROBOT_ARM
#include "InstinctBittleESP_arm.h"
#else
Expand Down Expand Up @@ -242,7 +248,8 @@ double rate = 1.0 * MAX_READING / BASE_RANGE;
enum ServoModel_t {
G41 = 0,
P1S,
P2K
P2K,
P50
};

ServoModel_t servoModelList[] = {
Expand Down Expand Up @@ -287,10 +294,11 @@ bool newBoard = false;
#define T_NAME 'n' // customize the Bluetooth device's broadcast name. e.g. nMyDog will name the device as "MyDog" \
// it takes effect the next time the board boosup. it won't interrupt the current connecton.
#define T_MELODY 'o'
#define T_CPG 'r' //Oscillator for Central Pattern Generator
#define T_PAUSE 'p' // pause
#define T_POWER 'P' // power, print the voltage
#define T_TASK_QUEUE 'q'
#define T_ROBOT_ARM 'r'
#define T_ROBOT_ARM 'R'
#define T_SAVE 's'
#define T_TILT 't'
#define T_TEMP 'T' // call the last skill data received from the serial port
Expand Down Expand Up @@ -415,10 +423,18 @@ int8_t middleShift[] = { 0, 15, 0, 0,
10, 10, -10, -10,
-30, -30, 30, 30 };
#elif defined BITTLE
#ifndef MINI
int8_t middleShift[] = { 0, -90, 0, 0,
-45, -45, -45, -45,
55, 55, -55, -55,
-55, -55, -55, -55 };
#else
int8_t middleShift[] = { 0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
-15, -15, -15, -15 };
#endif


#else // CUB
int8_t middleShift[] = { 0, 15, 0, 0,
Expand Down Expand Up @@ -556,10 +572,11 @@ int balanceSlope[2] = { 1, 1 }; // roll, pitch
#ifdef IR_PIN
#include "infrared.h"
#endif
#include "io.h"
#include "espServo.h"
#include "motion.h"
#include "randomMind.h"
#include "io.h"


#include "skill.h"
#include "moduleManager.h"
Expand Down Expand Up @@ -640,7 +657,6 @@ void initRobot() {
QA();

tQueue = new TaskQueue();

loadBySkillName("rest"); // must have to avoid memory crash. need to check why.
// allCalibratedPWM(currentAng); alone will lead to crash
delay(500);
Expand All @@ -651,6 +667,7 @@ void initRobot() {
if (!moduleDemoQ)
tQueue->addTask((exceptions) ? T_CALIBRATE : T_REST, "");
#endif
PTL("Ready!");
beep(24, 50);
idleTimer = millis();
}
4 changes: 2 additions & 2 deletions src/configConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,8 @@ void resetIfVersionOlderThan(String versionStr) {
long currentDate = atol(versionStr.c_str() + versionStr.length() - 6);
if (savedDate < currentDate) {
delay(1000);
PTH("\n* The previous version on the board is", savedVersionDate);
PTH("* The robot will reboot and upgrade to", versionStr);
PTTL("\n* The previous version on the board is ", savedVersionDate);
PTTL("* The robot will reboot and upgrade to ", versionStr);
resetAsNewBoard('X');
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/espServo.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
ServoModel servoG41(180, SERVO_FREQ, 500, 2500);
ServoModel servoP1S(270, SERVO_FREQ, 500, 2500); // 1s/4 = 250ms 250ms/2500us=100Hz
ServoModel servoP1L(270, SERVO_FREQ, 500, 2500);
ServoModel servoP50(120, SERVO_FREQ, 900, 2100);
#ifdef BiBoard2
#include "pcaServo.h"
#endif
Expand Down Expand Up @@ -47,6 +48,9 @@ void attachAllESPServos() {
case P2K:
modelObj[s] = &servoP1L;
break;
case P50:
modelObj[s] = &servoP50;
break;
}
servo[s].attach(PWM_pin[s], modelObj[s]);
zeroPosition[joint] = modelObj[s]->getAngleRange() / 2 + float(middleShift[joint]) * rotationDirection[joint];
Expand Down
2 changes: 1 addition & 1 deletion src/moduleManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ void read_serial() {
return;
}
newCmd[cmdLen++] = serialPort->read();
PTL(int8_t(newCmd[cmdLen]));
// PTHL(newCmd[cmdLen - 1], int8_t(newCmd[cmdLen - 1]));
} while (serialPort->available());
lastSerialTime = millis();
}
Expand Down
29 changes: 28 additions & 1 deletion src/qualityAssurance.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ float sDev(float *a, float m, int n) {
sum += (a[i] - m) * (a[i] - m);
return sqrt(sum / n);
}
byte DcDcGood[] = { 12, 19,
4, 4 };
byte DcDcBad[] = { 19, 16, 12,
16, 16, 16 };
byte mpuGood[] = { 12, 16, 19,
4, 4, 4 };
byte mpuBad[] = { 19, 17, 16, 14, 12,
Expand Down Expand Up @@ -81,7 +85,6 @@ bool testIR() {
else
return false;
}

if (millis() - timer > 11 && irrecv.decode(&results)) {
timer = millis();
current = IRkey();
Expand All @@ -108,6 +111,27 @@ bool testIR() {
}
}
#endif
void testDcDc() {
const int adcPin = 34;
const float R1 = 30000.0;
const float R2 = 51000.0;
const int adcMaxValue = 4095;
const float vRef = 3.3;
while (1) {
int adcValue = analogRead(adcPin);
float voltageMeasured = (adcValue / float(adcMaxValue)) * vRef;
float voltageInput = voltageMeasured * (R1 + R2) / R2;
if (voltageInput < 5.2) {
PTL("Wrong DcDc output!");
playMelody(DcDcBad, sizeof(DcDcBad) / 2);
delay(500);
} else {
PTL("\tDcDc Pass!");
playMelody(DcDcGood, sizeof(DcDcGood) / 2);
break;
}
}
}
void QA() {
if (newBoard) {
#ifdef I2C_EEPROM_ADDRESS
Expand All @@ -122,6 +146,9 @@ void QA() {
if (choice == 'Y' || choice == 'y')
#endif
{
#ifdef VOLTAGE
testDcDc();
#endif
#ifdef GYRO_PIN
testMPU6050();
#endif
Expand Down

0 comments on commit 80892c3

Please sign in to comment.