Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - crylikebaby

Pages: 1
1
TinyDuino Processors & TinyShields / stepper motor + dual motor shield
« on: January 24, 2017, 01:47:10 PM »
Hello,

I'm trying to control a mini stepper motor with a dual motor shield, but I haven't yet make it work. I wired it to shield and uploaded the code, but nothing happened. I want to simply control the speed and phase of the motor spinning. You can see how the motor looks like on the attached image.

(FYI, talking about the specification of the motor, it is 4 wire 2 phase mini stepper motor requiring 1.5 - 3V. For more information, you can check out this link - https://www.amazon.com/dp/B01GWJD0F4/ref=sr_ph_1?ie=UTF8&qid=1485282732&sr=sr-1&keywords=micro+stepper+motor.)

So, here below are the problems that I'm struggling with.

1. I'm not sure if I wired the motor to the shield correctly. It has four wires (brown-orange-yellow-red), and I'm not sure which one is + or -. Also, same on the board. I can see two holes on M1 and M2 parts on the board respectively, but can't see one which one is negative/positive. I just hooked the brown and orange wires to M1 and yellow and red wires to M2, and it didn't work.

2. I have the sample code of the dual motor shield, provided on the tutorial page. However, I don't think this is for running a stepper motor.

#include <Wire.h>
#include "MotorDriver.h"

MotorDriver motor(0);//value passed is the address- remove resistor R1 for 1, R2 for 2, R1 and R2 for 3

int maxPWM=10000;
int steps=100;
int stepSize=maxPWM/steps;

void setup(){
  Serial.begin(9600);
  Wire.begin();
  //The value passed to begin() is the maximum PWM value, which is 16 bit(up to 65535)
  //This value also determines the output frequency- by default, 8MHz divided by the maxPWM value
  if(motor.begin(maxPWM)){
    Serial.println("Motor driver not detected!");
    while(1);
  }
  //The failsafe turns off motors if a command is not sent in a certain amount of time.
  //Failsafe is set in milliseconds- comment or set to 0 to disable
  motor.setFailsafe(1000);
}

void loop(){
  int i;
  for(i=-maxPWM;i<maxPWM;i+=stepSize){
    delay(10);
    motor.setMotor(1,i);
    motor.setMotor(2,i);
  }
  for(i=maxPWM;i>-maxPWM;i-=stepSize){
    delay(10);
    motor.setMotor(1,i);
    motor.setMotor(2,i);
  }
}

-

Could anyone please help me to run the motor with this shield? Any advice on wiring and coding would be helpful!
I also strongly hope TinyCircuit provide more information and examples of controlling various type of motors with this shield ...


Pages: 1
SMF spam blocked by CleanTalk