• Proof of concept: hall sensor feedback to motor

    vkonanur08/06/2019 at 21:33 0 comments

    What I learned:

    1. Too much current through the stepper motor driver heats it up... causing it to shut down frequently... causing it to jitter the motor.

    2. Running the motor with external 6V instead of the rated 12V, allows to not draw as much power, removing the stutter/jitter.

    3. Turning off the motor when it's not in use allows for more cooldown time.

    I wrote some code to allow for controlling the motor with a hall sensor. The motor is supposed to be at a "home" position, except when a magnet is near the hall sensor. As soon as a magnet triggers the hall sensor, the motor moves clockwise until the magnet is removed, which is when the motor returns to home position.

    #include <Stepper.h>
    int sensor = 0;
    int distance = 0;
    int execsteps = 20;
    
    // change this to the number of steps on your motor
    #define STEPS 200
    
    // create an instance of the stepper class, specifying the number of steps of the
    // motor and the pins it's attached to
    Stepper stepper(STEPS, 4, 5, 6, 7);
    
    void setup() {
      // put your setup code here, to run once:
      stepper.setSpeed(50); // set the speed of the motor to 30 RPMs
      motorOff();
    }
    
    void loop() {
      // put your main code here, to run repeatedly:
      sensor = analogRead(0) - analogRead(1); // Read differential output voltage from hall sensor
      sensor = map(sensor, 335, 370, 0, 100);
      while (sensor>50) {
        stepper.step(execsteps);
        motorOff();
        distance = distance + execsteps;
        sensor = analogRead(0) - analogRead(1); // Read differential output voltage from hall sensor
        sensor = map(sensor, 335, 370, 0, 100);
        }
      while (distance !=0) {
        stepper.step(-execsteps);
        motorOff();
        distance = distance - execsteps;
        }
    }
    
    void motorOff() {
      digitalWrite (4, LOW);
      digitalWrite (5, LOW);
      digitalWrite (6, LOW);
      digitalWrite (7, LOW);
    }

     Here's a video of it functioning:

  • Make sure that your current draw is under control.

    vkonanur08/02/2019 at 19:15 0 comments

    I tried my hand at using a beefier stepper, one that draws 2A. Using a driver rated for 1.2A to drive this motor was a bad idea.

    At first I thought that the driver was not working correctly. However, upon adding a makeshift heatsink, the stepper made one complete revolution... and then the driver resumed shutting off after that. I guess that's progress?

    I have ordered a different stepper that has less torque and that draws less current. Hopefully the torque is sufficient to move the commutator. That is an empirical question. If not, I might have to get a beefier driver.

    Central optic fiber movement detection: 

    I will be using a pair of hall sensors to detect the movement of a magnet attached to the mobile component of the central optic commutator. The last time I tried this, the readings contained a lot of noise, but large changes in magnetic field were detected reliably. I'm either going to have to get a more precise/sensitive hall sensor or I'm going to have to smooth the data coming into the arduino with some code.

    To be continued.

  • Hello World with the TB6612 stepper driver

    Lex Kravitz07/27/2019 at 21:30 0 comments

    To control the stepper for this project we are using the TB6612 driver with a breakout board from Adafruit.  This breakout requires more wires than some other stepper drivers but it is simple to use and has some features that make this a good choice for this project.

    Today I did the "Hello World" equivalent and set this chip up to turn a stepper, following the Adafruit tutorial.  I'm using a 5V stepper from Adafruit which is convenient because we can power it directly from the 5V pin of the Uno, instead of needing a separate 12V power supply.

    I wired it up like the tutorial (photos below) and flashed the following code onto an Arduino Uno clone that I had lying around.  The stepper turns both ways, hello world!  

    #include <Stepper.h>
    
    // change this to the number of steps on your motor
    #define STEPS 200
    
    // create an instance of the stepper class, specifying the number of steps of the
    // motor and the pins it's attached to
    Stepper stepper(STEPS, 4, 5, 6, 7);
    
    void setup() {
      stepper.setSpeed(30); // set the speed of the motor to 30 RPMs
    }
    
    void loop() {
      stepper.step(100);  // Move clockwise
      delay (1000); // Wait a second
      stepper.step(-100);  //Move counter-clockwise
      delay (1000); // Wait a second
    }

    Photos of the entire setup (I attached the red disk to the stepper to see it turn more easily)

    Close-up of the TB6612 connections: