Resolved ! Troubleshooting current measurement motor shield v3

Hi all,

I use an arduino UNO with a motor shield v3 (L298P) to control a stepper motor.
I don't arrive to measure the current on analogpin A0, A1. The terminal displays always 0.00

The arduino UNO is powering throught the motor shield card (12 Vdc).

I tested this program https://electrotoile.eu/commande-moteur-avec-shield-motor-l298P-sur-arduino.php

float Intensite = 0;


void setup() {
  
  Serial.begin(9600);
  
  pinMode(3, OUTPUT); // Déclaration de la broche n°3 en sortie Digitale PWM
  pinMode(8, OUTPUT); // Déclaration de la broche n°8 en sortie Digitale
  pinMode(9, OUTPUT); // Déclaration de la broche n°8 en sortie Digitale
  pinMode(11, OUTPUT); // Déclaration de la broche n°11 en sortie Digitale PWM
  pinMode(12, OUTPUT); // Déclaration de la broche n°12 en sortie Digitale
  pinMode(13, OUTPUT); // Déclaration de la broche n°13 en sortie Digitale
}

void loop(){
  // Commande moteur pas à pas Unipolaire 5 fils en Full Step
  // Pas n°1 | Sorties B- et B+ du Shield Moteur -> Bobines A et B du moteur pas à pas
  digitalWrite(8, HIGH); //Activation Pin n°8
  digitalWrite(9, LOW); //Désactivation Pin n°9
  digitalWrite(12, LOW); //Désactivation Pin n°12
  digitalWrite(13, HIGH); //Activation Pin n°13
  analogWrite(3,0); //Pin 3 PWM valeur 0
  analogWrite(11, 255); //Pin 11 PWM valeur 255
  delay(20);
  
  // Pas n°2 | Sorties B+ et A- du Shield Moteur -> Bobines B et C du moteur pas à pas 
  digitalWrite(8, LOW); //Désactivation Pin n°8
  digitalWrite(9, LOW); //Désactivation Pin n°9
  digitalWrite(12, LOW);  //Désactivation Pin n°12
  digitalWrite(13, HIGH); //Activation Pin n°13
  analogWrite(3, 255); //Pin 3 PWM valeur 255
  analogWrite(11, 255); //Pin 11 PWM valeur 255
  delay(20);
  
  // Pas n°3 | Sorties A- et A+ du Shield Moteur -> Bobines C et D du moteur pas à pas 
  digitalWrite(8,LOW);  //Désactivation Pin n°8
  digitalWrite(9,  HIGH); //Activation Pin n°9
  digitalWrite(12, HIGH); //Activation Pin n°12
  digitalWrite(13, LOW);  //Désactivation Pin n°13
  analogWrite(3,255); //Pin 3 PWM valeur 255
  analogWrite(11, 0); //Pin 11 PWM valeur 0
  delay(20);
  
  // Pas n°4 | Sorties A+ et A- du Shield Moteur -> Bobines D et A du moteur pas à pas 
  digitalWrite(8, LOW);  //Désactivation Pin n°8
  digitalWrite(9, LOW); //Désactivation Pin n°9
  digitalWrite(12, HIGH); //Activation Pin n°12
  digitalWrite(13, LOW);  //Désactivation Pin n°13
  analogWrite(3, 255); //Pin 3 PWM valeur 255
  analogWrite(11, 255); //Pin 11 PWM valeur 255
  delay(20);
  
   Intensite = analogRead(A0); // Lecture de l'entrée analogique A0
   Intensite = map(Intensite, 0, 255, 0, 2000); // Mappage de l'intensité en milliAmpère
   Intensite = Intensite/1000; // Convertion de l'intensité en Ampère
   Serial.print("Consommation = "); // Affichage du texte
   Serial.println(Intensite); // Affichage de l'intensité consommée par le moteur connecté sur la voie A
}

On the site, we can see an example for measuring current on a dc motor and I adapted it on a stepper motor but don't work.
Have you got an idea of my problem ? Must I use interruption perhaps ?
Is there a analog voltage reference problem ?

Thank in advance for your help

Try printing your Intensite variable immediately after the analogRead.

Thanks for your response, I tested and I've same result : 0.00

I don't understand what the problem

How do you have it wired up?

the motor shield is pinned directly to UNO

I specify that I directly tested the analog inputs of the UNO with a potentiometer, that works and also I bought a new motor shield in doubt

Can you please provide a picture?

I don't see anything attached to the analog pins

analog pins of motor shield are directly plugged to UNO analog pins

tempsnip

Capture

Hi all,

I answer myself. In fact, the problem was that my stepper motor commun wire was plugged into Gnd instead of 12Vdc on the motor shield board.

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