1
0
Fork 0
mirror of https://github.com/RobotechLille/cdf2018-principal synced 2024-12-22 05:30:37 +01:00
This commit is contained in:
Geoffrey Frogeye 2018-05-10 10:09:44 +02:00
parent 9802230d13
commit d30f0ed548
7 changed files with 36 additions and 27 deletions

View file

@ -36,24 +36,26 @@ void barilletUnCran()
{ {
ax12a.setEndless(ID, ON); ax12a.setEndless(ID, ON);
ax12a.turn(ID, LEFT, 1220); ax12a.turn(ID, LEFT, 1224);
delay(978); delay(978);
ax12a.turn(ID, LEFT, 200); ax12a.turn(ID, LEFT, 200);
delay(100); delay(100);
ax12a.turn(ID, LEFT, 1224); ax12a.turn(ID, LEFT, 1224);
delay(100); delay(100);
ax12a.turn(ID, LEFT, 0);
} }
void barilletDeuxCrans() void barilletDeuxCrans()
{ {
ax12a.setEndless(ID, ON); ax12a.setEndless(ID, ON);
ax12a.turn(ID, LEFT, 1220); ax12a.turn(ID, LEFT, 1224);
delay(1955); delay(1955);
ax12a.turn(ID, LEFT, 200); ax12a.turn(ID, LEFT, 200);
delay(100); delay(100);
ax12a.turn(ID, LEFT, 1224); ax12a.turn(ID, LEFT, 1224);
delay(100); delay(100);
ax12a.turn(ID, LEFT, 0);
} }
void loop() void loop()
@ -96,11 +98,9 @@ void loop()
break; break;
case 'B': // Tourner barillet d'un cran case 'B': // Tourner barillet d'un cran
barilletUnCran(); barilletUnCran();
delay(500);
break; break;
case 'H': // Tourner de deux crans case 'H': // Tourner de deux crans
barilletDeuxCrans(); barilletDeuxCrans();
delay(500);
break; break;
case 'R': // Reset barillet case 'R': // Reset barillet
// ax12a.setEndless(ID, OFF); // ax12a.setEndless(ID, OFF);
@ -133,4 +133,4 @@ void loop()
Serial.write(lettre); Serial.write(lettre);
} }
} }
} }

View file

@ -11,7 +11,7 @@
#define FPGA_PORTNAME "/dev/ttyUSB0" #define FPGA_PORTNAME "/dev/ttyUSB0"
#define CF_BAUDRATE B115200 #define CF_BAUDRATE B115200
// #define PRINTRAWDATA // #define PRINTRAWDATA
//
typedef void (*rxHandler)(void); typedef void (*rxHandler)(void);
void registerRxHandlerCF(unsigned char code, rxHandler handler); // À utiliser après configureCF(); void registerRxHandlerCF(unsigned char code, rxHandler handler); // À utiliser après configureCF();

View file

@ -97,7 +97,7 @@ bool diagJustRun(void* arg)
{ {
void (*fonction)(void) = arg; void (*fonction)(void) = arg;
fonction(); fonction();
usleep(1000*1000); usleep(300*1000);
return true; return true;
} }
@ -160,8 +160,8 @@ void runDiagnostics()
i = 3; i = 3;
execDiagnostic("Mot+Cod R AR", diagCodeuse, &i); execDiagnostic("Mot+Cod R AR", diagCodeuse, &i);
execDiagnostic("Fermeture loquet", diagJustRun, &diagSetLoquetFerme);
execDiagnostic("Ouverture loquet", diagJustRun, &diagSetLoquetOuvert); execDiagnostic("Ouverture loquet", diagJustRun, &diagSetLoquetOuvert);
execDiagnostic("Fermeture loquet", diagJustRun, &diagSetLoquetFerme);
execDiagnostic("Reset barillet", diagJustRun, &barilletReset); execDiagnostic("Reset barillet", diagJustRun, &barilletReset);
execDiagnostic("T+1 barillet", diagJustRun, &barilletSuivant); execDiagnostic("T+1 barillet", diagJustRun, &barilletSuivant);
execDiagnostic("T+2 barillet", diagJustRun, &barilletSkip); execDiagnostic("T+2 barillet", diagJustRun, &barilletSkip);

