Lab 8- Drawing Machines

Lab 8- Drawing Machines

Date: 11/10/2017

Instructor: Marcela

Member: Huanci Wang (Mary), Xinyi Chen (Silvia)

Goals: Create drawing machines by using an H-bridge to control stepper motors attached to mechanical arms. Individually assemble the circuit using the SN75440NE IC and the pre-installed Arduino Stepper Library to control one stepper motor.

Materials: Arduino kit along with:

  • 1 42STH33-0404AC stepper motor
  • 1 SN75440NE ic chip
  • 1 power jack
  • 12 V power supply
  • 1 potentiometer from your kit
  • 1 Arduino and USB cable from your kit
  • Laser-cut mechanisms
  • Pen that fits the laser-cut mechanisms

Part 1: Build the following circuit to control the stepper.

 

circuit

I built the circuit pretty fast and the motor worked at first. (video) I thought there should be nothing wrong, but later when I started step 2, the motor started to vibrate instead of rotate.

It took me a long time to realize that I connected the H-bridge up-side-down, which was a dangerous mistake that can burn the H-bridge. I turned to another H-bridge instead.

Part 2: Use the potentiometer and the MotorKnob example to control my motor.  To do this, I need to carefully make sure that the potentiometer is well-connected, because its size doesn’t fit with the breadboard very well. I didn’t connect the potentiometer well the first time, and Marcela fixed it by pushing  the potertiometer really hard!

Part 3&4: Write a sketch on Processing that sends values to Arduino. Replace the potentiometer by using the values from Processing to control the motor. Then, combine my partner’s and my parts into a mechanical arm that can hold a marker. Use processing to control the movement of my motor, and make adjustments with my partner to make a drawing machine.

Due to the limited time in class (and my mistakes which wasted some time), I decided to finish the rest of the steps after class. I worked with Silvia, and together we made a drawing machine.

  • At first, we decided that the motor will rotate as long as the X position of mouse is bigger than half of the screen. Later, I changed the code and made it rotate clockwise when the X position of mouse is bigger and counter-clockwise when the position is smaller.

  • It was also hard to find a suitable pen with the right size. We borrowed one form the equipment room and used a lot of books to adjust the height of the motors and the paper. We also used a lot of paper because sometimes the motor simply drew outside the paper. That’s because the starting point was too close to the edge of the paper.

  • For the first few trials, we forgot to fix one of the nails of the arms, and sometimes this makes the arms draw lines only.

  • A interesting thing was that we didn’t use the board to fix the motors, which made the lines tremble on the paper, however, we thought it beautiful, and kept it that way.

Conclusion: The circuit and the coding is complicated this time because the stepper motor and H-bridge are new for us, and the code combines old and new knowledge. I’m still very slow at combining the code, which should be improved during making my final project. Also, it is extremely important to remember the correct way to use the devices such as H-bridge!

#include <Stepper.h>

// change this to the number of steps on your motor
#define STEPS 100

// 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, 8, 9, 10, 11);

// the previous reading from the analog input
int previous = 0;
int valueFromProcessing;


void setup() {
  Serial.begin(9600);
  // set the speed of the motor to 30 RPMs
  stepper.setSpeed(30);
}

void loop() {
  while(Serial.available()){
    valueFromProcessing = Serial.read();
    
  }
  if(valueFromProcessing == 'H' ){
    stepper.step(valueFromProcessing - previous);
  }
  if(valueFromProcessing == 'L'){
   stepper.step(previous - valueFromProcessing);
  delay(10);
}
}

Leave a Reply