Saturday, December 24, 2011

Starting a Mini Sumo Robot Project

For a while now I have been intending to put together all the modules I have lying around to make a Mini Sumo Robot. I have a tank tread platform, a dual motor controller, an old battery pack from an RC car, and the board from my tachometer project. With those parts plus IR emitters and sensors, I have the beginnings of a sumo bot. Below is the approximate layout (not yet hooked up).

Pieced Together Mini Sumo Bot
My first attempt at creating the IR emitter and sensor circuit failed miserably... mostly because I was trying to do too much at once.  The other problem I think I am getting is the vast differences in the IR detectors I purchased from RadioShack.  I have one of the Sharp distance measuring units I bought from Sparkfun (GP2Y0A21YK) a while ago... I should probably purchase another and leave the building my own module for the future.

Sunday, December 18, 2011

Completed Simplex Air Engine Drawing

Now that the engine is up and running, I have updated the drawing so that all of the bugs are out (or should be).  

Completed Simplex Engine Drawing

Working Simplex Air Engine

After a long time of starting and stopping work on the simplex air engine, I have finally got all the main parts made and assembled.  After a little tinkering, I got it working!


I'll updated the drawing and re-post it shortly along with a longer and nicer shot video.

Hole Tapping Guide with Spring

The best way to manually tap a hole, when the part is still on the mill, is to use a shaft which has a tapered end.  The tapered end interfaces with the hole on the end of the tapping handle.  This ensures your threads are "perfectly" normal to the part.

While tapping a hole during the Simplex Engine Project, I realized I did not have this helping taping guide.  The simple way to go would be to use the shaft with the tapered end as I described above.  Using that way would force you to move the quill as the tap moves downward, but who wants to do that?  So I came up with a three-part (plus one screw) design that uses a spring to save me from that 'extra' labor.


Assembled Tapping Guide with Spring
To use it, simply put the non tapered end into your chuck, put the tap and tapping handle in place, and move the quill down until you have compressed the spring a reasonable amount.  Now you can rotate the tap with the tapping handle while maintaining some axial force.

Although the drawing uses 1/4 rod, I ended up using a slightly larger diameter since that's what I had laying around.  Whatever you choose, make sure it's small enough to fit in your chuck.



Tapping Guide Parts

Tapping Guide Drawing

Sunday, September 11, 2011

Lathe Project 1 - Simplex Air Engine

I wanted to share this Simplex Engine design.  So I have created one large (and maybe slightly overwhelming) drawing to aid anyone else who wants to build it.

Please remember, I have not yet made every part, so there may be mistakes and/or missing dimensions.

Simplex Engine Drawing

Lathe Project 1 - Simplex Air Engine

Over the past week, I have been using every spare night to machine my engine parts.  Here is what I have done so far.

First, I re-machined the piston to cam connecting shaft.  I was not happy with the first version. After my third attempt, I'm pretty happy with the result.  A few mill operations and it's done. (the top part is the first attempt, the bottom my final part awaiting machining on the mill).

Connecting Rods (my iterations)
Next, after only one attempt, I created a nice drive shaft which also serves as the valve for this engine.  A few mill operations and it's done.

Drive Shaft

