Introduction: Arduino Controlled Solenoid Motor

This instructable was created in fulfillment of the project requirement of the Makecourse at the University of South Florida (www.makecourse.com). In this instructable, you will learn how to make a solenoid powered motor, more specifically a flat twin 3 rod solenoid powered motor. To make the project, you will have to have access to a lathe, mill, welder, and 3D printer due to all the custom parts.

Step 1: Gather Tools/Parts

To make this project you will need access to a machine shop.

The tools that you will need are.

1. Mill

2. Lathe

3. Welder

4. 3D Printer

5. Laser Cutter

6. Dremel

7. M4X.7 Tap

8. #30 Drill Bit

9. Power Drill

10. Calipers

The Parts you will need.

1. Wooden Base

2. 3mm Ground Rod

3. Four Small Hairpin Cotter Pins

4. Two 2inX2inX2in Steel Square Tubing

5. Three 7X11X9 Needle Bearings

6. Two 35X15X11 Ball Bearings

7. M4X.7 Bolts

8. Four M6X1 Bolts

9. Black Box

10. Three Medium Black Rubber Grommets

11. Velcro strips

12. Arduino UNO

13. USB Cable

14. Medium Breadboard

15. Assortment of Jumper Wires

16. LCD Display

17. 10K Potentiometer

18. On/Off Switch

19. 9V Battery

20. Two 12V 10 mm Stroke Solenoids.

21. Two TIP 120 Transistors

22.Two Diodes

23. 24V 3A Power Supply

24. 24V Hall Effect Sensor

25. Three 220 Ohm Resistors

26. DC In Plug

Step 2: Make Components

Now you need to make a lot of the other components

These components will be made on the Lathe

1. Two outer crank halves. (Requires eccentric lathing)

2. Two inner crank halves.

3. One rod posts.

4. Five rod spacers.

5. Three rod bearing holders.

6. Flywheel.

7. Slots in the ground rod for the cotter pins.

These components will be modified on the mill

1. Drill eccentric holes on all crank halves 4.9 mm from the center of the piece with the #30 drilll bit.

2. Face mill Slots in the flywheel for the magnets to attach.

3. Drill hole for set screw in flywheel.

4. Make bracket to hold hall effect sensor near the flywheel.

4. Use digital read out to drill precise holes in the wooden base to mount components. (Get these points from your CAD model)

5. Use digital read out to drill precise holes in the solenoid mounts to mount solenoids. (Get these points from your CAD model)

These components will be made on the laser cutter

1. All three rods. (Two are out of .125 Alum, one is out of .063 Stainless to balance to reciprocating/rotating mass.)

These components will be joined with the welder

1. Weld the rods to their corresponding rod bearing holders. (Alum to Alum and Stainless to Stainless.)

These components will be made on 3D printer

1. The main bearing holder. (Make the holes smaller then your tap chart calls for and drill them out afterwards. Also use at least 5 shell layers since we are tapping these holes.) The main bearing holders are designed to be a solid and rigid mount for the crank assembly that constrains all motion but rotation.

These components will be modified with the M4X.7 tap

1. Both outer crank halves. (Tap these holes at least 20 mm deep.)

2. Center rod post. (Tap this piece half way from each side of the piece.)

Step 3: The Black Box

Now you need to modify the black box a little.

1. First, you will need to drill two holes in the back side. One hole is for both solenoid wires, the other hole is for the hall effect sensor wire. make sure you insert the rubber grommets so the wires do not get cut.

2. Next drill another hole the correct size for the DC in port, and mount that on the back side of the box.

3. Then drill another hole on the right side and mount in your on/off switch to control the arduino.

4. Now drill a hole in the front side to fit your potentiometer. This can be used later on the vary your RPM.

5. Then using a dremel, cut a rectangular hole in the front for the LCD display. Be as neat as possible doing this so that your project looks professional. now mount you LCD display.

Step 4: Assemble Components

Now you can start Assembling all the parts

1. First, press in the needle bearings into the rod bearing holders with an arbor press or something similar.(A little heat on the rod may help.)

