Fall 2016 Solar Panels: DC Motor with Encoder Experiment

By Jose Rodriguez (Electronics and Control)

Objective: The following experiments were used to determine if a DC motor can be used in place of a stepper motor by configuring it to be as precise as a stepper motor. Using DC motors will be beneficial to our design as we are trying to provide power.

In the first experiment, the Arduino Uno was connected to an encoder—the signals the encoder provided was then analyzed as the shaft turned.

Parts Used:

  • Motor shield V2.0
  • DC motor with encoder
  • Push button
  • Breadboard
  • 12V Power Supply

400d

Figure 1: Breadboard Configuration

The following code was used:

code1

By taking a look at the serial motor I notice I was receiving zeros and once. The four different patterns received were 00, 01, 10, and 11 (this pattern repeated). Figure 1 explains the output of the serial motor where each output is offset by 90 degrees. The reason we have two outputs from encoder is to determine the direction of the motor.  By analyzing the figure below, we can come up with a true table for direction.

pic1

Figure 1: Output of Serial Motor

If A goes from 0 to 1
B=1 Reverse
B=0 Forward

 

If A goes from 1 to 0
B=1 Forward
B=0 Reverse

In order to track a pulse each time it occurs, we need to have an interrupt in our code so that we do not miss it. Every time a pulse occurs means that the motor has moved certain degrees. To find the ratio between pulses and degrees, I will measure the number of pulses for 1 rotation using the following code. Without adding power to the motor all that is required is to manually rotate the shaft 360 degrees.

code2

code3

A value of 2071 is what I tested for a full rotation. I divided 2071 by 360 and got 5.75. About 6 pulses will rotate the motor 1 degree and this concept is what I will used to control the motor with precision. If I will I like to move 2 degrees to the left or 2 degrees to the right, then 12 pulses are needed. Once 12 pulses have been received then the motor needs to stop. The next experiment will focus on being able to stop the motor after a full circle.

code4

The following code was used to control the motor. A switch button is used to let the Arduino know when it should rotate. Pressing the button causes the motor to rotates and stops once 2040 pulse have been reach. Due to the fact that the motor is too fast, a perfect rotation cannot be done. A motor with slower rpm but strong torque could potentially respond better. In addition, a gear motor will be more acceptable because we can relate a 360 to 1 gear ratio as 1 degree for every rotation. In the solar panel design, a maximum gear ratio of 50 to 1 is what we can attain. A DC motor could not be used in our project. A stepper motor has been determined as the only option available due to time and gear ratio availability.