Ac motor speed control

Hello guys, I've been working on a poject where i want to control an ac motor with arduino, using space vector modulation for 3 phase inverter , yet when I try to modify the phase by adjusting the potentiometer position so I can vary the voltage destinated to the motor it doesn't change.
this is the circuit I worked with:

and this is the code I tried to work with:


// Déclaration des broches pour le contrôle du moteur
int AA1 = 3;
int AA2 = 5;
int BB1 = 6;
int BB2 = 9;
int CC1 = 10;
int CC2 = 11;

// Variable pour suivre la phase actuelle du moteur
int fase = 1;

// Variable pour régler le temps entre les changements de phase (vitesse du moteur)
int tiempo = 100;
unsigned long previousMillis = 0;

// Variable pour indiquer si le moteur est en arrêt (0) ou en mouvement (1)
int Stop = 0;

// Broche pour la lecture de la valeur du potentiomètre
int val = A0;

void setup() {
  // Initialise la communication série pour afficher des messages de débogage
  Serial.begin(9600);

  // Configure les broches de contrôle du moteur en sorties
  pinMode(AA1, OUTPUT);
  pinMode(AA2, OUTPUT);
  pinMode(BB1, OUTPUT);
  pinMode(BB2, OUTPUT);
  pinMode(CC1, OUTPUT);
  pinMode(CC2, OUTPUT);

  // Configure la broche du potentiomètre en entrée
  pinMode(val, INPUT);

  // Attends 1 seconde (1000 millisecondes) pour l'initialisation
  delay(1000);

  // Initialise la variable previousMillis avec le temps actuel en microsecondes
  previousMillis = micros();
}

void loop() {
  // Si le temps entre les changements de phase est trop long, arrête le moteur
  if (tiempo > 1950) {
    Stop = 0;
    tiempo = 1950;
    // Met les broches de contrôle du moteur en basse tension (arrêt)
    digitalWrite(AA1, LOW);
    digitalWrite(AA2, LOW);
    digitalWrite(BB1, LOW);
    digitalWrite(CC2, LOW);
    digitalWrite(BB2, LOW);
    digitalWrite(CC1, LOW);
  } else {
    Stop = 1;
  }

  // Si le moteur est en mouvement
  if (Stop == 1) {
    // Enregistre le temps actuel en microsecondes
    unsigned long currentMillis = micros();

    // Si le temps écoulé dépasse le temps défini
    if (currentMillis - previousMillis >= tiempo) {
      previousMillis += tiempo;

      // Commute la phase du moteur en fonction de la variable fase
      switch (fase) {
        case 1:
          // Phase 1 : C-B
          digitalWrite(AA1, LOW);
          digitalWrite(AA2, LOW);
          digitalWrite(BB1, LOW);
          digitalWrite(CC2, LOW);
          digitalWrite(BB2, HIGH);
          digitalWrite(CC1, HIGH);
          break;
        case 2:
          // Phase 2 : A-B
          digitalWrite(AA2, LOW);
          digitalWrite(BB1, LOW);
          digitalWrite(CC1, LOW);
          digitalWrite(CC2, LOW);
          digitalWrite(AA1, HIGH);
          digitalWrite(BB2, HIGH);
          break;
        case 3:
          // Phase 3 : A-C
          digitalWrite(AA2, LOW);
          digitalWrite(BB1, LOW);
          digitalWrite(BB2, LOW);
          digitalWrite(CC1, LOW);
          digitalWrite(CC2, HIGH);
          digitalWrite(AA1, HIGH);
          break;
        case 4:
          // Phase 4 : B-C
          digitalWrite(AA1, LOW);
          digitalWrite(AA2, LOW);
          digitalWrite(BB2, LOW);
          digitalWrite(CC1, LOW);
          digitalWrite(BB1, HIGH);
          digitalWrite(CC2, HIGH);
          break;
        case 5:
          // Phase 5 : B-A
          digitalWrite(AA1, LOW);
          digitalWrite(BB2, LOW);
          digitalWrite(CC1, LOW);
          digitalWrite(CC2, LOW);
          digitalWrite(AA2, HIGH);
          digitalWrite(BB1, HIGH);
          break;
        case 6:
          // Phase 6 : C-A
          digitalWrite(AA1, LOW);
          digitalWrite(BB1, LOW);
          digitalWrite(BB2, LOW);
          digitalWrite(CC2, LOW);
          digitalWrite(CC1, HIGH);
          digitalWrite(AA2, HIGH);
          break;
      }

      // Augmente la phase actuelle ou retourne à la phase 1
      if (fase < 6) {
        fase = fase + 1;
      } else {
        fase = 1;
      }
    }
  }

  // Lit la valeur analogique du potentiomètre
  int potValue = analogRead(val);

  // Ajuste le temps entre les changements de phase en fonction de la valeur du potentiomètre
  tiempo = map(potValue, 0, 1023, 1, 2000);

  // Affiche la phase actuelle et la vitesse sur le moniteur série à des fins de débogage
  Serial.print(fase);
  Serial.print("  ");
  Serial.println(tiempo);
}

Can You explain that, for helpers not being members of the club?

Please read and use this link: How to get the best out of this forum - Using Arduino / IDE 1.x - Arduino Forum

Note the part telling how to post code.
Screen shots are seldomly good. It refuses magnification and is not readable.

"it doesn't work" contains no information.

Hello, Thank you for your help, I am new to the forum, to answer your question :Space vector modulation is responsible for generating pulse width modulated signals to control the switches of an inverter, which then produces the required modulated voltage to drive the motor at the desired speed or torque.

Thanks. It looks like some kind of 3 phase output from the controller. Never mind, a bit outside my territory.
Everyone is new, some are more, the first time. The introductory topics are well worth checking up.

I would drop declaring A0 as input. It might set A0 as being a digital input. "analogRead(val)" fixes it in the compiler.

But, does the voltage itself change? Then you will know which side of the circuit to look at.

Normally the voltage, should vary when the fase changes, that's basically how it supposed to work, but it didn't change even when when the fase is supposedly changed.

But! As you developed the project, did it EVER change?

It didn't,
the whole project is based on that voltage changing because that's how the speed can vary , yet when you read the signals in the virtuel terminal, the switching clearly takes place, that's why i was confused and i didn't know where the problem exactly is.

IF that is the key to the operation, can you now track the source of the error and correct it? Make a copy of that part of the circuit and write code to exercise the circuit and find the problem.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.