Decoding PPM signal from RC receiver to drive a stepper motor

Hello guys,

I made a little setup to drive a stepper motor from an RC receiver, it kinda works but I have a few issues I want to get some response from more advance users. Any advice is welcome !

  1. weird power thing, If I power the arduino Nano FROM USB, everything works fine, the motor spins right when I turn the remote wheel right, and left when I turn it left, also the speed increases as I turn the wheel to it's maximum. If I power the whole system from an dedicated transformer (220v to 5v) the arduino part works the same, voltage is steady at 5.0v, the arduino grabs the receiver signal and convert it to pulses and direction , but the stepper driver doesn't work, it has power on both sides (5v from the same source I power arduino , and 9v for the motor). You can see in the video bellow when I change the power source, the leds flash faster and faster as I move the remote wheel but the stepper doesn't spin at all, only if I power the arduino from USB

  2. Stepper speed. I don't know why the stepper speed is so low, I tried a different program just to add LOW -> HIGH on step pin in the loop, nothing else, and still the speed seems low, is this the maximum speed an arduino can generate ? Should I use a dedicated hardware / chip to generate an higher number of pulses, any advices ? I still need to use arduino to convert the PPM signal, if there is a chip that can connect to arduino and receive somehow how fast it should generated pulses for the driver it will be perfect.

In the video bellow there is the onboard arduino led which just flashes when a step should be made, the other led, the blue one flashes when actualy a step is sent to the driver, the white led is on the DIR pin, you can see it turns off when I move the wheel in one direction and turns ON when move the other way. The leds flash very fast but the camera can't record that fast. But the stepper spins very very slow even at maximum speed.

https://www.youtube.com/watch?v=cxhz9aNSYr0

PS. I tried to embed the video with but doesn't work, if a moderator can embed it directly will be great.

Thank you.

sibianul: 2. Stepper speed. I don't know why the stepper speed is so low, I tried a different program just to add LOW -> HIGH on step pin in the loop, nothing else, and still the speed seems low, is this the maximum speed an arduino can generate ?

The Arduino can generate eight million pulses per second. I suspect there is a delay in your sketch that is slowing the pulse rate. Are you using pulseIn() to read the PPM signal? That will cost about 20 mS as it waits for the pulse to come around. Are you using a microstepping driver? That will require as many as 16 pulses to move one step. Without seeing your code it's hard to say.

Hello,

I’m back from a job abroad, I was off my office for a few days.

I will upload the simple sketch now, maybe serial output is slowing down? but I remember I commented for test the serial output lines and the speed didn’t changed (in void setup the serial remained enabled)

This is faster than the video, but is still not very fast, quite slow I’ll say and there is no delay in the sketch, I use the concept of blink without delay for pulses to the stepper driver and for serial output which was limited to once at 5 seconds.

test_stepper_speed.ino (1.53 KB)

You are changing stepState once per millisecond and it takes two state changes to make a pulse so you are limiting yourself to 500 steps per second. If you have a 200 step per revolution stepper (and NO microstepping) that is 2.5 revolutions per second. You could change your millisecond timer to a microsecond timer. You could pulse the step line on AND off for each iteration. You could skip setting the direction pin repeatedly.

const int ledPin =  13;      // the number of the LED pin

const int dirPin =  10;
int dirState = LOW;

const int stepPin =  11;
int stepState = LOW;

const int enablePin =  8;
int enableState = LOW;
int prevEnableState = LOW;


int ledState = LOW;
long previousMillis = 0;
long previousMillis5 = 0;

int pulses = 0;

long interval = 1000;
long interval5 = 5000;

void setup()
{

  digitalWrite(enablePin, enableState);
  digitalWrite(dirPin, dirState);

  Serial.begin(9600); // can this slow down the loop considertably ?
}

void loop() {
  interval = 0; // also tried with interval 1

  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis > interval) {
    // save the last time you blinked the LED
    previousMillis = currentMillis;

    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW)
    {
      ledState = HIGH;
      stepState = HIGH;
    }
    else
    {
      ledState = LOW;
      stepState = LOW;
    }
    // set the LED with the ledState of the variable:

    digitalWrite(stepPin, stepState);
    digitalWrite(dirPin, dirState);
    digitalWrite(ledPin, ledState);

    pulses++;
  }

  // LIMIT SERIAL PRINT TO ONCE AT 5 SECONDS
  if (currentMillis - previousMillis5 > interval5) {
    previousMillis5 = currentMillis;

    Serial.print("P ");
    Serial.print(pulses);
    Serial.print(" I ");
    Serial.print(interval);
    Serial.print(" Dir ");
    Serial.println(dirState);
  }
}