View file

@ -10,7 +10,7 @@
#define DIAGNOSTIC_TENSION_TEST 3 #define DIAGNOSTIC_TENSION_TEST 3
#define DIAGNOSTIC_CODEUSES_DIFF_MIN 100 #define DIAGNOSTIC_CODEUSES_DIFF_MIN 100
#define DIAGNOSTIC_TEMPS_ROTATION 250 #define DIAGNOSTIC_TEMPS_ROTATION 500
typedef bool (*diagnosticFunc)(void* arg); typedef bool (*diagnosticFunc)(void* arg);

View file

@ -21,7 +21,7 @@
#define MOTOR_CONTROLLER_ALIMENTATION 24.0 // V (from elec) #define MOTOR_CONTROLLER_ALIMENTATION 24.0 // V (from elec)
#define MOTOR_CONTROLLER_REFERENCE 5 // V (from wiring) #define MOTOR_CONTROLLER_REFERENCE 5 // V (from wiring)
#define MOTOR_SATURATION_MIN 0 // V (from random) #define MOTOR_SATURATION_MIN 0 // V (from random)
#define MOTOR_SATURATION_MAX 12.0 // V (from testing) #define MOTOR_SATURATION_MAX 3.0 // V (from testing)
#define PWM_MAX 3.3 // V (from FPGA datasheet) #define PWM_MAX 3.3 // V (from FPGA datasheet)
#define CODER_RESOLUTION 370.0 // cycles/motor rev #define CODER_RESOLUTION 370.0 // cycles/motor rev
#define CODER_DATA_FACTOR 4.0 // increments/motor cycles #define CODER_DATA_FACTOR 4.0 // increments/motor cycles
@ -38,8 +38,8 @@
#define O_DIR_ECART_MIN (5.0 / 360.0 * 2.0 * M_PI) // rad #define O_DIR_ECART_MIN (5.0 / 360.0 * 2.0 * M_PI) // rad
#define O_DIR_ECART_MAX (25.0 / 360.0 * 2.0 * M_PI) // rad #define O_DIR_ECART_MAX (25.0 / 360.0 * 2.0 * M_PI) // rad
#define O_ECART_MAX (25.0 / 360.0 * 2.0 * M_PI) // rad #define O_ECART_MAX (25.0 / 360.0 * 2.0 * M_PI) // rad
#define O_GAIN 3.0 #define O_GAIN 5.0
#define P 7.0 #define P 5.0
#define I 0.0 #define I 0.0
#define D 0.0 #define D 0.0

View file

@ -21,6 +21,19 @@ void initLCD()
pinMode(LCD_ON_PIN, OUTPUT); pinMode(LCD_ON_PIN, OUTPUT);
} }
void eraseLCD()
{
lockLCD();
sendLCD(0x01, LCD_MODE_CMD);
sendLCD(0x02, LCD_MODE_CMD);
for (int i = 0; i < LCD_NB_TOTAL; i++) {
virtual[i] = ' ';
}
unlockLCD();
}
void onLCD() void onLCD()
{ {
digitalWrite(LCD_ON_PIN, LOW); digitalWrite(LCD_ON_PIN, LOW);
@ -32,7 +45,7 @@ void onLCD()
sendLCD(0x06, LCD_MODE_CMD); // Cursor move direction sendLCD(0x06, LCD_MODE_CMD); // Cursor move direction
sendLCD(0x0C, LCD_MODE_CMD); // Blink Off sendLCD(0x0C, LCD_MODE_CMD); // Blink Off
sendLCD(0x28, LCD_MODE_CMD); // Data length, number of lines, font size sendLCD(0x28, LCD_MODE_CMD); // Data length, number of lines, font size
clearLCD(); eraseLCD();
delay(50); delay(50);
} }
@ -57,14 +70,8 @@ void resetLCD()
void clearLCD() void clearLCD()
{ {
lockLCD(); offLCD();
sendLCD(0x01, LCD_MODE_CMD); onLCD();
sendLCD(0x02, LCD_MODE_CMD);
for (int i = 0; i < LCD_NB_TOTAL; i++) {
virtual[i] = ' ';
}
unlockLCD();
} }
void gotoLCD(uint8_t line) void gotoLCD(uint8_t line)

