In this lab we learned about different kinds of motors, DC and stepper motors, and how they work in comparison to each other. We used an H-bridge to control the direction of a DC motor and control a stepper motor.
Part 1: DC Motor
DC motors contain one coil and provide continuous motion. The function on the bases of induction where when you run a current through a wire it generates a magnetic field. In order to change the direction of the motor you need to change to direction of the current, but instead of rewiring the circuit every time, we used an H-bridge and code to control the motor’s direction.
The code that controlled this circuit involved setting each of the pins connecting to the H-bridge and checking the state of the button to determine which direction the motor should run. The following code involves analogWrite to control the speed of the motor because instead of high or low the amount of voltage given to the motor was in between the maximum and minimum, so the resulting speed was slower than the maximum speed.
Part 2: Stepper Motors
For the second part of the lab we set up a circuit for a unipolar stepper motor, that we controlled using an H-bridge. Like DC motors, Stepper Motors run off of the basis of induction; however, they also have the ability to have precise control through little pulses or steps.
The code required to control the stepper motor includes the Stepper library which allowed us to rotate the stepper motor, one revolution in one direction, then rotate the motor for one revolution in the opposite direction.