Closed-loop Linear Motion System(Linear Stage)

2,821

9

Introduction: Closed-loop Linear Motion System(Linear Stage)

In this project an Arduino Uno is used to build a closed-loop linear motion system using a DC motor. A photoresistor is used to measure the actual speed of the shaft, acting as a simple feedback system.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Components

The followings are the components used in this project:

- 9-12V DC motor

- Arduino Uno, usb cable and 9V DC adaptor

- Photoresistor

- L293D (H-Bridge) as DC motor driver

- 5mmx8mm Motor Shaft Helical Beam Coupler Coupling 18mm Dia 25mm Length

- Ball bearing (For Shaft Diameter: 8 mm)

- Painting spray (optional)

- Round wood sticks

- Wood and wood glue

- Limit switches x2

- Cable tie

Attention: I could not run the motor when I used a 9V battery to power up Arduino Uno.

Step 2: Building Linear Stage and Carriage

In this step a fixture is built to firmly hold the motor and shaft, and also a hanging object (carriage) is made out of wood. After that the DC motor is mounted and fixed using a cable tie. Then the whole setup is painted in black!

Step 3: Limit Switches and Wiring Up

In this step the two limit switches are installed at the two far ends, as shown in pictures. Also I added a "rail" so the carriage moves more smoothly and specified direction. Two pictures also show how to wire up the H-bridge driver.

Step 4: Speed Feedback System

Photoresistors, also known as light dependent resistors (LDRs) or photocells, are low-cost variable resistors where the resistance changes depending on the amount of light hitting its surface. In this project, a photoresistor is used to measure the actual RPM (revolution per minute) of the shaft. This is done by attaching a wood disk to the shaft and making a hole in it, while a photoresistor is fixed right behind the disk. If a light source is placed in front of disk, whenever the disk rotates 360 degree, light passes the hole and reaches the photoresistor once, causing a significant change in photoresistor reading. In this way we will be able to count the actual number of shaft rotations. This well-known approach is used in pictures.

Attention: To learn more about photoresistors, check this instructable out: "How to use a Photoresistor (or photocell) - Arduino Tutorial"

Step 5: Arduino Code

The Arduino code which is uploaded here is for a specific problem. You can use this code as a start and to understand some details, and then you could write your own code based on what you like to do with your linear motion system. The most important part of the code is where the speed is measured in real-time using the photoresistor (feedback system):

if (LDRReading < 100 && hole == 0 ) { // using few experiments, I noticed that 100 is a good number as the

//limit for when light passes the hole in wood disk VS. when it does not //counter = counter + 1;

hole = 1;

}

else {

if (LDRReading < 100 && hole == 1) {} else {hole = 0;} }

Serial.println("Attention! Near switch was triggered (CW rotation)!");

delay(100);

CurrentTime = millis();

break; }

}

183 16K
250 33K
123 12K