Actionneur: I2C (non testé) + nouvelle butée ascenseur
This commit is contained in:
parent
b405fbdb76
commit
75ea97fdd5
@ -39,6 +39,8 @@ struct position_t{
|
|||||||
uint position;
|
uint position;
|
||||||
} cible_haute, cible_basse, actuelle;
|
} cible_haute, cible_basse, actuelle;
|
||||||
|
|
||||||
|
enum etat_action_t Actionneur_deplacement(void);
|
||||||
|
enum etat_action_t Actionneur_prise_initiale(void);
|
||||||
enum etat_action_t Actionneur_empile(void);
|
enum etat_action_t Actionneur_empile(void);
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
@ -228,38 +230,31 @@ void loop()
|
|||||||
case 2:
|
case 2:
|
||||||
// Position de déplacement
|
// Position de déplacement
|
||||||
// Fourche levée pour ne pas géner les capteurs
|
// Fourche levée pour ne pas géner les capteurs
|
||||||
Servo_set(FOURCHE_LEVEE);
|
if(Actionneur_deplacement() == ACTION_TERMINEE){
|
||||||
// Ascenseur en bas
|
I2C_memory[I2C_DCE_REALISE] = I2C_memory[I2C_CDE_DEMANDE];
|
||||||
Ascenseur_descend();
|
}
|
||||||
// Pinces internes fermées
|
|
||||||
Servo_set(DOIGT_PINCE_DROIT_FERME);
|
|
||||||
Servo_set(DOIGT_PINCE_GAUCHE_FERME);
|
|
||||||
// Aimant rentrés
|
|
||||||
Servo_set(AIMANT_PINCE_DROIT_LACHE);
|
|
||||||
Servo_set(AIMANT_PINCE_GAUCHE_LACHE);
|
|
||||||
// Translateur à l'arrière
|
|
||||||
Translateur_recule();
|
|
||||||
I2C_memory[I2C_DCE_REALISE] = 2;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
// Prise initiale
|
// Prise initiale
|
||||||
// Fourche en position de prise
|
if(Actionneur_prise_initiale() == ACTION_TERMINEE){
|
||||||
Servo_set(FOURCHE_PRISE);
|
I2C_memory[I2C_DCE_REALISE] = I2C_memory[I2C_CDE_DEMANDE];
|
||||||
// Ascenseur en bas
|
}
|
||||||
Ascenseur_descend();
|
break;
|
||||||
// Pinces internes fermées
|
|
||||||
Servo_set(DOIGT_PINCE_DROIT_FERME);
|
|
||||||
Servo_set(DOIGT_PINCE_GAUCHE_FERME);
|
|
||||||
// Aimant rentrés
|
|
||||||
Servo_set(AIMANT_PINCE_DROIT_TIENT);
|
|
||||||
Servo_set(AIMANT_PINCE_GAUCHE_TIENT);
|
|
||||||
// Translateur à l'arrière
|
|
||||||
Translateur_recule();
|
|
||||||
I2C_memory[I2C_DCE_REALISE] = 3;
|
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
// Position de transport
|
// Position de transport
|
||||||
|
// Utile ? - n'est-ce pas la position après la prise initiale ?
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 5:
|
||||||
|
// Empile
|
||||||
|
if(Actionneur_empile() == ACTION_TERMINEE){
|
||||||
|
I2C_memory[I2C_DCE_REALISE] = I2C_memory[I2C_CDE_DEMANDE];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -269,6 +264,27 @@ void loop()
|
|||||||
// get incoming byte:
|
// get incoming byte:
|
||||||
int inByte = 0;
|
int inByte = 0;
|
||||||
inByte = Serial.read();
|
inByte = Serial.read();
|
||||||
|
if(inByte == '?'){
|
||||||
|
// Affiche le menu
|
||||||
|
Serial.println("d: Ascenseur step down");
|
||||||
|
Serial.println("u: Ascenseur step up");
|
||||||
|
Serial.println("m: Ascenseur monte");
|
||||||
|
Serial.println("l: Ascenseur descend");
|
||||||
|
Serial.println("a: Translateur avance");
|
||||||
|
Serial.println("z: Translateur recule");
|
||||||
|
Serial.println("w: Doigt pince ouvre");
|
||||||
|
Serial.println("x: Doigt pince ferme");
|
||||||
|
Serial.println("1: Reglage servo 8");
|
||||||
|
Serial.println("2: Reglage servo 9");
|
||||||
|
Serial.println("3: Reglage servo fourche (5)");
|
||||||
|
Serial.println("v: Cycle ascenseur");
|
||||||
|
Serial.println("c: Cycle translateur");
|
||||||
|
Serial.println("h: Actionneur, position de déplacement");
|
||||||
|
Serial.println("j: Actionneur, prise initiale");
|
||||||
|
Serial.println("k: Actionneur, empile");
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
if(inByte == 'd'){
|
if(inByte == 'd'){
|
||||||
Ascenseur_step_down();
|
Ascenseur_step_down();
|
||||||
}
|
}
|
||||||
@ -284,15 +300,15 @@ void loop()
|
|||||||
if(inByte == 'a'){
|
if(inByte == 'a'){
|
||||||
Translateur_avance();
|
Translateur_avance();
|
||||||
}
|
}
|
||||||
|
if(inByte == 'z'){
|
||||||
|
Translateur_recule();
|
||||||
|
}
|
||||||
if(inByte == 'w'){
|
if(inByte == 'w'){
|
||||||
Servo_set(DOIGT_PINCE_GAUCHE_OUVRE);
|
Servo_set(DOIGT_PINCE_GAUCHE_OUVRE);
|
||||||
}
|
}
|
||||||
if(inByte == 'x'){
|
if(inByte == 'x'){
|
||||||
Servo_set(DOIGT_PINCE_GAUCHE_FERME);
|
Servo_set(DOIGT_PINCE_GAUCHE_FERME);
|
||||||
}
|
}
|
||||||
if(inByte == 'z'){
|
|
||||||
Translateur_recule();
|
|
||||||
}
|
|
||||||
if(inByte == '1'){
|
if(inByte == '1'){
|
||||||
reglage_servo(8);
|
reglage_servo(8);
|
||||||
}
|
}
|
||||||
@ -302,9 +318,21 @@ void loop()
|
|||||||
if(inByte == '3'){
|
if(inByte == '3'){
|
||||||
reglage_servo(5);
|
reglage_servo(5);
|
||||||
}
|
}
|
||||||
if(inByte == 'u'){
|
if(inByte == 'h'){
|
||||||
|
while(Actionneur_deplacement() == ACTION_EN_COURS);
|
||||||
|
}
|
||||||
|
if(inByte == 'j'){
|
||||||
|
while(Actionneur_prise_initiale() == ACTION_EN_COURS);
|
||||||
|
}
|
||||||
|
if(inByte == 'k'){
|
||||||
while(Actionneur_empile() == ACTION_EN_COURS);
|
while(Actionneur_empile() == ACTION_EN_COURS);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
if(inByte == 'u'){
|
||||||
|
while(Actionneur_deplacement() == ACTION_EN_COURS);
|
||||||
|
while(Actionneur_prise_initiale() == ACTION_EN_COURS);
|
||||||
|
while(Actionneur_empile() == ACTION_EN_COURS);
|
||||||
|
}*/
|
||||||
if(inByte == 'v'){
|
if(inByte == 'v'){
|
||||||
Ascenseur_cycle();
|
Ascenseur_cycle();
|
||||||
}
|
}
|
||||||
@ -385,44 +413,33 @@ void Servo_set(int servo, int position){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum etat_action_t Actionneur_deplacement(void){
|
||||||
|
Servo_set(FOURCHE_LEVEE);
|
||||||
|
// Ascenseur en bas
|
||||||
|
Ascenseur_descend();
|
||||||
|
// Pinces internes fermées
|
||||||
|
Servo_set(DOIGT_PINCE_DROIT_FERME);
|
||||||
|
Servo_set(DOIGT_PINCE_GAUCHE_FERME);
|
||||||
|
// Aimant rentrés
|
||||||
|
Servo_set(AIMANT_PINCE_DROIT_LACHE);
|
||||||
|
Servo_set(AIMANT_PINCE_GAUCHE_LACHE);
|
||||||
|
// Translateur à l'arrière
|
||||||
|
Translateur_recule();
|
||||||
|
|
||||||
enum etat_action_t Actionneur_empile(){
|
return ACTION_TERMINEE;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
enum etat_action_t Actionneur_prise_initiale(void){
|
||||||
static enum etat_actionneur_t{
|
static enum etat_actionneur_t{
|
||||||
ACTIONNEUR_DEPLACEMENT,
|
|
||||||
ACTIONNEUR_PRISE_EXTERNE,
|
|
||||||
ACTIONNEUR_DEPILE,
|
ACTIONNEUR_DEPILE,
|
||||||
ACTIONNEUR_PRISE_INTERNE_1,
|
ACTIONNEUR_PRISE_INTERNE_1,
|
||||||
ACTIONNEUR_PRISE_INTERNE_2,
|
ACTIONNEUR_PRISE_INTERNE_2,
|
||||||
ACTIONNEUR_RECULE_PRISE_INTERNE_1,
|
ACTIONNEUR_RECULE_PRISE_INTERNE_1,
|
||||||
ACTIONNEUR_RECULE_PRISE_INTERNE_2,
|
ACTIONNEUR_RECULE_PRISE_INTERNE_2
|
||||||
ACTIONNEUR_LEVE,
|
} etat_actionneur=ACTIONNEUR_DEPILE;
|
||||||
ACTIONNEUR_AVANCE_PRISE_INTERNE,
|
|
||||||
ACTIONNEUR_DEPOSE_PRISE_INTERNE,
|
|
||||||
ACTIONNEUR_RANGE_TRANSLATEUR,
|
|
||||||
ACTIONNEUR_DESCEND
|
|
||||||
} etat_actionneur=ACTIONNEUR_DEPLACEMENT;
|
|
||||||
|
|
||||||
switch(etat_actionneur){
|
switch(etat_actionneur){
|
||||||
case ACTIONNEUR_DEPLACEMENT:
|
|
||||||
Servo_set(FOURCHE_TRANSPORT);
|
|
||||||
Translateur_recule();
|
|
||||||
Servo_set(DOIGT_PINCE_GAUCHE_FERME);
|
|
||||||
Servo_set(DOIGT_PINCE_DROIT_FERME);
|
|
||||||
Servo_set(AIMANT_PINCE_DROIT_LACHE);
|
|
||||||
Servo_set(AIMANT_PINCE_GAUCHE_LACHE);
|
|
||||||
delay(5000);
|
|
||||||
etat_actionneur = ACTIONNEUR_PRISE_EXTERNE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ACTIONNEUR_PRISE_EXTERNE:
|
|
||||||
Servo_set(FOURCHE_PRISE);
|
|
||||||
Servo_set(AIMANT_PINCE_DROIT_LACHE);
|
|
||||||
Servo_set(AIMANT_PINCE_GAUCHE_LACHE);
|
|
||||||
// Attente avance
|
|
||||||
delay(2000);
|
|
||||||
etat_actionneur = ACTIONNEUR_DEPILE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ACTIONNEUR_DEPILE:
|
case ACTIONNEUR_DEPILE:
|
||||||
Servo_set(FOURCHE_LEVEE);
|
Servo_set(FOURCHE_LEVEE);
|
||||||
etat_actionneur = ACTIONNEUR_PRISE_INTERNE_1;
|
etat_actionneur = ACTIONNEUR_PRISE_INTERNE_1;
|
||||||
@ -457,13 +474,36 @@ enum etat_action_t Actionneur_empile(){
|
|||||||
case ACTIONNEUR_RECULE_PRISE_INTERNE_2:
|
case ACTIONNEUR_RECULE_PRISE_INTERNE_2:
|
||||||
Serial.println("ACTIONNEUR_RECULE_PRISE_INTERNE_2");
|
Serial.println("ACTIONNEUR_RECULE_PRISE_INTERNE_2");
|
||||||
if(Translateur_etat() == ACTION_TERMINEE){
|
if(Translateur_etat() == ACTION_TERMINEE){
|
||||||
etat_actionneur = ACTIONNEUR_LEVE;
|
Servo_set(FOURCHE_TRANSPORT);
|
||||||
Ascenseur_monte();
|
etat_actionneur=ACTIONNEUR_DEPILE;
|
||||||
|
return ACTION_TERMINEE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
Ascenseur_gestion();
|
||||||
|
return ACTION_EN_COURS;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
enum etat_action_t Actionneur_empile(){
|
||||||
|
static enum etat_actionneur_t{
|
||||||
|
ACTIONNEUR_LEVE,
|
||||||
|
ACTIONNEUR_LEVE_1,
|
||||||
|
ACTIONNEUR_AVANCE_PRISE_INTERNE,
|
||||||
|
ACTIONNEUR_DEPOSE_PRISE_INTERNE,
|
||||||
|
ACTIONNEUR_RANGE_TRANSLATEUR,
|
||||||
|
ACTIONNEUR_DESCEND
|
||||||
|
} etat_actionneur=ACTIONNEUR_LEVE;
|
||||||
|
|
||||||
|
switch(etat_actionneur){
|
||||||
case ACTIONNEUR_LEVE:
|
case ACTIONNEUR_LEVE:
|
||||||
Serial.println("ACTIONNEUR_LEVE");
|
Serial.println("ACTIONNEUR_LEVE");
|
||||||
|
etat_actionneur = ACTIONNEUR_LEVE_1;
|
||||||
|
Ascenseur_monte();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ACTIONNEUR_LEVE_1:
|
||||||
|
Serial.println("ACTIONNEUR_LEVE_1");
|
||||||
if(Ascenseur_get_etat() == ACTION_TERMINEE){
|
if(Ascenseur_get_etat() == ACTION_TERMINEE){
|
||||||
etat_actionneur = ACTIONNEUR_AVANCE_PRISE_INTERNE;
|
etat_actionneur = ACTIONNEUR_AVANCE_PRISE_INTERNE;
|
||||||
Translateur_avance();
|
Translateur_avance();
|
||||||
@ -503,8 +543,7 @@ enum etat_action_t Actionneur_empile(){
|
|||||||
case ACTIONNEUR_DESCEND:
|
case ACTIONNEUR_DESCEND:
|
||||||
Serial.println("ACTIONNEUR_DESCEND");
|
Serial.println("ACTIONNEUR_DESCEND");
|
||||||
if(Ascenseur_get_etat() == ACTION_TERMINEE){
|
if(Ascenseur_get_etat() == ACTION_TERMINEE){
|
||||||
etat_actionneur = ACTIONNEUR_DEPLACEMENT;
|
etat_actionneur = ACTIONNEUR_LEVE;
|
||||||
Servo_set(FOURCHE_TRANSPORT);
|
|
||||||
return ACTION_TERMINEE;
|
return ACTION_TERMINEE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#include <Wire.h>
|
||||||
|
|
||||||
#define TAILLE_MEMOIRE_I2C 256
|
#define TAILLE_MEMOIRE_I2C 256
|
||||||
#define TAILLE_MESSAGE_ENVOI_MAX 32
|
#define TAILLE_MESSAGE_ENVOI_MAX 32
|
||||||
byte memoire_I2C[TAILLE_MEMOIRE_I2C];
|
byte memoire_I2C[TAILLE_MEMOIRE_I2C];
|
||||||
|
Loading…
Reference in New Issue
Block a user