Next, I machined the pin which will hold the Connecting Rod to the Piston.  I just need to thread the small diameter (#2-56).

Piston Pin

Finally, after a number of failed attempts, I finished the lathe work on the Cam Shaft Pin.  This pin connects the Connecting Rod to the offset weight.  Two of the diameters need to be threaded with #2-56.

Cam Shaft Pin

I have also included two cross sectional images of the engine assembly.  The first image is the cylinder being pressurized (the compressed air comes from the end of the tube).

Pressurize Stroke
The next image shows the exhaust stroke.

Exhaust Stroke



Sunday, September 4, 2011

Lathe Project 1 - Simplex Air Engine

For my first 'real' project, I wanted to start small.  Nothing too time consuming or complicated.  After poking around on the web for a while, I stumbled on a 9x20 lathe blog (Smithy's Lathe Blog).  Smithy has made a number of cool working engines powered using compressed air.  After doing some reading, I thought I could do the same.  So, I sat down and designed my own based on Smitty's.

Simplex Air Engine - Front

Simplex Air Engine - Rear

I have also started the first part, the connecting rod.  The basic shape is there, next comes a few milling cuts and then holes for the pins into the piston and cam.

Partially Complete Connecting Rod


Sunday, August 21, 2011

Practice with the lathe

It has been a while, at least 4 years, since I have played with a lathe.  So, before I begin to start any serious projects, I wanted to freshen my memory.

My first practice project was to make a spinning top out of some steel bar I had laying around (actually it's precision ground rod from my CNC project, unhardened).

Here it is.

Finished top
And better yet, it works!

Spinning top
The next practice project involved machining a diameter which was at a precise size.  So, using a bearing out of my roller blade wheel, I machined a part to fit it on.

Bearing and mating part
Bearing and mount assembled
Now that I've got the basics down, time for something more advanced.

Grizzly G4000 Benchtop Lathe

Ever since I worked in a machine shop over the summer when I was in school, I have loved lathes.  For a while now, I have wanted my own benchtop version to support my robot hobby.  Finally, I had the cash to buy one.  I bought the Grizzly G4000 9x19 Bench lathe (G4000 link)

First, this is the bench I made to hold it.  It is made of 1.5" square tube with a 1.5" thick wood top.  It has castors for easily moving it around, as well as leveling feet for... well, leveling.

Bench for lathe
The images below are the 'fresh out of the box' images in chronological order.

As shipped
Four jaw chuck
Face plate
Tale stock
Misc parts
Steady rest
Follow rest
Compound slide and tool holder
Stripped lathe
Drive gears and pulleys
Fully stripped lath
Chip pan
The above chip pan is to be used (per the instructions) as the bolt template to drill and secure the lathe to the bench.  It's obviously pretty easy to drill the two holes for the 1/2" bolts when you have the machine, but it would have been nice to have the information before it arrived.  So, for your convenience, the bolt center to center distance is approximately 23 3/16", as shown below.

Lathe mount bolt distance

Re-assembled lathe on bench
Workshop

Tachometer Project is Complete! (kinda)

Since my last posting, a lot has happened.  I received the new tachometer board, populated it, programmed it, and then tested it.  Below is an image of the testing set-up.

Prototyped Tach Board in Test
In the image above, you can see the oscilloscope to the left which is hooked up to the photogate signal.  I have a motor spinning an incremental encoder wheel (a disk with slots on it) from an old ball mouse.  You can also see the RPM is being displayed on the serial display.

The current code works by counting the number of 'highs' within 250 ms (1/4 sec) and doing some simple math to compute the RPM.  Although the code is working and I can call this one 'completed', I'm not too happy with the accuracy.  It is slightly inaccurate because of the method I used (as described above).  The more accurate method involves measuring the time between 'highs' (or teeth in my case).  That way there are no rounding errors.

The current method rounds down, so if the chip has counted 55 highs and is 95% to the next high, just as the time ticks to 250ms, it only sees 55.  So the extra 0.95 high is not counted.  If your gear has very few teeth, the time between teeth increases and your error becomes bigger.  The high to high counting does not have this issue.

This whole project started off by wanted to provide an RPM measurement for my dad's Mini-Mill from Grizzly.com (the G0463).  Finally, the project is at a phase where we can integrate it to the machine and I can update the program later (if I get the energy).

The images below show the mini-mill's gears which I plan on hooking my magnetic tooth sensor too.

G0463 Mini-Mill with gear cover removed
Below are the spindle and drive gears with the number of teeth marked on each.  I will obviously need the number of teeth per revolution to program into the chip.  It was not obvious to me, at lease not right away, that after you know the number of teeth per revolution, it does not matter which gear, big or small, you place the sensor next too.  Ponder it... you'll figure it out. (it's not like belts and pulleys). 

G0463 Mini-Mill Spindle and drive gears
And next I had planned to include an image of the populated board and all of the external parts (display, tooth sensor, and battery clip), but apparently I forgot to take a picture before handing the assembly over to my dad.... well, you'll have to wait.

Saturday, June 18, 2011

PIC16F688 Timer 1 Code

After developing the code on the PIC16F877A for my tachometer, I decided to use the PIC16F688 since it was cheaper and smaller.  Below is the code to run Timer 1.


// PIC16F688
// Flash LED with Timer 1
// RoboSlave.Blogspot.com 6/2011


// -----------------------------------------------------------------------
// Includes
// -----------------------------------------------------------------------
#include "system.h" // Include general file


// -----------------------------------------------------------------------
// Configuration Bits
// -----------------------------------------------------------------------
#pragma DATA _CONFIG, _PWRTE_OFF & _WDT_OFF & _CPD_OFF & _HS_OSC & _CP_OFF
#pragma CLOCK_FREQ 20000600


// -----------------------------------------------------------------------
// Defines
// -----------------------------------------------------------------------
#define TimerLED portc.0


// -----------------------------------------------------------------------
// Interrupt
// -----------------------------------------------------------------------
void interrupt( void )
{
if( pir1 & (1<<TMR1IF) )   // Handle timer1 interrupt
{
TimerLED = !TimerLED; // Toggle Timer LED
pir1.TMR1IF = 0; // Reset interrupt flag
}
}


// -----------------------------------------------------------------------
// Main Program
// -----------------------------------------------------------------------
void main( void )
{
ansel = 0x00; //Configure portC as I/O
cmcon0 = 0xFF; //Configure portC as I/O


trisc = 0x00;   //Configure port C
portc = 0x00;   //Initialize port C


tmr1h = 0x00; //should be cleared before enabling interrupts
tmr1l = 0x00;


intcon.GIE = 1; //Global Interrupt Enable bit
intcon.PEIE = 1; //Peripheral Interrupt Enable bit
pie1.TMR1IE = 1; //Timer1 Overflow Interrupt Enable bit


t1con = 0b00010001;


     while (1)
    {
}
}

Friday, June 17, 2011

Tachometer Board and Programming

Since the last post, I have been working on getting version 1.0 tachometer board up and running.  It turns out that creating the schematic and laying out the board in one night is too fast for a novice like me.  I made a number of simple mistakes that doomed the board from the schematic level.

Bad Schematic (REV -)
The two areas boxed in red were incorrect. VDD is positive 5V and VSS is ground. Apparently the PIC16F688 does not work well when it is not grounded properly. However, it does show some life.  For whatever reason, I was still able to blink an led. The delay between blinks was 5X slower than it should have been, but it did work.  This played havoc with my programming because I was convinced the board was working properly.  Finally, after a bit of programming help from the Sourceboost C forum (my thread), I managed to get Timer 1 working properly. I also have fixed my current board, shown below.

Fixed Board
The schematic has been updated to fix the errors, as well as add holes to connect to the unused pins.  I wanted this in order to use the board for prototyping in the future.

Updated Schematic (Rev A)
Updated Layout

Sunday, April 17, 2011

Tachometer board has arrived

I ordered three boards on March 25th and six show up on April 14th... Thank You BatchPCB!  After about 30 minutes of soldering, the board was fully populated.

Populated Tack Board
My desk after soldering
Best of all, I plugged my PicKit2 into the board and it was recognized!  All I need to do now is fix the code so that it works on this PIC16F688.  I developed working code on the PIC16F877, which I do most of my programming on.  Unfortunately, I did not realize the vast differences between the two... not quite plug-n-play.

Friday, March 25, 2011

Tachometer board has been ordered

Last night, I managed to get the tachometer programming and circuit all figured out.  Before I knew it, I had the schematic and then the board laid-out.
Tachometer Schematic
Tachometer Board Lay-Out
After about two hours of playing around with the schematic and moving the components around on the board, I decided I was done.  I then placed an order with BatchPCB.  This board is 1.17x1.54 inches, and cost $4.51 each with a $10 handling fee.

I also placed an order with Digi-Key which contained the gear tooth sensor which will be mounted within the gear box of the mini mill.  That order is below.
Digi-Key Order

Saturday, January 29, 2011

PIC16F877A Interrupt Code

During my attempt to program my tachometer, I decided to make things simpler by creating code for an external interrupt, timer 0 interrupt (TMR0), and timer 1 (TMR1) interrupt.  I figured this might be useful to someone in the future, so here it is!

NOTE: I program my code using Sourceboost C complier.

External Interrupt Code on the PIC16F877A
//External Interrupt Test,  
//RoboSlave.Blogspot.com, 1/2011
//Includes
#include <system.h>
//PIC16F877A
#pragma DATA _CONFIG, _PWRTE_OFF & _BODEN_OFF & _WDT_OFF & _LVP_ON & _CPD_OFF & _DEBUG_OFF & _XT_OSC & _CP_OFF
#pragma CLOCK_FREQ 4000000 //Set clock frequency
//Define
#define button1 portb.0
#define led1 portd.0
//Interrupts
void interrupt( void )
{
if( intcon & (1<<INTF) ) //Handle external interrupt
{
clear_bit( intcon, INTF );
led1 = !led1;
}
}
//Main Code
void main( void )
{
trisb = 0x00; //Configure port B
trisd = 0x00; //Configure port D
portb = 0x00; //Initialize port B
portd = 0x00; //Initialize port D
intcon = 0xB0; //Enable interrupts (External, Timer0)
while( 1 ) //Endless loop
{}
}

 Timer0 Interrupt Code on the PIC16F877A
//Timer0 Interrupt Test 
//RoboSlave.Blogspot.com, 1/2011
//Includes
#include <system.h>
//PIC16F877A
#pragma DATA _CONFIG, _PWRTE_OFF & _BODEN_OFF & _WDT_OFF & _LVP_ON & _CPD_OFF & _DEBUG_OFF & _XT_OSC & _CP_OFF
#pragma CLOCK_FREQ 4000000 //Set clock frequency
//Define
#define led1 portd.0
//Interrupts
void interrupt( void )
{
if( intcon & (1<<T0IF) ) //Handle timer0 interrupt
{
clear_bit( intcon, T0IF ); //clear timer 0 interrupt bit
led1 = !led1;
}
}
//Main Code
void main( void )
{
trisd = 0x00; //Configure port D
portd = 0x00; //Initialize port D
intcon = 0xB0; //Enable interrupts (External, Timer0)
//Set Timer0 mode
clear_bit( option_reg, T0CS ); //configure timer0 as a timer
//Set prescaler assignment
clear_bit( option_reg, PSA ); //prescaler is assigned to timer0
//Set prescaler rate
set_bit( option_reg, PS2 ); //prescaler rate 1:128
set_bit( option_reg, PS1 );
set_bit( option_reg, PS0 );
//Set timer0 source edge selection
set_bit( option_reg, T0SE ); //increment on high-to-low transition on RA4/T0CKI pin
while( 1 ) //Endless loop
{}
}

  Timer1 Interrupt Code on the PIC16F877A
//Timer1 Interrupt Test, 
//RoboSlave.Blogspot.com, 1/20111
//Includes
#include <system.h>
//PIC16F877A
#pragma DATA _CONFIG, _PWRTE_OFF & _BODEN_OFF & _WDT_OFF & _LVP_ON & _CPD_OFF & _DEBUG_OFF & _XT_OSC & _CP_OFF
#pragma CLOCK_FREQ 4000000 //Set clock frequency
//Define
#define led1 portd.0
//Interrupts
void interrupt( void )
{
//if( pir1 & (1<<TMR1IF) ) //Handle timer1 interrupt
if (pir1.TMR1IF == 1)
{
clear_bit( pir1, TMR1IF ); //clear timer 1 interrupt bit
led1 = !led1;
}
}
//Main Code
void main( void )
{
trisd = 0x00; //Configure port D
portd = 0x00; //Initialize port D
intcon.GIE = 1;
intcon.PEIE = 1;
pie1.TMR1IE = 1;
t1con= 0b00000001; //set timer1 configs and start
while( 1 ) //Endless loop
{}
}

Wednesday, January 19, 2011

New Tool! - Oscilloscope

I was looking for a function generator to use during my tachometer project debugging.  So I started to bid on a few on ebay.  Wow, ebay is addicting!  Before I realized it, I bought myself an oscilloscope which is just a few years younger than me!  Hitachi Model V-209 Portable Oscilloscope born in 1987, and cost $48.50 + shipping.
My Oscilloscope
Still no function generator... but there is always my next paycheck to look forward too.

Sparkfun Free Day

I wanted to comment on the Sparkfun Free Day on January 13th.  This was the second year I (tried) to participate.  Last year the server did not allow me to even see the pages.  This year it was far better but I still walked away disappointed.

I passed up $30 free dollars (due to my 3+ years as a customer) and attempted to complete the 10 question quiz at a chance to win $100 free dollars.  I did see the first question.... for about 45 minutes... again and again and again.  The server just would not allow me to submit my answer no matter what I did.

Unfortunately, I was being greedy and should have gone for the easy money and walked away.  Instead I got zero.  But I did get this message about a hundred times!
Sparkfun Error Message

Project 4 - Tachometer

Its been over a month since my last post... I did not work much on the others, but I did manage to add another project to my list.

Enter Project 4, the tachometer.  This project was spawned from my father buying a mini milling machine from Grizzly Industrial Inc.  The machine is model G0463 which is a variation of other mini mills on the market.
Grizzly Mini Mill Model G0463
The more expensive mini mill model comes with a number of bells and whistles which may or may not pay for themselves, one of them being an RPM gauge.  After a bit of discussion, I decided to take on the task of making a tachometer to determine the RPM of the spindle.  The range is from 0 to 2000 RPM.  I will probably use a sensor to measure the passing teeth on the drive gear beneath the upper cover... but we'll see how that goes.

Below you can see the current breadboard assembly.  I am using a PIC16F877A for now and will switch to something with less pins when I get the time.  I am also using an old mouse encoder wheel mounted to a motor which I can use to simulate the spindle (bottom right).  The sensor is a simple photogate, which has one LED pointing at a light sensor (all in infrared).
Tachometer Breadboard Set-Up
I bought the following from Sparkfun to display the four digit RPM.
Sparkfun Display Order
I managed to send the numbers via serial communication but was not getting the correct range of RPM... I need to play with the code, the delay_ms(time) function in Sourceboost C may be inaccurate.  I don't have any pictures of that quite yet.

The plan, for now, is to use 1 pin to send the RPM to the display instead of 28 pins.  I did not want the hassle of connecting up each led in each segment and then having to control the mess in the code.  That may happen in a later addition and maybe even if I layout a board for this project.