Tuesday, April 22, 2014

K9's Outer Shell - Building with Wood

Just ask my old shop teacher, I was never really gifted in the wood working department. Wood is the only material I am really at all familiar with, however, so that is what I will use to construct cosmetic parts for this robot. As I move forward with this project I am learning about other materials such as Vinyl, Aluminum and Acrylic but I basically have to stick with materials I can work with at home - so wood it is.

I mentioned in a previous blog entry that by first attempt a building the dorsal control panel was too small and I would have to build a new one. That gave me an opportunity to document the very an example of rudimentary techniques I used to construct the outer shell as I build this much smaller piece.

The first step usually is a cardboard model. In this case I was pretty sure what I wanted so I skipped this. Next step is drawing out the pieces onto a piece of wood. In this case, I am using very thin wood at only 1/8 of an inch. Here are the parts drawn into the wood.

You can see off to the right, the paper templates I printed out to transfer the lines onto the wood. Since this wood is only 1/8" thick, I then start to score the lines with an X-acto knife and then move to a box cutter. It helps to coat both side of the surface with clear packing tape before you do this to prevent the wood from splintering. Soon the wood will be cut through and you can remove the packing tape. If I were using 1/4 wood or particle board as I used in the frame I have show in past blogs, I would have to use a scroll saw or a bayonet saw to do the same thing. I then bored out the button holes by again covering the wood in clear packing tape and then using a 3/4" spade drill bit.

Next, thanks to the miracle that is Heavy Duty Liquid Nails I assembled and clamped the parts together. This piece has a curved section that will have to be clamped in place while the liquid nails drys.

Don't put on liquid nails to heavily as this severely increases the time required for it to dry. A light coat between the pieces will hold this thing together if you give it at least 24 hours to dry and set. I originally did not know how I was going to do the wood assembly this project would require but this stuff really holds things together.

After 24 hours has passed, I removed the clamps and Dremeled down the rough edges. Then I filled all the holes and remaining imperfections with Plastic Wood and sanded everything down smooth. Now it looks something like this.

Next, I had to cover up the wood grain. This is done by priming the wood and the standing down the primer coat until it fills the the wood grain.

Here is the near finished product. You can still see some wood grain but I am leaving it at this stage and moving on. I will do a final sanding and priming right before I do the final paint job once the entire body is finished.

I am going to postpone the final coat because until everything is finished, I am not sure what additional modifications I may need to do to the body before it is complete and I don't want to worry about marring the finish while work continues.

Here is the near finished product, sitting in the main body shell (Which, unfortunately, has some plastic wood filler on it at the moment) on the left compared to an actual shot of the detailed (hero) prop on the right. This time I have the correct scale.

Next, hooking the lights and switches back into the Arduino.

Friday, April 18, 2014

K9 Detects an Obstacle and Talks About It

This is very pre-mature but I have been working on generating events for the Raspberry PI which come from the Arduino as I have mentioned previously. Tonight was the first time I used one of these events. I have hooked up a temporary speaker and amplifier to the PI to allow it to play sounds. When the platform detects an obstacle using the Ping))) ultrasonic range finder, it stops the forward motor and sends an event to the PI. It responds by playing a sound. I thought the video was worth sharing.

The source for this interaction is available on my GitHub project but it has a long way to go.

Sunday, April 13, 2014

K9 Drive Base Demonstration

Things are progressing pretty well on the drive base. I have it configured to accept commands from both the on board Raspberry PI and an RC remote control. The remote control takes priority over any PI issued commands. This is useful if it should decide to do anything unexpected. When I first started testing it, I would put it up on blocks in case it decided to run away. Now I can flit the B switch on the remote control to stop it dead if this happens. Below is a picture of the current drive base with call outs that show what each component is.

It still looks like a bit of a rat's nest of wires but it is now capable of moving on its own and I can ssh over to the PI and give it commands like move forward or rotate around. Below is a video of my first tests. Excuse my weak voice, I have a bit of a cold.

As you can see it moves pretty fast. I have gone out of my way to restrict how fast it can go because when it is not carrying it external shell, it is far lighter than it will be when it is done. I already had one accident when my son was testing it out and he drove it hard into his own ankle and managed to hurt himself.

If you listen carefully you can also hear a high pitch noise whenever it moves. This is probably because the pulse width modulation frequency is too low and the motor itself is resonating in response to it. I will have to investigate changing that frequency to one outside the range of human hearing. Maybe, when I am done it will just annoy dogs.

Below is a head on shot. Here you can see the Parallax Ping))) sensor mounted on the front.

The speaker and microphone pair kind of look like eyes. If you look to the left you can see the RC receiver antenna which is being held on with a cable tie that looks a little like a sweat band. The ping sensor uses sound based radar to report obstacles up to 10 feet in front of it. These measurements are then passed on to the PI for further decision making.

At one point, I put the shell on and then got worried when the base refused to move forward. It would only go backward. Then I realized that when I had covered the Ping sensor, it was reporting that the shell was an obstruction in front of it and refused to move forward until the shell was removed.

Below is a shot of the two Razor scooters mounted to the bottom of the drive base. 

These scooter motors and rear wheels have been sawed off from the rest of the scooter. All that remains is the back 8 inches of the scooter. The rest was discarded. The frames are held to the mounting board with a U-bolt around the inner sides of the axels and three machine bolts that fit into the pre-drilled holes on the top of the frame and are very securely attached. There are also two wheels that spin freely and prevent the platform from tipping over.

You can also see that they are mounted in opposite directions. This is because the steel frames rapidly become wider than the base itself. If mounted in the same direction, they would be two wide to fit inside the shell. Having them face in opposite directions is not a problem because the DC motors can be rotated in either direction. If you look at the wiring diagram present in one of my previous posts, you will see that the left and right motors have their terminals reversed so as far as the controllers are concerned, they both move forward and backwards in unison.

Friday, April 11, 2014

Its Here! The new Printed Circuit Board Arrived.

You you may remember a few posts back, that the board I built to control the lights on the dorsal control panel on my K9 robot burned out because of a short. Well, the printed circuit board I designed to replace it has arrived. It took two weeks but for the price ($9.00 US) it was worth the wait for 5 copies of my design.

Thank you SeeedStudio. Yes, they have three eees in their name. Hopefully this weekend I can install the components and get it working.

Update: Here is a shot of it with all components installed.

This is the way to do it, all the holes were pre-tinned and all the traces are lacquered over. No more shorts.

Tuesday, April 8, 2014

Making K9 into a Pointer Dog - The HMC5883L Magnetometer

Real dogs have a breed called pointers which are also known as Gun Dogs bred to assist hunters in finding prey by pointing it out. I needed a similar capability to identify which direction the dive base is facing to stay on course while moving or for room mapping which is something I am interested in doing in the future.

I had never worked with a Magnetometer (Specifically the HMC5883L) and really did not know what to expect. They are fairly inexpensive to purchase. My first question was how to mount it. This may seem obvious but do you mount it flush or on its side? It turns out that the x-y plane provides the equivalent of a compass reading. If you look closely at your printed circuit board, there should be silk screened image of its three axis.
Your board may vary in size, color or number of pins but there should be an axis diagram. This one indicates that if you mount it flush with a horizontal surface and point the x-axis to the front, the angle between the vector formed by [x,y] and the centerline of your robot is the angle of your heading. I discovered this by reading the x and y values from the board as I rotated my robot base clockwise by hand. I graphed these points and repeated the process twice (the red and blue paths). 

The pink arrow represents the X axis and the direction of magnetic north which I found using a compass normal. As you can see, the points form an ellipse. I am no expert on this but I assume that the [x,y,z] vector represents the direction and the magnitude of the magnetic field at the point on Earth you are at. By looking at only the projection onto the x,y plane and then finding the center of the ellipsoid, you could calculate the angle between the x axis and the current [x,y] vector that points to magnetic north. Keep in mind all I know is what I have learned by experimenting with this board. If someone has any additional insight as to how this works, please pass it on. I am also ignoring any effects of tilting or z-axis data at this point. All I really wanted was my current angle from magnetic north but I was not getting this from the sample libraries a tried. I used the code at Adafruit to generate the x,y coordinates to create the graph above. You can see how its wired into my Arduino by looking at the diagram in my previous blog entry.

