Go Down

Topic: IR remote controlled stepper motor with interrupt trouble (Read 2128 times) previous topic - next topic

Batee

Hi guy's, I'm pretty new in here so I hope I can get some help here.

So I'm controlling a stepper motor through 8bit shift register on Arduino UNO. I've a NEC IR remote control and a basic IR receiver. With it I'm controlling the speed of the motor using attachInterrupt function. I did not do any debouncing or similar circuitry. In the software side I'm using the mentioned interrupts and IRremote library.

Now to the problem, I cant achieve that the values received by the controller change instantly as i press the button on the RC. I have to be lucky to get the moment when the signal is received well e.g i want to transmit 0xFF52AD and its just -1 and 0 and if I'm lucky it transmits the proper number. I can also mention that with the motor spinning at lower speeds it is easier to transmit the value

I hope you can give me some advice guy's

I include the code also
Code: [Select]
#include <IRremote.h>

int pin = 13;
volatile int state = LOW;
int recv = 2;
short int latchPin = 8;
short int clockPin = 12;
short int dataPin = 11;
short int d = 50;
volatile int val;

IRrecv irrecv(recv);
decode_results results;

void setup()
{
  pinMode(pin, OUTPUT);
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
  Serial.begin(9600);
  irrecv.enableIRIn();
  irrecv.blink13(true);
  attachInterrupt(0, motorSpeed, RISING); //interrupt
}

void loop()
{
 
    switch (results.value){  //I have chosen 3 buttons for 3 speeds
    case 0xFF30CF:
      d = 50;
      break;
    case 0xFF38C7:
      d = 12;
      break;
    case 0xFF52AD:
      d = 3;
      break;
  }
  //just the motor driving part of the code
    digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, 0b1110011);
  digitalWrite(latchPin, HIGH);
  delay(d);
    digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, 0b11100110);
  digitalWrite(latchPin, HIGH);
  delay(d);
    digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, 0b11011100);
  digitalWrite(latchPin, HIGH);
  delay(d);
    digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, 0b10111001);
  digitalWrite(latchPin, HIGH);
  delay(d);
  Serial.println(val);
}

void motorSpeed()
{
  if (irrecv.decode(&results)) { //receiving the input
    val = results.value;
    irrecv.resume();
  }
}


Thank you

MarkT

Sounds like a hardware issue - is the stepper motor sharing power with the IR receiver?  That's
a recipe for huge amounts of interference - motors and sensitive electronics should be
separately powered wherever possible.

A circuit diagram / photo / description would be informative...
[ I won't respond to messages, use the forum please ]

Batee

MarkT, thank you very much for your advice, I managed to resolve my problem by connecting separately the motor to the arduino 5V source and the sensor to the 3,3V source and to be sure i used different grounds also. Now my remote is working without a flaw.

Thanks again very much ;)

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy