Monday, December 31, 2012

More Progress On The New Tinker's Workshop

Today was a good day to end out 2012.  After all that has happened over this past year I am more than happy to have the year end and have progress made on setting up the new workshop on top of it all.  I had to confer with my good friend Garry yesterday to help me figure out some electrical snafu's that had show up with my setting up the new workshop.  Garry gave me some pointers once again and so I tore into the project today hoping for the best.  As I have said in earlier posts I am a rookie when it comes to anything electrical other than changing out a dead light bulb once in a while.  So this is what I had to look at today.


On one end of the new workshop I had started enlarging the door from a single door to a double door.  This was looking good until the fist snafu showed it's ugly head.  


Here buried inside the wall between the main beam of the house and the old "Rec" room was this electrical box.  Written below the box are the words NW Bedroom & Bathroom.  This gave me a clue at least as to where the wires were going and that was about it.  I tore the remainder of the stud wall out so that I could get at the wiring.  This helped a lot and as the studs had to come out anyway I was still making progress.  After that I had to go to my circuit breaker box and figure out what unlabeled switch shut the power off to this wiring.  After ten minutes or so I found the right switch and then could open up the electrical box.  It was simply wired as three black wires and three white wires together.  Not badly done just badly placed in the basement.  Another ten minutes later I figured out that one wire came from the circuit breaker box and the other two wires led to the two rooms now without power.  I disconnected everything and pulled the wires out of the electrical box so I could find some other place to mount it so that it would have easier access.  Luck was still with me as I found the perfect spot four feet from the wall just near my washer and dryer.  Yay!!!!  I removed the electrical box and mounted it in the new location and inside twenty minutes I was done.  


Now the doorway is nearly ready for framing and the new doors can be installed without having buried electrical boxes in the way.  On to the next snafu!


Another mystery electrical job was found.



At the foot of the steps was another electrical box that was tied into a light that was less than worthless to even have been installed.   Poor lighting to say the best thing about this light and even worse yet was the box and a mystery transformer were just hanging in between the joists.  


This is a good view of what the inside of the electrical box looked like along with the mystery transformer that was plugged into it.  No clue as to how long this had been wired like this but no matter what it had to go.


Round two then took place again with the unlabeled circuit breaker box.  Luckily this light was was only five steps from the box so I could see if the right switch had been shut off.  I killed the power and removed the worthless light and mounted the electrical box and the transformer on the inside of one of the joists that could easily be accessed once again.  On to the last task of the day.



The outlet that was mounted on to the wall just under the step had to be looked at to see if it could be moved to a new location where a new wall will be added to close up that end of the workshop.  I lucked out with this task as the outlet only need to be removed from one of the studs in the existing wall.  This then gave me more than enough wiring to move the outlet into position on the planned wall that will cover the old wall.  Pulling the paneling was a snap and so a couple minutes later I had it ready for the new wall which hopefully I will have installed some time this week.   I just left the outlet hang for now until the wall is up.
  So as I said earlier it has been a good day working on the new workshop.  I did not get zapped by electricity,  didn't cross wire something and start a fire, and I cleaned up some ugly wiring and electrical boxes that needed to be done anyway.  By the way I figured out what that little transformer was for on the second electrical job.  That is for my door bell.  So now I will still be able to hear someone at my door so I can show off my new workshop or at least the progress I've made on it today.  
  Have a Happy New Year.  I  know mine will be a good one if I keep having days like this one. 

Saturday, December 29, 2012

Rope making machine at BuildBrighton

With Xmas and New Year occupying so much of everyone's time, there's not really been much time for nerding about lately. Well, not for some of us. But thankfully Stephen Cropp from BuildBrighton hasn't been so pre-occupied, and set about 3D-printing this awesome rope-making machine.


It's really quite simple in design. At one end of the table is clamped a central cog, which drives three outer cogs (each spaced 60 degrees apart). By turning the central cog with a handle, all the outer cogs turn the same way and at the same rate.

Steve threads his twine through hooks on these outer cogs to a weighted clip at the other end of the table then cranks the handle...



Friday, December 28, 2012

The Bob-R Hat.....A Hat For A True Fisherman!

