LEGO Spike Prime – Design an automatic door

In today’s post, I would like to introduce a model made of LEGO Spike Prime. If you are using LEGO MindStorms, you could design this model, too. Since this two sets share many similar blocks.

This is an open-ended project for the students. As instructor, we just put forward the requirement and then left it for students to think about how to implement it. Therefore, the solutions could be versatile. This post just introduces one of the solutions which is concise and works pretty well.

The working model is shown in the following video. At the beginning, the two doors are closed. Whenever the ultrasonic sensor identfies an object, the doors swing 90 degrees and play a beep sound at the same time as an alert. When the object is removed, the doors are closed after one second. It just simulates the automatic doors in our real life.

Mechanical Structure

The core of this project is the design of mechanical structure. Let’s take a look at the model’s overall structure. It uses one medium motor to drive two axles. When the axles spin in opposite directions at the same rotation rate, the two doors turns simutaneously.

The gear chain is put at the top of the door to transmit the spinning power. The motor is put on top of it and the ultrasonic sensor is hanging ahead of the doors, so that when an object approaches, it could identify and inform the program to make certain actions.

The axles pass through the two frames (pink color) and turns the frame with it.

For the medium motor, it is connected to one of the gears, as shown below. When motor turns, the spinning transmits through the gear train, driving the left and right most gray gears turn at the opposite directions.

Gear Train

Now let’s remove the motor and ultrasonic sensor to take a look at the gear train. You might feel that the gear train’s layout is a bit weird. Yes, it is not aligned on a line. It is because the gear trains are fixed onto a blue beam. However, the holes of the beam could not fit all the sizes of the gears. If you design open-ended projects with LEGO Spike or LEGO MindStorms, this condition often happens.

In order to keep the two axles spin at the same speed, the left and right most gears should be of same size or more accurately, same teeth. In order to keep the two axles spin in opposite directions, the total gear number should be an even number. However, since the beam hole position could not match all the gear sizes, one of the gears has to keep a bit offset from linear position in order to mesh properly with the adjacent gears. This model implements this by using two short beams (blue and yellow colors, respectively) to lock the third gear into its position to ensure meshing with other gears.

Once gear train has been working, motor and ultrasonic sensor are easy to be mounted. The other parts of the model, including the big 11×15 frames, 3×3 biscuit blocks, and black flat panels, etc. are used to support the whole structure and keep it stable and upright.

For the axles which pass through the 7×11 frame’s holes, they are inserted into the base sheets. Since the base sheets contain round holes, the axles could spin freely within the holes and keep the door at the proper position.

Other Solutions

As I mentioned, this is an open-ended project. Therefore, more solutions are always welcome. The following is another solution, which is not perfect but workable. It uses two separate motors to control the movement of doors. Meanwhile, the ultrasonic sensor is put at the back of the door.

Program

Finally, let’s take a look at the program. Generally, the program is easy to understand and there is not complicated logic. When program starts, it enters a forever loop. Within it, the program checks if the ultrasonic sensor identifes any object closer than 7 cm. If it does, the program plays a beep sound and broadcasts “open door” message. After that, the program waits for the object move away from the ultrasonic sensor. In this way, if the program identifies the existance of an object all the time, the door will keep opened. It is consistent with the setting of automatic door in the real life.

When the ultrasonic sensor could not identify an object any more, the program waits for an extra one second and broadcasts “close door” message.

Let’s take a look at several other code segments. When program starts, the program sets motor (at Port A) relative position to 0. Please note that we need to keep the door closed at the beginning so that the motor could record its current positition as 0. When receiving “open door” message, the motor goes to relative position of -90, so both doors will swing 90 degrees. When receiving “close door” message, the motor turns back to the initial position of 0. We did not use “turn closewise 90” or other similar code, since specifying relative position could accurately control the targeted position of the motor.

That is all for the introduction of the open-ended project. Do you find any object in your life that you could simulate with LEGO Spike Prime? Try to implement it and that is an effective way to improve your design skills. Keep tuned and we will have more posts about this types of project.

Note: All the analysis articles are copyright products of http://www.thecodingfun.com. Anyone re-posting them should credit author and original source. Anyone using them for commercial purposes or translating them into other languages should notify TheCodingFun and get confirmation first. All Rights Reserved.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.