To calculate then center of this ellipse, I just placed a rectangle around it and then found the center of it as can be seen in the figure below. I calculated the center of the ellipse to be at (45,-360)
I don't know if this point will work for you or if this center will shift when I take the robot to new locations but for now I am using this as my center and I am getting fairly accurate readings on my heading relative to magnetic north.

Here, I calculate the angle between the current vector and the x axis which is the midline of my drive platform and then add or subtract from that angle to place it in the correct quadrant so so that I get the equivalent of a magnetic compass reading in degrees. My approach may be flawed as I mentioned above but I will update this post as I learn more about this device. The entire sketch that the gist above is taken from can be seen here. This sketch reads all the other devices listed in my previous blog entry and emits events over the USB bus to the Raspberry PI in JSON format indicating what the current heading is. I will talk about these events and the PI can send back to the Arduino in my next entry.

Monday, April 7, 2014

Making K9 Move - The motor base

I have been experimenting with building a base to sit my K9 outer shell on top of and things are really proceeding very well. For about $500.00 in parts I have created a platform that fits inside the shell that can be controlled either by a Raspberry PI or an RC remote control. Here is a picture of the platform with the parts I am planning on installing laid out on it but not yet connected. Here you can see the board that the scooters are attached two with plus shaped cut outs in the center to allow the wheels to pass through.

The platform consists of the following items.

1 1/4" Pine board with holes cut out for the wheels
2 Razor 24 Volt batteries (They come with the scooters, not shown above)
1 Terminal block
1 Raspberry PI
2  U-Bolts (1/4x1-1/8x3-1/2) used to attach the axel to the board
6 3/16x1 Washers
6 10-24 x3/4 Pan Phillips Machine screws which are the perfect size to screw through the wood into the steel frame.

Here is how the components are connected together.

If you look closely, you can spot that I have attached the scooters to the platform facing in opposite directions. This was to allow the steel frames to fit together closely enough to stay within the limits of the with of the board they were being mounted to. In the diagram above I have reversed the electrical connections to the motor to make both motors consistently move in the same direction. This could also be accomplished in code as well but this makes them both appear to be facing in the same direction as far as the controllers are concerned.

When working with high current systems it is a good idea to use heavier gage wire. I am using 18 gage stranded wire for all the motor connections which I am wiring into a terminal block for distribution. I have also wired the step down regulator into the terminal block to provide 3 amps of 5 volt service which should be enough to power two Ardunios and the PI.

Each scooter's specs state they can propel a child up to 10 mph for 40 minutes between charges. This platform packs two of them and will weigh far less so I am expecting really good performance. In addition the steel frames use a bicycle chain to transfer power from the motors to the polyurethane wheels. 

I put some thought into how I wanted the wheels arranged. I know I wanted four wheels, two powered and two idle to form a stable base that would not be easily tip-able. I also wanted the shortest possible turn radius as my goal was to develop autonomous navigation projects and having a near zero turn radius would allow the robot to maneuver in close quarters. This mean placing the wheels in the midsection of the body. By rotating them in opposite directions, the robot could literally spin around its z-axis, doing a complete 180° turn in place. I decided on a Hilare-type wheel arrangement which is a two wheeled differential drive with two additional passive points of contact (casters) was the way to make this happen.

After sawing away most of the scooter with a sawzall, only the back wheel and the motor remain. It turns out that using a combination of a large U-Bolt and 3 replacement screws listed above is all you need to anchor the scooter to the board. Here is a side shot of the mounted scooter frame.

I think I have been postponing posts because I want to put too much information into them so I am going to wrap this one up at this point and cover the communications protocol and how I am interpreting the sensor data as well as prioritizing remote control requests higher than PI requests in another post. I also want to talk about the power supply and how I want to manage battery charging. You can always look at the current state of my Arduino source code here. I have not yet started adding support for this peripheral to the PI daemon. It still has a long way to go.