The Christmas rush has finally come and gone and I am now able to get back to the blog and post something that I have been waiting to show everyone since last September.  I created something special for a close friend of mine who is big into fishing.  I am not but I knew that he is and so the idea for the gift was born.
    In the Midwest everyone knows about Wisconsin and the state being the dairy state. With that also being famous for cheese.  I know this very well as having grown up in this great state and once again living in it.  Along with the famous cheese, Wisconsin has also created what else?  The cheese hat of course!  With that thought in mind I put a twist on the hat idea and created a special hat of my own for anyone into fishing.  I call it the Bob-R hat. 


Here my friend Garry is happily modeling my creation that I made for him for Christmas.  With this post I will show you how I put it all together.


I had to create the top of the bobber button first in my computer.   This will make more sense as I progress with the photos in this post so bear with me.  


The red disk was printed on my Makerbot 3D printer and then bonded onto a styrofoam cylinder.  After the epoxy had cured I wrapped the assembly with a couple layers of fiber glass cloth and resin, let it cure over night and sanded smooth everything smooth.


Next work began on a styrofoam hollow half sphere that I found at a craft store. After fiber glassing the outside of the dome I made a cut out to receive the bobber button. 


 Next I created a fiberglass ring to insert into the cutout for the top of the dome.  This was made by wrapping the bobber button with plastic wrap and then laying down a couple more layers of fiber glass cloth and resin for a perfect fit. 


 This ring was slid into the cut out in the dome.


 The inner portion of the cavity was then filled with fiber glass resin and a micro-balloon mixture.  This mixture was poured into the cavity and then left to cure over night.


 After the resin mixture had cured I trimmed off the excess portion of the ring to make it flush with the top of the dome.


The bobber button was then inserted into the dome to double check the fit. 



Along with the button a brass ring needed to be added to complete the look.  This ring was created by taking a brass rod and clamping it into a vise with a one inch steel pipe.  With it being clamped in place I only had to take the rod and bend it around the pipe.  I then cut it to size using a Dremel tool and inserted the loop into the two holes that were modeled into the red disk. 



These strange little pieces were created on the Makerbot 3D printer to hold the head band into place inside the hat.  This took about three tries to get the shape just right but it was worth the effort.



 The bobber button was then wet sanded several times and painted in gray primer.



 The mounting blocks were bonded into the inside of the helmet and left to cure over night once again.  Then the first coat of primer was sprayed on.


Several more coats of primer later and a lot more wet sanding and the dome is near ready to be painted with several coats of gloss white paint.



The button for the hat was painted bright red and turned out perfect.  


Once the paint had cured long enough I was able to reinsert the brass loop for the top of the button.  Check out the gloss on the paint.  I'm getting this painting fiber glass thing down pretty well.  This is where all the wet sanding pays off in a big way. 



The hat is also wet sanded and painted with primer over and over until the surface is super smooth.  It doesn't look pretty here but the effort put into the hat at this point like the button pays off later.


 Here the inside of the hat has been painted bright white with at least four or five coats of paint.




After the white paint had dried on the dome for a couple of days I was then able epoxy the red button into the top of the hat to mount it securely for good.


 An adjustable headband was next inserted into the mounting blocks inside the helmet.  This makes the hat easy to wear and will actually keep your head cool in hot weather. 


The finishing touch to the Bob-R hat is the decal that I designed for  the back.  I had this made for the helmet by a car place that makes decals for cars.  They were more than happy to work on something different. It really makes the helmet stand out that much more.  As if it needs to stand out any more than it already does.  




Here is a video I shot of my friend Garry opening up his very special gift.  The reaction to his present made the project all worth while.  As usual here at the Tinker's Workshop I tend to design and build some pretty interesting projects. This one has got to be one of the most "Different" kind of projects to be sure.  Interesting and different in the same breath.  

Thursday, December 27, 2012

Dual Axes SunTracker with Advanced Options


Finally i came up with the new efficient algorithm for the dual axes sun tracking system. The tracker is menu based , parameters can be set with 6-keys keypad with following functionalities:


