Go Down

Topic: Drive bipolar stepper motor on arduino Uno with X-nucleo-IHM05A1 stacked on it (Read 187 times) previous topic - next topic

malnyr

Hi everyone, thanks for welcoming me here.

I started a project where I have to drive a bipolar stepper motor.

I must use an arduino Uno with a x-nucleo-ihm05a1 stacked on it.

I look all day long yesterday for tutorials, schematics, circuits diagrams and code examples.
I found tutorials of bipolar stepper motor with ihm05a1 stacked on stm32 board.

I need somehow to also make it work with an arduino Uno.
My problem is that I don't understand how to "translate ST code to Arduino code" or to reach the A and B outputs of ihm05a1 with the arduino Uno to control the phases.

Can someone help me to start my project please

Robin2

What is a "x-nucleo-ihm05a1" ?   Please post a link to its datasheet.

Also please post a link to the datasheet for the stepper motor you propose to use.

...R
Stepper Motor Basics
Simple Stepper Code
Two or three hours spent thinking and reading documentation solves most programming problems.

malnyr

Thanks for your aswer, here all the components I am using :

X-Nucleo-IHM05A1 : https://www.st.com/resource/en/data_brief/x-nucleo-ihm05a1.pdf

L6208 (in the X-Nucleo-IHM05A1) : https://www.st.com/resource/en/datasheet/l6208.pdf

Stepper motor used :https://datasheet4u.com/datasheet-pdf/Busheng/17HD48002-22B/pdf.php?id=1147974




Robin2

I can't see from the first datasheet how the pins relate to the Arduino Uno pins. Do you have a link to a document that explains that?

...R
Two or three hours spent thinking and reading documentation solves most programming problems.


Robin2

Two or three hours spent thinking and reading documentation solves most programming problems.

Robin2

Sorry, but I can't read that. Please just post a link to the document.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

malnyr


Robin2

They seem remarkably reluctant to provide information.

As far as I can see the direction Pin is 7 and the step pin is 6. I suggest you try those in my Simple Stepper Code.

What's not clear is whether you also need a specific setting for Pin 2 (enable), Pin 11 (reset) Pin  5 (control) or pin 4 (half/full)

It may help to make all of those LOW (or some of them HIGH).


If you have an example program then please post it - it may shed some light on the subject.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

CrossRoads

Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

CrossRoads

They appear to have analog inputs VrefA and VrefB coming from Arduino digital PWM pins.  The board has RC filter built in on D3 and D10. You'll have to figure out PWM levels needed for the desired control.

" When the voltage drop across the sense resistor becomes greater than the voltage at the reference input (VREFA or VREFB) the sense comparator triggers the monostable switching the bridge off."
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

malnyr

Thank for your answers.

Robin2, Yes finding information on that topic is quite hard, I spent 2 whole days on it and it's still messy.
I'll give a try to your simple stepper code.

CrossRoads, I did read the manal.
For the moment, I tried a code this evening by driving VrefA, VrefB with the Clock too. I tried every combinaison of these three signals by digital PWM arduino pins and I feel I need to order the right combinaisons to get proper rotation in the mode I chose. For now, I will work on Full Step Mode.
I think I need to study the logic diagram of the X-Nucleo-IHM05A1 (and L6208 Integrated Circuit) to understand what happen to the signals I send to VrefA and VrefB and how Va+, Va-, Vb+, Vb- are made by the L6208 Integrated Circuit component.

I'll get back If I make a little progress.

Please don't hesitate to tell me if I'm going in the right direction or if I need to use L6208 libraries to make something with it.

malnyr

Hello again.

I tried to send PWM signals to VrefA, VrefB and the Clock.
After a day of fails, I finally make the motor turn by only using this Arduino code :
Code: [Select]

//Main
#define MOT_ENABLE 2
#define REF_A_BIS 3
#define MODE 4
#define CONTROL 5
#define CLOCK_PIN 6
#define COUNTERWISE 7
//#define RESET 8
#define REF_B 9
#define REF_A 11

#include "FonctionsMot.h";

void setup() {
  #include "SetupPorts.h";
  //faire1Revo();
  faire12Revo();
}

void loop() {
  //faire1Revo();
}


Code: [Select]

//FonctionsMot.h
#define CLOCK_TIME 1
#define TEST_TIME 12


void testCombinaisons(){

   digitalWrite(REF_A, HIGH);
   digitalWrite(REF_B, LOW);
   digitalWrite(CLOCK_PIN, HIGH);
   delay(TEST_TIME);

   digitalWrite(REF_A, HIGH);
   digitalWrite(REF_B, LOW);
   digitalWrite(CLOCK_PIN, LOW);
   delay(TEST_TIME);
   
   digitalWrite(REF_A, LOW);
   digitalWrite(REF_B, HIGH);
   digitalWrite(CLOCK_PIN, HIGH);
   delay(TEST_TIME);

   digitalWrite(REF_A, LOW);
   digitalWrite(REF_B, HIGH);
   digitalWrite(CLOCK_PIN, LOW);
   delay(TEST_TIME);

}

void faire1Revo(){
  for(int i = 0 ; i < 100 ; i++) testCombinaisons();
}

void faire12Revo(){
  for(int i = 0 ; i < 100*12 ; i++) testCombinaisons();
}


Code: [Select]

//SetupPorts.h
Serial.begin(9600);

pinMode(MOT_ENABLE, OUTPUT);
pinMode(MODE, OUTPUT);
pinMode(CONTROL, OUTPUT);
pinMode(CLOCK_PIN, OUTPUT);
pinMode(COUNTERWISE, OUTPUT);
pinMode(REF_B, OUTPUT);
pinMode(REF_A, OUTPUT);
 
digitalWrite(MOT_ENABLE, HIGH);
digitalWrite(MODE, LOW); //FULL STEP mode
digitalWrite(CONTROL, HIGH); //SLOW DECAY mode
digitalWrite(COUNTERWISE, LOW); /*It says HIGH for clockwise but for me it's LOW that gives clockwise rotation*/


I need to drive this motor at the speed of 12rotations/min. I previously measured 9.75s to make 12 rotations with 2ms for TEST_TIME so I just multiplied by six the time for a step and I got 12 rotations in 57.5s.

I got a few problems including the heating and the vibrations. My apprentice master told me it's because stepper motor are using lot of current to rotate and the vibration may come from the fact that I'm using too much current to drive to motor so it gains rotational inertia and it does a little more than a step...

Now I need to understand how I can limit the vibrations and heating by controlling the current with my Arduino but I haven't seen anything like this so I'm a little lost. What's your thoughts guys ? I'd happy to receive your remarks.

Go Up