Section 1

Steps

1. Assemble system from instructions below.

2. Download the blink code (link) and verify you can upload code to your Arduino.

3. Download the starter code (link).

4. Blink LEDs based on rotation direction and once per revolution (example video below).

In this task you will program your arduino to detect value changes on the A and B quadrature signals, and voltage changes on the potentiometer analog input. You will need to:

a. Determine a way to detect rotation direction from the A and B signals, and to flash the blue and red LEDs depending on rotation direction (you may choose which LED corresponds to which direction). The LEDs should only flash when the encoder is moving and otherwise should be off.

b. Similarly, using the potentiometer analog input detect when the potentiometer goes through a full rotation (i.e. the voltage drops from 5V to 0V), blink the green LED every time your system completes a full rotation.

We will not be powering the motor, just turning by hand. Some helpful links on quadrature encoders are here, here, and here.

5. Provide a printed plot of the encoder and potentiometer readings (example).

You can use the serial monitor on the Arduino software to record the serial output from your program. Copy and paste this into a file and load into Matlab to make plots.

6. Add another LED and blink once every N number of encoder counts.

Add a fourth LED to the breadboard. Program your Arduino to now count the cumulative encoder counts taking into account positive (CW) and negative (CCW) directions, i.e. 5 counts CW + 10 counts CCW = 5 counts CCW. Blink the LED every time the motor rotates a specified number of encoder counts (you choose).

Assembly instructions

Parts needed:

1. Arduino and USB cable.

2. Breakout board (if using).

3. 2x angle brackets for extruded aluminum.

4. 1x 20 mm extruded aluminum.

5. 2x 10-32 nuts and bolts.

6. 1x potentiometer mount.

7. 1x motor mount.

8. 1x motor.

9. 1x Flexible motor coupler.

10. 1x potentiometer.

11. 4x jumper wires.

13. 2x M4-8 cap screws.

14. 2x flat nuts for extruded aluminum.

15. LEDs

17. Resistors

1. Connect your Arduino and verify you can upload code.

1.1 Download the Arduino software here.

1.2 Connect your USB cable to your Arduino and computer.

1.3. To verify your Arduino works you can download and run the blink program (link). The LED on the breakout board should blink.

2. Mount and wire the potentiometer

Mounting instructions

2.1. Mount the angle bracket to the extruded aluminum using the M4 cap screws and flat nuts.

2.2. Mount the plastic potentiometer stand to the angle bracket using the 10-32 nuts and bolts.

2.3. Unscrew the nut on the potentiometer and mount the pot to the plastic stand.


Electrical hookup instructions

The red and blue wires of the potentiometer record the full resistance of the pot. The blue wire is the pot’s wiper which will vary in resistance as the pot turns.

2.4. Connect the red pot wire to the 5V pin on the Arduino.

2.5. Connect the black pot wire to the GND pin on the Arduino.

3.6. Connect the blue pot wire to pin 0 of the analog inputs.


3. Mount and wire the motor encoder

Mounting instructions

Using similar steps as the potentiometer, mount the motor to the plastic motor mount. The only difference in this step is we will use the M3-8 cap screws and washer to mount the motor. Use the motor coupler to connect the potentiometer to the motor sprocket.

Electrical hookup instructions

The motor wires are as follows:

For this section we will just hook up the encoder wires (green, blue, yellow, white).

3.1. Connect The green wire to the arduino GND pin using a jumper.

3.2. Connect the blue wire to +5V on the arduino.

3.3. Connect the yellow wire to digital input pin 3.

3.4. Connect the white wire to digital input pin 2.

4. Wire up LEDs

4.1 Using your breadboard connect a blue LED in series with a 220 ohm resistor between the ground and digital pin 8.

4.2 Using your breadboard connect a red LED in series with a 220 ohm resistor between the ground and digital pin 9.

4.3 Using your breadboard connect a green LED in series with a 220 ohm resistor between the ground and digital pin 10.