1- Single Axis or Dual Axis control settings
2- 12VDC / 24V DC motor (windshield car motors etc) or Linear Actuator (Peak Current 10Amp)
3- PWM based motor controller. The PWM value is selectable from Menu.(0~100% duty cycle)
4- Return East Options (a- On Limit Switch stoppage based or -b- Time based)
5- User Selectable Tracking Delay
6- Load Sequencing management
7- Dark return Time setting
8- Twilight Time settings (after the twilight Dark return Time started)
9- RJ45 connectors for sensors
10- Sensors sensitivity settings
11- Highly efficient tracking Algorithm
12-Drive Off sun position setting
13-Easy menu driven parameters settings
14- Saving Parameters values in EEPROM
15-Compact and easy to install
16-Northern/Southern Hemisphere Compatible

LCD, Keypad and sensor:


I am still adding much more features as it is micro-controller driven..
Modular type:
1- Main Controller (Price Range 30~45 US dollar)
2- PWM DC Motor Controller (10 ~15 US dollar)
3- Sun Tracking sensors (single axis or dual axis) (5~10 US dollar)
4- 20x4 backlight LCD with control circuit ( 12~15 US dollar)
5- six Key keypad (2 US dollar)
6- Optional controller to sensor wiring

Tuesday, December 25, 2012

How to fix any Hexbug robot

I have noticed that the Hexbug robotic creatures are pretty popular gifts for kids during Christmas. If you are experiencing any kind of problem with your Hexbug, try any of the troubleshooting options below.

1. Reverse the batteries (a lot of these robots are shipped out with the batteries facing the wrong way)

2. Remove anything that is caught inside the robot. For example, dirt maybe clogging the robot's gear box.

3. Replace the old batteries with the new ones.

4. Replace the batteries in the remote controllers (for the inchworm, spider, slider XL, and scarab XL.

5. Make sure your robot and it's controller are on the same channel (A or B)

Thanks for reading and if you're experiencing any other problems, then comment below and I'll see what I can do.

Sunday, December 23, 2012

Homemade PCB for a new robot

After messing around with a lot of wires in my projects, I decided to make my own PCB. For this PCB forging method, I used ferric chloride (Iron(III) Chloride) and an ordinary permanent marker. I first cut the copper clad into a small shape. After that, I drew on the design and then placed it into the etching solution. Roughly 20 minutes later, the PCB was ready! The only thing left to do was dispose of the Copper Chloride (because it had copper in it) . To dispose of the acid, I poured baking soda (a base) into a bucket with the acid. It then reacted to form a safe byproduct that can be placed in a bag and tossed away. Thanks for reading and more updates will be posted soon! Merry Christmas!


Wiegand26 protocol RFID reader

We recently received an RFID reader from eBay for a door tagging/entry system project due to start in the New Year. This one was going to stay on hold for a while, but with a few hours to spare one evening at a BuildBrighton Thursday night, it seemed like the perfect opportunity to have a play about and see what this thing could do.



Firstly, it uses some weird protocol called Wiegand26 rather than the slightly more straight-forward serial/TTL level communications. But the protocol itself seems quite straightforward: the device consists of two data lines - when a zero is transmitted, one line goes low for a few microseconds, while the other stays high and when a one is transmitted, the other line goes low, keeping the first line high.

This seems easy enough. We simply monitor both lines and when one goes low, wait for it to come high again, and add a zero or a one to a binary buffer value. The tricky part comes in detecting the end of the binary stream:

Now the "official" Wiegand26 protocol involves 26 bits of data (that must be where it gets the -26 part of it's name from!). But some RFID cards and tags use much longer data for better security. Since we don't know much about the tags/cards we're going to use with this reader, we're going to have to assume there could be more or fewer bits of data coming down the wire(s).

So here's the approach:
We're going to set a flag to say whether or not we've started receiving some data.
As soon as one of the data lines changes, we start a timer running to time out after about 500ms.
Every time one of the data lines changes, we reset the timer.
When the timer times out (no activity for 500ms) we see what data we've got in the buffer and spit it out over serial.

We've doing this project in SourceBoost - not because we've fallen out with Oshonsoft, but because the first chip we picked up was one of the 16F1825s we've been using in our earlier audio project, so we stuck with it for ease of use.

This is the bulk of our program:
void main(){
   init();
   timer1Init();
   delay_ms(50);
   startTimer();
   while(1){
      checkforinput();
   }
}

The init routine simply sets up the input/output pins, and for debugging, starts the UART for writing data out over serial so we can debug what's actually going on inside the magic black box:


void init(){
   
   osccon           = 0b11110000;   //32 MHz clock   
   intcon           = 0b11000000;   //global/peripheral ints enabled
   apfcon0          = 0b01000000;   //MOSI on RA4
   option_reg         = 0b10000000; //no weak pull-ups, timer0 at OSC/4/2 = osc/ 8   

   UARTInit();
   ansela            = 0;         //no analog inputs
   anselc            = 0;         //no analog inputs
   trisa=00000000b;
   trisc=00000110b;
   
   porta=0;
   portc=0;
   tmp=0;   
   bitCount=0;
   bufferPointer=0;
   
   // now we pull pins low to activate the beeper and the lights
   // so force them high by default
   porta.2=1;
   portc.0=1;
   
   msCount=0;
   isReading=0;
   empty_buffer();
}

We couldn't be bothered to work out the values/pre-scalers for a 500ms timer, so just copied and pasted some code from another project which kept a 1ms timer, and used that with a counter to decide when 500ms had passed:


void preloadTimer1(){
   //------------------------------------
   // pre-load timer1 with 65172 (0xFE94)
   //------------------------------------
   // 1/22050 = 0.00004535147
   // at 32mhz, fosc=8,000,000
   // and 8m/22050 = 362.812
   // so we want our timer1 to only count up to 363
   // timer1 is a 16-bit timer (0-65535) so we need to
   // preload it with 65535-363 = 65172

   tmr1h=0xfe;
   tmr1l=0x94;
}   

void timer1Init(){
   //-------------------------------------------
   // interrupt on timer1 22050 times per second
   // ------------------------------------------
   pie1.0=1;   // timer1 rollover interrupt on bit zero
   intcon.7=1;   // global interrupts
   intcon.6=1;   // peripheral interrupts
   preloadTimer1();   
}

void startTimer(){   
   t1con.0=1;
}

void stopTimer(){
   // turn off the timer1 T1ON bit
   t1con.0=0;
}

void resumeTimer(){
   // turn on the timer1 T1ON bit
   t1con.0=1;
}

And in our timer interrupt:

void interrupt(void){
   
   // bit zero of pir1 is tmr1 overflow interrupt
   if(pir1.0==1){
      // clear the timer1 interrupt flag
      pir1.0=0;
      // preload timer1 to get the next interrupt to occur in a timely manner
      preloadTimer1();
      msCount++;   
      
      if(msCount>500){
         if(isReading==1){
            flushBuffer();
         }
         msCount=0;
      }         
   }
}


Now every time one of the data lines goes low, we wait for it to come back high, then add a one or a zero to the end of a stream of bits.

void checkforinput(){
   if(portc.2==0){
      // reset the timer if this is the start of a read
      if(isReading==0){msCount=0;}
      // set the flag to say we're reading some data
      isReading=1;
      //data1 has gone low: this is a one
      while(portc.2==0){
         // wait for the line to return high
         tmpBit=1;         
      }
      add_bit();
   }
   
   if(portc.1==0){   
      // reset the timer if this is the start of a read
      if(isReading==0){msCount=0;}
      // set the flag to say we're reading some data
      isReading=1;   
      //data1 has gone low: this is a one
      while(portc.1==0){
         // wait for the line to return high
         tmpBit=0;   
      }
      add_bit();
   }
   
}


To add a bit to the right-most end of the temporary value, we bit-shift all the data in the variable one place to the left, and simply OR the value (1 or zero) to the final result.
Here's an example:

Let's say we've already got the value 001101 in our buffer and we receive a one. First we bit-shift the value one place to the left. This gives us 011010. Now we OR this value with the number one (000001) and the result is 011011. This is the same as just tacking a one onto the end of the bit stream!

void add_bit(){
   tmp=tmp << 1;
   tmp=tmp | tmpBit;
   bitCount++;
   if(bitCount>=8){
      // this is a full byte
      // add it to the buffer
      porta.4=1;
      buffer[bufferPointer]=tmp;
      bufferPointer++;      
      tmp=0;
      bitCount=0;
   }   
}


So all that's left to do now is spit the data out so we can interrogate it:

void empty_buffer(){
   unsigned char i;
   for(i=0; i<=12; i++){
      buffer[i]=0;
   }
   bufferPointer=0;
}

void flushBuffer(){
   unsigned char i;
   
   // send out whatever's in the buffer
   // (first four bytes for a 26-bit protocol)
   isReading=0;
   UARTPrintLn("Buffer contents:");
   for(i=0; i<4; i++){
      tmp=buffer[i];
      UARTPrintNumber(tmp);
      UARTPrintLn(" ");
   }
   
   // reset the buffer for the next read
   tmp=0;
   bitCount=0;   
   empty_buffer();      
}

The reader we're working with has the following pinout:

power
ground
data0
data1
buzzer (low to activate)
led (low = green, high = blue)

So we wired the whole lot up to our PIC 16F1825 microcontroller, dumped some code onto it and read back what came out:


Amazingly, everything worked pretty much the first time out, with the results as follows:


Amazingly, the RFID reader could read a variety of RFID tags. We tried it with some of the phonics owl cards from an earlier BuildBrighton project, as well as the key fobs from the BuildBrighton door entry system, along with some other RFID tags from other people's various places of work. The RFID reader simply read them all and reported back the tag contents!

Now it'd be easy to call it a day and say we can read RFID tags successfully, but there's still the nagging doubt that we're not actually reading data, and just reporting a load of junk. What we needed was some way of confirming the data being read with a known value.
Luckily, the phonics owl cards (and a lot of RFID cards for that matter) have a Wiegand26 value printed onto them. If you have an RFID card with two sets of values, it's the second value (the one with the comma in it) that we're interested in:


What we need to do is compare our read-in value(s) against the Wiegand26 values printed onto the cards. So let's take a look at the actual bitstream from each of the card reads:

card no: 0006304068 096,12612
0000000048
0000000024
0000000162
0000000000
b00110000000110001010001000 (first 26 bits)

card no: 0012225140 186,35444
0000000093
0000000069
0000000058
0000000000
b01011101010001010011101000 (first 26 bits)

card no: 0006348080 096,56624
0000000176
0000000110
0000000152
0000000000
b10110000011011101001100000 (first 26 bits)

We've reported four bytes of data, because 26 bits is just over 3 bytes (3x8 = 24 bits).
In this case, all our fourth bytes are zero, but there's no guarantee that this will always be the case. So let's convert each decimal value to binary  and squash them all together (truncating once we get to 26 bits). Looking at it now, we could have created a single 32-bit value and simply bit-shifted the data 26 times, but then our code wouldn't work with 64-bit (or longer) cards. So by handling the data one byte at a time, we've got more work to do at this end (for validating) but it does mean we've a much more flexible system for future use.

Here's how the Wiegand26 protocol works, with 26 bits of data:



Let's look at the first set of values.
Splitting the byte stream up into groups of bits, we've got

0 01100000 0011000101000100 0

At the minute we're ignoring the parity bits, and are only interested in the "middle" section of the data stream. But already it's looking quite encouraging....

01100000 in decimal is 96
We've a couple of cards that begin with 096 followed by a comma.....
Taking the next group of 16-bits and converting to a single decimal gives us - 12612

That means we've correctly read the RFID data from the top-most card! Yay!
Comparing the values from the other cards, and we find we're accurately reading all the cards using the Wiegand26 protocol. We're not just reading junk, we're actually reading data.

With this in mind, we don't actually have to decode the bit-stream back to Wiegand values every time - we can simply report back the groups of bytes from the different cards, fobs and tags, confident that if we're reading them correctly (we are), the data from each will decode to the actual value on the card (if we need it to) but the parity bits will always give us the same groups of bytes for each card. As long as we have consistency each time a card is presented (i.e. we're not reading junk, we know we're reading the data correctly) we can simply compare the clumps of bytes to a look-up table to make the cards usable.

So to use this RFID reader for a door entry system, for example, it doesn't matter if we record a card as having the Wiegand26 value of 096,12612 or whether it's stored as 48,24,162,0 - each time the card with 096,12612 is presented to the card reader, we should expect to get back the bytes 48,24,162,0.
It's much easier to work with byte rather than splitting them up into bits, so we could just put these four bytes into our look-up table instead of converting back and forth between crazy 26-bit values!

In short, our first quick success for a long time.
After just a few hours of messing about, we've got a fully working RFID reading system.
In future posts, we'll look at writing our lookup table to an SD card and logging each time a card is swiped by writing a log file back to the card, making a completely PC-independent, embedded system!