View file

@ -3,7 +3,7 @@ SIMULATION = 0;
% Paramètres de lecture % Paramètres de lecture
DIRNAME = "/home/geoffrey/CdF/cdf2018-principal/log/"; DIRNAME = "/home/geoffrey/CdF/cdf2018-principal/log/";
FILENAME = "000471.csv"; FILENAME = "000655.csv";
PATH = DIRNAME + FILENAME; PATH = DIRNAME + FILENAME;
% Paramètres de simulation % Paramètres de simulation
@ -33,7 +33,7 @@ motorNominalTension = 24.0; % V (from datasheet)
motorControllerAlimentation = 24.0; % V (from elec) motorControllerAlimentation = 24.0; % V (from elec)
motorControllerReference = 5; % V (from wiring) motorControllerReference = 5; % V (from wiring)
motorSaturationMin = 0; % V (from random) motorSaturationMin = 0; % V (from random)
motorSaturationMax = 12.0; % V (from testing) motorSaturationMax = 3.0; % V (from testing)
pwmMax = 3.3; % V (from FPGA datasheet) pwmMax = 3.3; % V (from FPGA datasheet)
coderResolution = 370.0; % cycles/motor rev coderResolution = 370.0; % cycles/motor rev
coderDataFactor = 4.0; % increments/motor cycles coderDataFactor = 4.0; % increments/motor cycles
@ -51,8 +51,8 @@ dDirEcartMax = 10.0; % mm
oDirEcartMin = (5.0 / 360.0 * 2.0 * pi); % rad oDirEcartMin = (5.0 / 360.0 * 2.0 * pi); % rad
oDirEcartMax = (25.0 / 360.0 * 2.0 * pi); % rad oDirEcartMax = (25.0 / 360.0 * 2.0 * pi); % rad
oEcartMax = (25.0 / 360.0 * 2.0 * pi); % rad oEcartMax = (25.0 / 360.0 * 2.0 * pi); % rad
oGain = 3.0; oGain = 5.0;
P = 7.0; P = 5.0;
I = 0.0; I = 0.0;
D = 0.0; D = 0.0;
@ -130,13 +130,15 @@ legend("Gauche", "Droite", "Err. gauche", "Err. droite");
% Distance % Distance
p = subplot(2, 2, 3); p = subplot(2, 2, 3);
hold on; hold on;
timeGraph(["dDirEcart", "dErr"]); %timeGraph(["dDirEcart", "dErr"]);
timeGraph(["dDirEcart", "dErr", "secFront", "secBack"]);
addLimitline(p, dDirEcartMin); addLimitline(p, dDirEcartMin);
addLimitline(p, dDirEcartMax); addLimitline(p, dDirEcartMax);
title("Distance"); title("Distance");
xlabel("Temps (s)"); xlabel("Temps (s)");
ylabel("Distance (mm)"); ylabel("Distance (mm)");
legend("Ecart direction", "Err. retenue"); %legend("Ecart direction", "Err. retenue");
legend("Ecart direction", "Err. retenue", "Distance avant", "Distance arrière");
% Rotation % Rotation
p = subplot(2, 2, 4); p = subplot(2, 2, 4);