Tuesday, October 30, 2012
Video: Everything you need to know about the FESTO robotic bird
Drones have drastically changed over the years. Some resemble planes, UFO's, and even birds. Specifically, when I say birds, I mean FESTO. It's by far the most impressive robotic bird to date. Now I'm not going into detail about this robotic bird, but you can view the video above to learn about it.
Monday, October 29, 2012
DARPA's new "Pet-Proto" robotcan avoid obstacles and climb stairs
A few days ago, DARPAtv (the youtube channel for DARPA) uploaded a video showing off their latest robot named Pet-Proto. The robot was given the challenge of climbing stairs and avoiding a huge gap in a given path. With all the new technology that was out into this robot, it was able to climb the stairs with little effort. It also got past the gap by spreading it's arms and legs to grip the nearby wall to traverse right through. All these tasks were achievable because of Pet-Proto's specially designed legs. If your interest in this bot, then check out the video above!
Playing audio with a PIC 16F1825 microcontroller and SD card
It's taken literally weeks to get right, but finally, we've got a working example of how to play a raw/wav file from an SD card using a PIC16F1825 microcontroller.
In a departure from previous projects, we've had to put our favoured Oshonsoft compiler to one side and learn how to use Sourceboost C compiler. This is because the 16F1825 isn't supported by Oshonsoft, and we're using this micro because
a) it has loads of RAM and ROM (compared to similar chips in the same price range)
b) it runs at 32Mhz from an internal oscillator (we need plenty of clock cycles to keep the sound playing)
c) of course, it's cheap
Rather than spend time writing about each and every frustration we had during this project (and there were plenty!) we decided to get the thing working, then write up what's going on - there's nothing more frustrating than reading how someone did something, only to get to the end to be told "it didn't work, so don't you do it like this in future".
One of the biggest hurdles was moving from software to hardware periperhals.
Had we a super-fast processor, we'd probably have bit-banged everything (i.e. done all the interfacing - PWM and SPI - through software) but we needed the data to keep flowing without interruption so that the sound played smoothly, so we had to use hardware SPI and hardware PWM. This isn't always as straightforward as the datasheets suggest!
This is the first of a multi-part post.
We're going to, first of all, interface with a SD card via SPI. Once we've got this interface working, we're going to investigate how FAT works and finally, read some files off the disk.
The first thing to do is hook up our PIC and SD card.
This particular PIC has registers which allow you to move the pins around (e.g. put the SPI output onto different pins) so there are probably lots of different ways you can hook things up. But this is how we did it, and it works ;-)
For testing, we've driven the speaker through a BS170 FET on the ground line. This isn't the best way to do it and in the final version we'll use a proper amp (like a LM386 or TS922) but it's good enough for now! Note that putting the transistor to ground does give a slightly better/louder signal than putting it on the powered side (but both will work).
Now before we get started, we need a couple of header files and some "serial comms helper functions" - these are functions we'll use to write messages back to the PC so we can see what's going on inside that little black box!
#ifndef _SD_H_
#define _SD_H_
#include "common.h"
#define SD_BLOCK_SIZE 512
Boolean sdInit();
UInt8 sdSpiByte(UInt8 byte);
Boolean sdReadStart(UInt32 sec);
void sdNextSec();
void sdSecReadStop();
#endif
This is our sd.h file
#ifndef _COMMON_H_
#define _COMMON_H_
#include
typedef signed char Int8;
typedef unsigned char UInt8;
typedef unsigned char Boolean;
typedef unsigned long UInt32;
typedef unsigned short UInt16;
#define inline
#define true 1
#define false 0
void log(UInt8);
void fatal(UInt8 val);
#define P_LED portc.2
#endif
This is our common.h file
And in the main file, main.c, we need a few functions to get us started.
#include "common.h"
#include "SD.h"
#define FLAG_TIMEOUT 0x80
#define FLAG_PARAM_ERR 0x40
#define FLAG_ADDR_ERR 0x20
#define FLAG_ERZ_SEQ_ERR 0x10
#define FLAG_CMD_CRC_ERR 0x08
#define FLAG_ILLEGAL_CMD 0x04
#define FLAG_ERZ_RST 0x02
#define FLAG_IN_IDLE_MODE 0x01
#pragma CLOCK_FREQ 32000000
#pragma DATA _CONFIG1, _FOSC_INTOSC & _WDTE_SWDTEN & _PWRTE_ON & _MCLRE_OFF & _CP_ON & _CPD_ON & _BOREN_OFF & _CLKOUTEN_OFF & _IESO_OFF & _FCMEN_OFF
#pragma DATA _CONFIG2, _WRT_OFF & _PLLEN_OFF & _STVREN_ON & _LVP_OFF
void UARTInit(){
//
// UART
//
baudcon.4 = 0; // SCKP synchronous bit polarity
baudcon.3 = 0; // BRG16 enable 16 bit brg
baudcon.1 = 0; // WUE wake up enable off
baudcon.0 = 0; // ABDEN auto baud detect
txsta.6 = 0; // TX9 8 bit transmission
txsta.5 = 1; // TXEN transmit enable
txsta.4 = 0; // SYNC async mode
txsta.3 = 0; // SEDNB break character
txsta.2 = 0; // BRGH high baudrate
txsta.0 = 0; // TX9D bit 9
rcsta.7 = 1; // SPEN serial port enable
rcsta.6 = 0; // RX9 8 bit operation
rcsta.5 = 1; // SREN enable receiver
rcsta.4 = 1; // CREN continuous receive enable
spbrgh = 0; // brg high byte
spbrg = 51; // brg low byte ()
apfcon0.2=1; // tx onto RA.0
}
void UARTSend(unsigned char c){
txreg = c;
while(!txsta.1);
}
void UARTPrint(char *s){
while(*s) {
UARTSend(*s);
s++;
}
}
void UARTPrint(char c){UARTSend(c);}
void UARTPrintNumber(unsigned long n){
unsigned long k=1000000000;
while(k>0) {
UARTSend('0'+n/k);
n%=k;
k/=10;
}
}
void UARTPrintLn(char *s){
UARTPrint(s);
UARTPrint("\r\n");
}
void UARTByte(unsigned char b){
const char *hex="0123456789abcdef";
UARTPrint("0x");
UARTSend(hex[b>>4]);
UARTSend(hex[b & 0xf]);
}
void UARTLog(char *s, unsigned short iv){
UARTPrint(s);
UARTPrint(" ");
UARTPrintNumber(iv);
UARTPrintLn(" ");
}
void fatal(UInt8 val){ //fatal error: flash led then go to sleep
UInt8 i, j, k;
for(j = 0; j < 5; j++){
for(k = 0; k < val; k++)
{
delay_ms(100);
P_LED = 1;
delay_ms(100);
P_LED = 0;
}
UARTLog("Error",val);
delay_ms(250);
delay_ms(250);
}
while(1){
asm sleep
}
}
We'll be calling on these functions a lot, so it's good to get them down good and early!
They should be pretty self explanitory if you're familiar with the C language; the things to look out for are the PIC internal registers used to set up the hardware peripherals.
UARTInit( ) is where the hardware UART/serial comms is set up.
We've put the serial TX pin onto pin RA.2 because we're using a PicKit2 (clone) to program our PIC. Why does this matter? Because if we use the same pins for serial data as we do for programming, we can also use the built in serial/UART tool built into the PicKit2 software without having to change any wiring!
It just so happens that in data mode, pin4 on the programmer is used for receiving serial/UART data (RX). In programming mode, pin4 on the programmer is programming data (PGD). The programming pin on the PIC is RA.0 (pin 13). By putting the UART TX pin onto RA.0 in the UARTInit function we can leave the programmer connected and simply flip between programming and UART/serial modes in the PicKit2 software.
In a departure from previous projects, we've had to put our favoured Oshonsoft compiler to one side and learn how to use Sourceboost C compiler. This is because the 16F1825 isn't supported by Oshonsoft, and we're using this micro because
a) it has loads of RAM and ROM (compared to similar chips in the same price range)
b) it runs at 32Mhz from an internal oscillator (we need plenty of clock cycles to keep the sound playing)
c) of course, it's cheap
Rather than spend time writing about each and every frustration we had during this project (and there were plenty!) we decided to get the thing working, then write up what's going on - there's nothing more frustrating than reading how someone did something, only to get to the end to be told "it didn't work, so don't you do it like this in future".
One of the biggest hurdles was moving from software to hardware periperhals.
Had we a super-fast processor, we'd probably have bit-banged everything (i.e. done all the interfacing - PWM and SPI - through software) but we needed the data to keep flowing without interruption so that the sound played smoothly, so we had to use hardware SPI and hardware PWM. This isn't always as straightforward as the datasheets suggest!
This is the first of a multi-part post.
We're going to, first of all, interface with a SD card via SPI. Once we've got this interface working, we're going to investigate how FAT works and finally, read some files off the disk.
The first thing to do is hook up our PIC and SD card.
This particular PIC has registers which allow you to move the pins around (e.g. put the SPI output onto different pins) so there are probably lots of different ways you can hook things up. But this is how we did it, and it works ;-)
For testing, we've driven the speaker through a BS170 FET on the ground line. This isn't the best way to do it and in the final version we'll use a proper amp (like a LM386 or TS922) but it's good enough for now! Note that putting the transistor to ground does give a slightly better/louder signal than putting it on the powered side (but both will work).
Now before we get started, we need a couple of header files and some "serial comms helper functions" - these are functions we'll use to write messages back to the PC so we can see what's going on inside that little black box!
#ifndef _SD_H_
#define _SD_H_
#include "common.h"
#define SD_BLOCK_SIZE 512
Boolean sdInit();
UInt8 sdSpiByte(UInt8 byte);
Boolean sdReadStart(UInt32 sec);
void sdNextSec();
void sdSecReadStop();
#endif
#ifndef _COMMON_H_
#define _COMMON_H_
#include
typedef signed char Int8;
typedef unsigned char UInt8;
typedef unsigned char Boolean;
typedef unsigned long UInt32;
typedef unsigned short UInt16;
#define inline
#define true 1
#define false 0
void log(UInt8);
void fatal(UInt8 val);
#define P_LED portc.2
#endif
And in the main file, main.c, we need a few functions to get us started.
#include "common.h"
#include "SD.h"
#define FLAG_TIMEOUT 0x80
#define FLAG_PARAM_ERR 0x40
#define FLAG_ADDR_ERR 0x20
#define FLAG_ERZ_SEQ_ERR 0x10
#define FLAG_CMD_CRC_ERR 0x08
#define FLAG_ILLEGAL_CMD 0x04
#define FLAG_ERZ_RST 0x02
#define FLAG_IN_IDLE_MODE 0x01
#pragma CLOCK_FREQ 32000000
#pragma DATA _CONFIG1, _FOSC_INTOSC & _WDTE_SWDTEN & _PWRTE_ON & _MCLRE_OFF & _CP_ON & _CPD_ON & _BOREN_OFF & _CLKOUTEN_OFF & _IESO_OFF & _FCMEN_OFF
#pragma DATA _CONFIG2, _WRT_OFF & _PLLEN_OFF & _STVREN_ON & _LVP_OFF
void UARTInit(){
//
// UART
//
baudcon.4 = 0; // SCKP synchronous bit polarity
baudcon.3 = 0; // BRG16 enable 16 bit brg
baudcon.1 = 0; // WUE wake up enable off
baudcon.0 = 0; // ABDEN auto baud detect
txsta.6 = 0; // TX9 8 bit transmission
txsta.5 = 1; // TXEN transmit enable
txsta.4 = 0; // SYNC async mode
txsta.3 = 0; // SEDNB break character
txsta.2 = 0; // BRGH high baudrate
txsta.0 = 0; // TX9D bit 9
rcsta.7 = 1; // SPEN serial port enable
rcsta.6 = 0; // RX9 8 bit operation
rcsta.5 = 1; // SREN enable receiver
rcsta.4 = 1; // CREN continuous receive enable
spbrgh = 0; // brg high byte
spbrg = 51; // brg low byte ()
apfcon0.2=1; // tx onto RA.0
}
void UARTSend(unsigned char c){
txreg = c;
while(!txsta.1);
}
void UARTPrint(char *s){
while(*s) {
UARTSend(*s);
s++;
}
}
void UARTPrint(char c){UARTSend(c);}
void UARTPrintNumber(unsigned long n){
unsigned long k=1000000000;
while(k>0) {
UARTSend('0'+n/k);
n%=k;
k/=10;
}
}
void UARTPrintLn(char *s){
UARTPrint(s);
UARTPrint("\r\n");
}
void UARTByte(unsigned char b){
const char *hex="0123456789abcdef";
UARTPrint("0x");
UARTSend(hex[b>>4]);
UARTSend(hex[b & 0xf]);
}
void UARTLog(char *s, unsigned short iv){
UARTPrint(s);
UARTPrint(" ");
UARTPrintNumber(iv);
UARTPrintLn(" ");
}
void fatal(UInt8 val){ //fatal error: flash led then go to sleep
UInt8 i, j, k;
for(j = 0; j < 5; j++){
for(k = 0; k < val; k++)
{
delay_ms(100);
P_LED = 1;
delay_ms(100);
P_LED = 0;
}
UARTLog("Error",val);
delay_ms(250);
delay_ms(250);
}
while(1){
asm sleep
}
}
We'll be calling on these functions a lot, so it's good to get them down good and early!
They should be pretty self explanitory if you're familiar with the C language; the things to look out for are the PIC internal registers used to set up the hardware peripherals.
UARTInit( ) is where the hardware UART/serial comms is set up.
We've put the serial TX pin onto pin RA.2 because we're using a PicKit2 (clone) to program our PIC. Why does this matter? Because if we use the same pins for serial data as we do for programming, we can also use the built in serial/UART tool built into the PicKit2 software without having to change any wiring!
PicKit2 in UART mode
PicKit2 in programming mode
It just so happens that in data mode, pin4 on the programmer is used for receiving serial/UART data (RX). In programming mode, pin4 on the programmer is programming data (PGD). The programming pin on the PIC is RA.0 (pin 13). By putting the UART TX pin onto RA.0 in the UARTInit function we can leave the programmer connected and simply flip between programming and UART/serial modes in the PicKit2 software.
Thursday, October 25, 2012
Video Thursdays: Nao Gangnam style
Out of all the humanoid robots in the world, Nao (in my opinion) has performed Gangnam Style the best. By enabling Nao to execute short an efficient leg movements, TheAmazel succeeded at getting his robot to perform the internet's favorite dance.
The Tinker's Workshop Makerbot Replicator 3D Printer
For some time now I have been asked by a lot of people here on the blog as well as out in the real world the question "What is a 3D printer?" For me to answer that question has become routine and quite simple to explain what it is and what it can do. This is obvious of course if you have been following my blog here over the past year or so. I am fortunate enough to be able to own one of these beautiful machines and am capable of creating pretty much anything I can dream up. Case in point is one of the last projects I posted of my 1/6th scale electric car model complete with full suspension, rack and pinion steering, disk brakes and even folding seats. This has been received very well by the 3D printing community from around the world and it was a lot of fun designing and creating it using my Makerbot Replicator 3D printer.
This being said I currently am working on another new project that I will post when I get farther along with it and an idea popped into my head yesterday while printing part for this project. I quickly pulled out my trusty iPad and shot video of ten parts being made all at the same time on my 3D printer. I thought it would be of interest to anyone who wanted to see this machine actually make some parts. I shot enough video to put together a two minute mini show that I edited on my iPad as well. Complete with titles and a music background. Now when someone asks you if you know what a 3D printer is you can say "Yes I do and I even have seen one print parts!" So enjoy the video I put together and let everyone know that you learned something new today.
This being said I currently am working on another new project that I will post when I get farther along with it and an idea popped into my head yesterday while printing part for this project. I quickly pulled out my trusty iPad and shot video of ten parts being made all at the same time on my 3D printer. I thought it would be of interest to anyone who wanted to see this machine actually make some parts. I shot enough video to put together a two minute mini show that I edited on my iPad as well. Complete with titles and a music background. Now when someone asks you if you know what a 3D printer is you can say "Yes I do and I even have seen one print parts!" So enjoy the video I put together and let everyone know that you learned something new today.
Click the YouTube button for a bigger view of the video.
Tuesday, October 23, 2012
Motorcycle Cargo Trailer Project Final Part 9
In this final part of the motorcycle cargo trailer project I will cover the painting of the trailer and final photos of what it looked like once it was completed. So once again let's get started.
Here is the trailer finally seeing the light of day on it's wheels and getting ready to be hauled to the paint shop. The blueish white kind of looks like camoflaage at this point but it will soon be sanded and primed for new paint. I was very pleased to see it take shape with all that had been completed over the eight months that it took to get this far. Total hours at this point of work came up to 425 total. This did not include the hundreds of hours it took just to design the trailer.
The trailer is on the trailer! My cargo trailer looks small compared to what it being hauled on when these photos were taken. But in reality the trailer was quite large and could haul a sizable load.
My brother who has been doing body work on cars for years was my paint man and so it was a no brainer to turn this portion of the trailer project over to him. During the winter months he worked on prepping the trailer for paint and brought the body up to perfection with this knowledge and skill of auto body work.
These two photos show the start of setting up the paint scheme that I had decided on for the trailer. This alone was a long process as the trailer like any other vehicle can be painted a million different ways and colors. So I was more than happy to have someone that I trusted to help me get this part of the project done right.
Here are some good views of the trailer body all smoothed out ready for paint. I also was very happy on how it all looked with the little details such as the tail light assembly, fenders, and latch mounts that I had been working on looking so nice even before painting had begun.
Here the final layout for the paint is being laid down on the body of the trailer. An interesting process to see first had. My brother Carl is an expert when it comes to this part of the project so I became a spectator at this point as was very confident that he would do a much better job that I ever could. I am an expert in a couple of different fields but body work and painting is not one of them. You simply cannot be an expert in every field of interest. I would have to have a couple more lifetimes to accomplish that feat.
The first of many coats of white paint are being applied to the primed body. The blue tape that had already been laid down on the body was already covering the maroon stripes that Carl had already completed before hand.
It was strange for me to see the body in color now after all of the months of working on it and only seeing the blue styrofoam and fiber glass. Looks good at this point already.
The blue tape is removed to reveal the maroon stripes for the first time! An exciting thing to see after all the work that had been put into this project. The body was painted with several white base coats and then several more coats of pearliscent white. The stripes look black in these photos but are actually are maroon to match my motorcycle.
Once the pearl paint and the stripes had cured enough four or five coats of clear were sprayed on to top to give everything a nice shine worthy of the project.
This is what it is all about. The planning, designing, blood, sweat, and tears to finally call this project done.
A good shot of the rear of the trailer with the newly chromed bumper and LED tail lights mounted. Notice the chrome locks on the lid of the trailer.
Even with the lid of the trailer open the rig looks great. The prop rod to hold up the lid was from a 65' Mustang. It was the prefect size and shape for the project.
One last thing was needed to put the cherry on top of the project. Custom coolers!
A good friend of mine had followed along with me on this project from beginning to end as I was building it and asked me if the coolers had the sun and moon on them for hot and cold drinks. I cracked up and said of course what better reason to make custom coolers for this beautiful trailer. Through it all I learned a lot about working with fiber glass and composite construction in general. It led the way to other projects like the fifteen foot three section kayak that I have posted on this site.
I hope you have learned something new as well with all of the postings about my trailer project and have come away with the knowledge that it does not take a rocket scientist to create something like this. Just a lot of patience and the willingness to put the effort into it to see it to completion. Enjoy and keep tinkering!
Monday, October 22, 2012
Lego NXT robot draws the Mona Lisa
Since nothing relating to robotics has really stood out today, I decided to share this amazing Lego robot video with you. It shows a small Lego robotic arm drawing the Mona Lisa. Don't take my for it, check out the video above to see for yourself.
Motorcycle Cargo Trailer Project Part 8
Today in this section of the motorcycle cargo trailer project we will look at the mounting of the lid for the body, rear bumper mounting, lid latches and protective undercoating of the body.
The hinge is removed and only the lower mounting block is puttied into place using a resin putty mixture. This mount once it has cured will be totally glassed into place to seal it completely from the elements.
Here one of the hinges is closed and shaped to work out how the mount will look when done.
The lid of the trailer was put in place just to see where I was headed with the hinge mounts. This was a trial and error kind of thing to work out. As I was experimenting a this point to figure out what would work and look good all at the same time.
The lid hinges here are mocked up on wooden mounting blocks. I found the hinges online at a supply house that handles parts for boats. I thought that if it could stand being on a boat it would work well on the trailer. Less likely to rust.
The area for cutting is laid out on the one the foam surface of the body of the trailer. The two locations for the hinges is where the additional panel was added at the front of the trailer body opening. (see earlier post on this panel placement)
Let the foam cutting start once again.
The front hinge is test fitted into the new opening to make sure everything looks and works right.
The hinge is removed and only the lower mounting block is puttied into place using a resin putty mixture. This mount once it has cured will be totally glassed into place to seal it completely from the elements.
The hinge and upper block are reattached once again to check alignment and clearances.
Here one of the hinges is closed and shaped to work out how the mount will look when done.
The lid of the trailer was put in place just to see where I was headed with the hinge mounts. This was a trial and error kind of thing to work out. As I was experimenting a this point to figure out what would work and look good all at the same time.
This is a good view of the hinge mounts that are glassed in and cutouts on the lid.
The upper hinge block is now cut down to match the angle of the top lid surface and a small foam wedge is sitting alongside to fill the upper void.
These two photos show the lid in place over the upper hinge block without the foam wedge and with it in place.
At this point the hinge assembly is covered with plastic film so that all the upper wooden block and foam wedge can be bonded into place using fiber glass resin putty. The plastic film is resting between the upper and lower hinge blocks so that when I bonded the lid to the upper block it would not glue the hinge shut. This would be very bad as it would make the assembly useless at that point.
Once the bonding putty had dried it was then sanded smooth and the upper mounting block could be glassed into place for a strong, straight, tight fit. The hinges now were in place and the lid could be removed completely by just removing the mounting bolts for the hinges. Each of the holes in the wooden block had steel inserts in them so that if the lid needed to be removed it would not just have wood screws holding the lid on. Otherwise over time the mountings could fail and you would have a heck of a time trying to fix or make a new hinge mount.
Here is a computer image of the design that I came up with for the rear bumper of the trailer. In an earlier post I had told you that my first design of a bumper was to have it incorporated into the body of the trailer. This was not a good idea as it would be difficult to not have the bumper damaged and then you would have to repaint the entire body of the trailer because of it. What I did here was use a steel bumper that would mount directly on to the frame give it better structural strength and protection from damage.
It took me some time online to find the exact parts that I needed for the end caps of the bumper. These were hollow half balls of steel and were a real trick to find. The bumper is made from standard muffler pipe that is cut and welded together using end plated that would mount the assembly to the frame.
These two photos show the bumper temporarily mounted to the frame with the body in place and with it moved so that the mount could be more easily photographed.
Next the rear chrome hasp mounts were created to lock the lid of the trailer down. I struggled for the longest time trying to figure out an inexpensive and simple way to lock the trailer. I originally wanted a lock system similar to what you would find on a car. This proved to be way to complicated and expensive to duplicate so I came up with this idea of using two chrome hasps that would have locks on them. Simple, inexpensive and easy to build.
The mounts for the chrome hasps have a mounting block similar to all the mounts on the trailer with mounting holes for the stainless machine screws. In each hole once again was a steel threaded insert so that you could have a sold steel mount that would not destroy itself over time. The mounts were then wrapped in foam around the outer perimeter to give it a nice look when glassed.
Her the trailer is prepped with paper and tape so that the underside of the body could be painted with a protective truck bed liner material.
This is a black rubber compound that you roll on with a bush to protect a truck bed. It worked out perfectly with the trailer as it gave a nice finished look to the underside of the body and protected it from rocks or what have you that the tires would toss up into the glassed fenders. Again inexpensive and very strong so it was a great idea that worked out very well.
So once again with this installment of this project I've managed to show you some pretty complicated assemblies and simple solutions to head toward completion of the motorcycle cargo trailer. Enjoy.
Subscribe to:
Posts (Atom)