Speedometer Stepper Motors

Hello,
I have these stepper motors from an bmw e36 cluster:


but i havent really been able to controll them.
I found this tutorial for an golf 4 and opel tacho, but i think the use switec motors and they work differntly? At least this wasn’t working for me, the needle would just rattle.

If I wired one of the motors to the cluster I found out the voltage moves as follows:

So I wrote this code which just send a pwm signal in the order of the pins.

#define ONE 3
#define TWO 5
#define THREE 6
#define FOUR 9

void setup(){
  Serial.begin(9600);
  Serial.setTimeout(100);
  
  pinMode(ONE, OUTPUT);
  pinMode(TWO, OUTPUT);
  pinMode(THREE, OUTPUT);
  pinMode(FOUR, OUTPUT);
}

int curr = 0;
int mod = 5;
int real = 0;

void moveToTarget()
{
  int target = map(real, 0, 7000, 79, 790);
  int val = curr;
  int distance = abs(curr-target);
  if(distance>mod)
  {
    if(curr>target)
    {
      if(distance>mod)
      {
        val = curr-mod;
      }
      else
      {
        val = curr-distance;
      }
    }
    else{
      if(distance>mod)
      {
        val = curr+mod;
      }
      else
      {
        val = curr+distance;
      }
    }
  }
  if(val<0)val=0;
  int COIL1 = 0;
  int COIL2 = 0;
  int COIL3 = 0;
  int COIL4 = 0;
  
  if(val<255)
  {
    COIL1 = 255-val;
    COIL2 = val;
  }
  else if(val<510)
  {
    int temp = val-255;
    COIL2 = 255-temp;
    COIL3 = temp;
  }
  else if(val<765)
  {
    int temp = val-510;
    COIL3 = 255-temp;
    COIL4 = temp;
  }
  else
  {
    COIL4 = 255;
  }

  analogWrite(ONE, COIL1);
  analogWrite(TWO, COIL2);
  analogWrite(THREE, COIL3);
  analogWrite(FOUR, COIL4);

  Serial.println(COIL1);
  Serial.println(COIL2);
  Serial.println(COIL3);
  Serial.println(COIL4);
  Serial.println(val);
  Serial.println("----------");

  curr = val;
}

void loop(){

  if (Serial.available())
  {
    real = Serial.parseInt();
  }

  moveToTarget();
  
}

The code isn’t very pretty, but it kind of works. The problem is, the needle isn’t very accurate.
I also tried a motor driver (L298N) which made the movements more stable, but thats it.

Sorry for my lack of knowledge about stepper motors, I hope someone has already worked with those gauge motors, and can help me.

Stepper motors don't use PWM. And those probably aren't stepper motors. Regular stepper motors have 1.8 degree steps (200 steps per revolution) so you can see them "step", and you'd need more connections because you need at least one "home" sensor so you know where you're starting before you start stepping.

Those motors might be related to the very common type of gauge stepper motor described here: Automotive Gauge Stepper Motor [x27.168] : ID 2424 : $9.95 : Adafruit Industries, Unique & fun DIY electronics and kits

Some of the gauge steppers have an unusual bipolar drive scheme. Google "gauge stepper" for lots of info.

Thanks for the replies. Found out those are air core steppers. I also found a post with code to control them,
but I still don't know how to wire them up.

If it is a bipolar stepper, use your multimeter to find the four connections to the two coils. The coil resistance should be tens to maybe over 100 Ohms.

I found out the voltage moves as follows:

What does that mean?
What voltage, measured with respect to what?

First coil is 1&4 second one is 2&3 on the picture. The problem is there are 6 pins used in the code:

const int aircore1SinPin = 9; //this controls the voltage to the "sine" coil
const int aircore1CosPin = 10; //this controls the voltage to the "cosine" coil
const int aircore1SinDirPin1 = 2;  //these two control the polarity to the "sine" coil
const int aircore1SinDirPin2 = 4;
const int aircore1CosDirPin1 = 7;  //these two control the polarity to the "cosine" coil
const int aircore1CosDirPin2 = 8;

but I only have 4 connections on the air core stepper.
As I understand it pins 2&4 are wired up to one coil and 7&8 to the other one with a motor driver,
but where are 9&10 supposed to go?

Schematic including power supplies, stepper driver and everything else.

Julesss:
First coil is 1&4 second one is 2&3 on the picture. The problem is there are 6 pins used in the code:

const int aircore1SinPin = 9; //this controls the voltage to the "sine" coil

const int aircore1CosPin = 10; //this controls the voltage to the "cosine" coil
const int aircore1SinDirPin1 = 2;  //these two control the polarity to the "sine" coil
const int aircore1SinDirPin2 = 4;
const int aircore1CosDirPin1 = 7;  //these two control the polarity to the "cosine" coil
const int aircore1CosDirPin2 = 8;




but I only have 4 connections on the air core stepper.
As I understand it pins 2&4 are wired up to one coil and 7&8 to the other one with a motor driver,
but where are 9&10 supposed to go?

I think you will find that code uses a motor drive shield.
GOOGLE
x27 arduino
Tom... :slight_smile:

TomGeorge:
GOOGLE
x27 arduino

It’s a gauge motor too, but I think they differ from an air core motor in how they are controlled.
Are you sure they work the same?

What, How
Interesting info here
Air Core Stepper

The sine/cosine drive is exactly what a microstepping bipolar stepper driver does. The A4988 driver might work if the current limit can be adjusted appropriately.

Hi,
What are the resistances of the windings?
Have the units got numbers on them, to identify the part?

Thanks... Tom... :slight_smile:

jremington:
The sine/cosine drive is exactly what a microstepping bipolar stepper driver does.

It may resemble it, but lastchancename's reference points out this is not in any form, a stepper motor.

this is not in any form, a stepper motor.

I could not disagree more completely. The motor simply has many fewer poles (4) than you are used to seeing.

I am quite confident that if the current limit can be set appropriately, a microstepping driver will work just fine.

Unfortunately the OP lacks experience, however a simple test is to power the coils either alone, or in pairs and reverse the current to one of the coils. If the Wikipedia description is correct, the shaft will step by 90 degrees.

Well, OK, it is a stepper motor where one "step" is 360°. So your driver will give him exactly 16 positions of rotation. :roll_eyes:

Not sure whether that is quite what is expected. :astonished:

I wish I had a reason...
Interesting Driver datasheet
Click through to the datasheet

OK, it is a stepper motor where one "step" is 360°.

One "full step" is 90 degrees, if the drive circuit supports both positive and negative directions for the current flow in each coil, so it is a 4 full step/revolution stepping motor.

Used in 1/16 microstepping mode, the A4988 would divide the 90 degrees into microsteps of 5.6 degrees. Not great resolution, agreed.

This air core gauge driver chip uses a pair of bidirectional DC motor drivers, one for each coil, with internal sine/cosine current control. That would be the way to go, obviously.