0

I am using an FPGA with a stepper motor (and ULN 2003 driver board) and have not been able to make it go to a specific angle. I am using verilog so Arduino examples such as this cannot be used but this is precisely what I want.

What I have tried successfully:

//turn 90 degrees, then 90 again and so on

0: stepperPins <= 4'b1100; //this means 1A is HIGH, 1B is HIGH, 2A and 2B are LOW
1: stepperPins <= 4'b0110;
2: stepperPins <= 4'b0011;
3: stepperPins <= 4'b1001;

//180 to 210 degrees and repeat, the angle changing randomly

0: stepperPins <= 4'b1000;
1: stepperPins <= 4'b0100;
2: stepperPins <= 4'b0010;
3: stepperPins <= 4'b0001;
4: stepperPins <= 4'b1000;
5: stepperPins <= 4'b0100;
6: stepperPins <= 4'b0010;
7: stepperPins <= 4'b0001;

//90 degrees and repeat

0: stepperPins <= 4'b1110;
1: stepperPins <= 4'b0111;
2: stepperPins <= 4'b1011;
3: stepperPins <= 4'b1101;

//180 and repeat

0: stepperPins <= 4'b1100;
1: stepperPins <= 4'b1110;
2: stepperPins <= 4'b0110;
3: stepperPins <= 4'b0111;
4: stepperPins <= 4'b0011;
5: stepperPins <= 4'b1011;
6: stepperPins <= 4'b1001;
7: stepperPins <= 4'b1101;

How do I power the pins to get to say 30 degrees? or 115? Experimentally I did this:

0: stepperPins <= 4'b1100;
1: stepperPins <= 4'b0011;

but the motor didn't even move. I understand that half step angle is 5.625 degrees and full step angle is 11.25 but how to get multiples of them? I have spent more than a month searching for answers, so if anyone could kindly help me?

  • You'll need at least one absolute position reference. - Wait: Mechanical/shaft angle or "magnetical angle"? – greybeard Mar 31 '23 at 11:41
  • (1A to 2B being *what*?) – greybeard Mar 31 '23 at 11:50
  • 1A,1B,2A,2B are the names of the four coils when HIGH pulse is given to them. 1001 would mean 1A and 2B are HIGH rest are LOW. Also, I am talking about he mechanical angle. The ones in my post are what I have measured myself. – Thermal_insulator Mar 31 '23 at 12:02
  • (With the common/middle/red wire connected to "+ motor voltage" and an inverting driver, a H would mean *(half) phase winding energised*.) Please provide, in the question, some document(ation) what exactly the terminal designations refer to, in particular, whether a given "phase" shares the same digit or the same letter. – greybeard Mar 31 '23 at 13:04

1 Answers1

2

To turn to a specific angle/position you need at least one absolute position reference.

You get multiples of the step angle / turn by a specific angle by performing an appropriate number of steps.
For a motor with 32 steps per turn, the step angle is 360/32 = 11.25°.
To turn 30°, perform 30°/11.25° = 2⅔ steps. (Would be 4 steps with a 48 step/rev motor.)
For 130°, compute #steps = 130°/11.25° - alas, that's 11 5/9 steps.
Now, with reduction gears a multiple of 9, those would be full-steps again.

greybeard
  • 1,469
  • 1
  • 4
  • 17
  • What do I do in code to achieve that? How do I do 2 steps or 3 or 7? I am simply talking about energizing/de-energizing of coils through high or low pulses. – Thermal_insulator Mar 31 '23 at 12:43
  • 1
    You take 2, 3 or 7 steps in the 4-entry table (4, 6 or 14 in the 8 entry one), "wrapping around" when at one end. Have a procedure with steps or degrees or whatever as a parameter. You could add an external "stepper motor controller" using an CW/CCW and a *step* (clock) input, or even more elaborate ones with some commands given with some communications protocol. (Seem to have fallen out of favour compared to the 1980s - what with the pervasion of MCUs.) – greybeard Mar 31 '23 at 14:13
  • I still dont understand. Is `0: stepperPins <= 4'b1100;` in very first table a step? Or since I have energized two coils simultaneously is it two steps? How do I take 7 steps in a 4-entry table with 4 coils? If you could just kindly elaborate on that. What signals do I give through my code? – Thermal_insulator Apr 05 '23 at 12:05
  • 1
    Any given table entry/state of output=phase currents is a *state*: static, no movement. Going to an adjacent state/entry is a step: (small) movement. There is no use to energise same phase coils such that the fields oppose. I don't think I'm going to try and write yet another [Introduction to Driving Stepper Motors](https://www.ti.com/lit/an/slva767a/slva767a.pdf). – greybeard Apr 06 '23 at 07:41
  • Okay thank you, now my understanding has increased a lot. Each entry in the table is one step from previous entry. Studying it more. Will get back to you. Thank you again. – Thermal_insulator Apr 06 '23 at 10:40
  • Using PWM to control the angle. Have so far tried with generating one pwm signal to give to the coils in half-step. But it doesnt change anything besides not working below a certain value of cutoff (for pwm). My guess is that I need four different duty cycles to be applied to four pins as necessary. – Thermal_insulator Apr 07 '23 at 11:14