2. Next Assemble all the crankshaft pieces together how they are in the model. Be very careful to get all the pieces indexed correctly or your crank will not be balanced. Use lock tight on all the bolts and get as tight as possible.

3. Next mount the main bearing holders onto the wooden base. No need to use a physical tap on the 3D printed parts, if your hole is the right size, then the bolt should be able to form is on threads the first time it goes in.

4. Next slide your main bearings onto the two outer crank halves and set them inside the main bearing holders. Then insert 3D printed caps and bolts to secure the crank.

5. Now mount your solenoid holders onto the wooden base in their corresponding holes.

6. Then insert your solenoids into their holders and join the Con rod to the solenoid end with the 3 mm ground rod. Make sure your put the cotter pins in or they may come apart.

7. Mount the black box on the board with four pieces of Velcro. This makes for easy removal in-case you need to service any components.

8. Using more velcro, mount your Arduino Uno, the breadboard, and your 9V battery inside the box.

Step 5: Wiring

Now it is time to wire all the electronic components. I have attached a wiring diagram to follow.

Here is a brief description of how the circuity works..
The hall effect sensor is an input to the Arduino that tells it the crank position. Then when the timing is right, the arduino sends out a signal on pins 9 and 10 that go to the two transistors. These transistors act as relays and send 24V to the two solenoids. There are also diodes on the solenoids so that there is no back voltage that may hurt some of the components. The LCD display is an output that shows the RPM of the crankshaft. It gets wires to 5V/ground and also to the two I2C bus pins. The potentiometer is an analog input that goes to pin 1 and varies voltage going into the arduino. I have put a switch on the 9V supply for the arduino so that i can turn the system on/off without opening the box. I also put a fuse block on the 24V input for safety reasons so that i don't burn any wires.

You will need to wire

1. Power to the Arduino through the switch.

2. 5V and ground from arduino to the breadboard.

3. 24V and ground from the power supply to the breadboard though a fuse.

4. Potentiometer to analog pin 1.

5. Hall effect sensor to 24V and digital pin 3.

6. LCD display to the IC2 bus pins and 5v/ground.

7. The two solinoids through the transistors and diodes to digital pins 9 and 10. (These get 24V and take 1.5 Amps each.)

Step 6: Programing

Now time for programming, you will need to be familiar with arduino code to do this part (or just copy and paste my code.)

1. First you will need to include a few libraries..

a. "Wire" used to start the I2C bus for the LCD

b. "LiquidCrystal_I2C" used for the I2C/LCD

c. "Math" needed to do the RPM calculations later on

2. Now define your input/output pins

a. Set "solinoid1pin" to digital pin 9

b. Set"potpin" as analog pin 1

c. Se "ignitioninputpin" as pin 2 (This goes to the hall effect sensor.)

d. Setting your "interruptnumber" as interrupt number 0 (On digital pin number 2)

3. Now define all the following variables. (Volatile is used because these variable are used in the ISR)

a. "previousstate"

b. "buttonstate"

c. "counter1"

d. "start"

e. "finish"

f. "elapsed"

g. "RPM"

4. Now onto the general setup section which only runs once when you start up to arduino

a. Set all your pins as inputs/outputs

b. Set the initial state of your pins/variables

c. attach the interrupt service routine with its settings

d. Initialize and turn on back light of LCD

e. output a statement to the LCD

f. Begin serial communication

5. Now here comes the main loop. It will run forever until the arduino is shut down

a. Output buttonstate previousstate and counter1 to the serial port for diagnosing problems later.

b. Do calculations for the RPM

c. Set up If/Then statements to activate the solenoid only when the first magnet is detected, and keep it on until the second magnet is detected to turn it off.

d. Set up If/Then statement to count the time between hall effect sensor detections

e. Make another If/Then statement that outputs the RPM to the display every time the counter is a multiple of 6. This is done to reduce the lag in the motors when the RPM is being sent to the LCD

f. Insert your Interrupt service routine. This resets the buttonstate, prevousstate, and adds one to the counter every time.

Step 7: Starting Your Motor!

Now that you have all the components to the project put together, just give the flywheel a little push and it should spin away!