4-29-16 – So after I got the basic K-9 body assembled, the task to program it began. I did some basic stuff in the Vex Easy C programming language about a year ago and I forgot almost everything I knew. I did remember the basic looping structure of autonomous programs and how to activate motors. I had no idea how to program the ultrasonic sensor, but I told myself that if anyone could figure it out, I could (#giftedhack).
I had two programs in mind. One would be a program where K-9 could patrol the classroom, encounter an obstacle, twitch his ears for a second, back up, rotate and go in another direction. Another was what I call a “watchdog” program, where K-9 stays still and waits until something passes in front of the ultrasonic sensor, then he moves forward to scare off the “intruder”.
I wasn’t even sure how to plug in the ultrasonic sensor into the Vex Cortex. Another online search found that you could plug it into any two digital ports as long as the output is lower than the input. In the Easy C software, there is a sample test program for this sensor. I plugged in the sensors as directed in this sample program (to digital ports 1 and 11) and the sensor worked correctly.
My K-9 robot has three motors. The left, right and ears motors are plugged into motor ports 5, 2 and 6 respectively and are referred to in the sample programs below.
Now it was just a matter of writing out exactly what I wanted K-9 to do. I experimented with some of the wait times to make the movements as I envisioned them. (I also managed to snap off the 3-D printed tail in the process of the robot rolling around and running into things. A little electric tape mended it, and gave it some needed flexibility!) Here is the “Patrol” program as it is written today:
Now I can send K-9 around the classroom to patrol and interact with students, or I can park him in front of my office and he can keep those pesky students out.
I don’t think I am quite finished with the programming part yet. I can write commands to digital ports to make the eyes blink, and I am thinking about buying a Vex speaker so K-9 can talk. Another thought would be put both the Patrol and Watchdog programs on the Cortex and make the user throw a switch to select one or the other. There is probably a way to program the remote controller to select any “run mode” I can program.
Finally, I had an idea to print up a sign for the room saying “Beware of K-9 Unit”.
4-27-16 – Before I give all the details on this project, let me say it probably took me five months to complete. I do actually have a full time job teaching kids about STEM and tech stuff all day. I worked on this project in the spare moments before, between and after classes. A lot of the equipment used in this project is gear that is graciously provided by my employer and I am lucky to have access to it. This project is for the enjoyment of me and my students and K-9 will remain in the classroom.
I had some spare Vex robotics parts in the lab that were left by the previous teacher including two spare Cortex controllers, three remotes, some sensors and lots of batteries. I had originally made a simple robot that was sort of like a remote control car with two Vex motors and a universal direction wheel. At some point, the students had played with it so much that one of the motors was messed up, so I disassembled it.
Fast forward to this school year. I still had a spare Vex Cortex with a controller which I knew worked perfectly. I had recently watched a bunch of Doctor Who on Netflix including some old Tom Baker episodes with K-9 and got the idea to make my own K-9 robot.
I knew I could make a basic remote control K-9, but I really wanted a robot that would work independently and maybe even patrol the classroom on its own. I made a basic frame and attached the ultrasonic sensor to the front. I had no idea how to install it, or plug it in. I had experience with using ultrasonic sensors with Lego Mindstorms and Arduino based robots, so I figured it couldn’t be hard to learn how to do it with the Vex system.
I found some images of K-9 online. Some K-9 plans were out there, but I didn’t want to pay for them (#giftedhack). I printed some images of K-9 and came up with my own plans keeping similar angles and proportions to the real thing.
I cut the panels out of wood with a band saw and sanded them. I glued them together with Gorilla glue and some stints for extra support. Then I sanded out all of the rough edges. Finally I had the familiar trapezoidal body and head. It wasn’t perfect, but it was good enough (#giftedhack).
Gluing the body together
The robot drive frame with the body.
The body completed.
The head completed.
I wanted K-9’s ears to rotate also, so I took another Vex motor and some gears and make a mechanism that would rotate two Vex shafts up through the head. I drilled holes so the shafts would poke through the top of the head.
Mount for the head.
A familiar shape emerges.
Ear rotation mechanism.
At this point, K-9 was almost recognizable. I fashioned two brackets to attach the wood body to the robot frame. I also bought and cut a 4 inch black gutter flexible drainpipe to cover the metal neck and wires.
I then sat down with Autodesk Inventor and set to design some of the detail parts. The fake control panel was the easiest to design. The final product used all the space on the print base in my Makerbot Mini. I designed the tail in two parts and glued them together. I made a grill (printed in red) for the eyes and the ear satellite dishes. The ears were printed in three parts and assembled with super glue. The base of the ears has a hole that fits perfectly onto the Vex shafts that poke through the head.
Eye grill, printed in red and tail (painted)
Ear sensor dishes, unpainted.
I bought some Kilz for priming and some basic acrylic paint (battleship gray with metal sheen). I primed the heck out of the wood parts, then started painting. I think I put at least 3 coats of gray on everything. I then painted the darker spot between the legs by mixing a little black in with the gray. I also painted the control panel buttons.
Other details were added at this time like the fake view screen on the right side. I really would have liked to have had a working LCD screen but I didn’t have anything handy. Vex has a very expensive LCD screen, and I didn’t want to pay for it. So I faked a screen with another piece of wood cut with the lab laser cutter (#giftedhack). Then I sealed the whole thing with spray sealant, satin finish, probably around 3 coats.
I was going to just attach the red grill to the head for the eyes, but I really thought I would regret not installing some red LEDs for eye lights. Vex sells LEDs with custom plugs for the Cortex controller, but I did some research (#giftedhack) and found you could use regular LEDs by just running a wire directly into the 5V and ground ports on any digital port. I rigged some wires to some simple LEDs I had on hand, making sure to wire some 330 Ω resistors in the circuit. I drilled two holes in the front of the head and pushed the LEDs through until they were visible. Then I rigged wires out of the head and down the neck ready to be plugged in.
LEDs working with eye grill glued in front.
At this point, I was ready to add that iconic “K-9” logo to the side. I have a vinyl cutter in the classroom and I downloaded the logo image and traced it, then cut it into white vinyl to make a sticker logo. It’s a little big, but it looked good.
K-9 was now constructed, but he not very smart. It was basically a remote control car in a box. The programming part will come in the next blog entry.