Sunday, August 25, 2013

Main board with PIC 16F628















PIC 16F628 on the left, SN754410 on the right, LP2950 top right, ICSP top left, line sensor header bottom left, motor header bottom right

The main board of pennybot would consist of the following:

* PIC 16F628 microcontroller
* SN 754410 motor driver
* 5V power supply based around a LP2950
* connector pins for the motors, line sensor board, batteries, ICSP and IR sensor board

Lots to do and board space was limited so planning was needed.  A couple of hours shuffling components around and I had what I thought was a layout that would work.  Starting with the easy bits all the headers and IC chip sockets were soldered in first.  With that taking a couple of hours I started to remember how long it takes to put freeform circuit boards together from scratch.

The power supply was next.  This was also a major deviation from my original design.  Due to space and layout I moved the cutout switch in the circuit and deleted the filtering capacitor on the raw power line.  I also made some brain errors and kept making circuit hookups that meant the cutout switch didn't break the circuit.  Don't solder when tired!  I also had a false error in that when the cutoff switch was activated, I was still getting 5V.  However this was because at that stage I had lots of capacitors and no components to use up the stored charge.  The circuit was being cut but with nothing consuming power it takes awhile (minutes) for 5V to dissipate.  Always have at least a single led to drain out power.

Then it was a slow and steady task of connecting up everything else as per the schematic.  I did the Pic first so I could test the ICSP and make sure that was working before going further.  Whenever I'm wiring things up I like to do a small amount, test for short circuits, test functionality and then go onto the next item.  Trying to troubleshoot an entire board with everything soldered is just a recipe for tears.

For the connector to the IR board I used a 8 pin female header.  This header would double as the mounting socket too.  For the connection to power I decided to solder on the wires to the main board directly, rather than use a removable cable.  The connector would be on the chassis in the form of a female header recessed flush into the base plate.  To strengthen the connection I glued with two part epoxy the power wires on the main board.  I also epoxied the right angle header pins used for the motor and line sensor connections.  Anything that would be frequently connected and disconnected needed some extra support.  

For the most part things went well.  Another change that was made was the pull up resistor on pin RA4.  Originally this was 4.7K but that made the dual colour led very dim (with the red barely visible).  I dropped this to 1K.  I had never done this part of the design on the breadboard as I had used the dual colour leds as motor substitutes.  Always breadboard exactly what you are going to wire up.

Sunday, August 18, 2013

Line sensor board













Line sensor board

Now with a good and hopefully final chassis design it was time to pick up the soldering iron and start making things.  The first of the three boards to tackle was the line sensor board.  It would need to be very narrow to fit between the batteries and the front scoop.  The total parts list is small comprising of two leds, two IR phototransistors, 4 resistors and a 4 pin connector.  The four pin connector would be used for 5V power, ground and the two test point voltages from the sensors.  These voltages would be around 4V on the black surface and under 0.1V on the gloss white surface of the sumo ring edge.

For the four pin header instead of my usual molex connectors I used a standard right angle connector and the new headers I had recently purchased from Little Bird Electronics.  These headers are smaller than the molex ones but don't have a guide slot so can be inserted either way (and also the wrong way).

Once everything was soldered I drilled two holes mounting holes and tapped threads into the chassis.  All this drilling and tapping makes for a much better result but adds to the time.  Once a hole and drilled and tapped, then the bolt has to be cut to size as it can't come past the other side of the chassis base plate.  Much trial and error and test fits and cutting involved.  With the holes ready I used nylon spacers between the board and the chassis to get the position I wanted.

Lastly I made a 4 wire cable to connect to the main board.  Originally I started crimping a ribbon cable but then thought I was sure I already had a cable with a header on it in my salvage box.  Sure enough I did although the four header socket only had three wires.  Still saved some time and crimp pins.

After doing continuity test and shorts circuit tests I wired up the board to my bread board circuit and it worked fine.  Well it did until a further integration test showed the board and thus the sensors were too close to the ground.  The sensor voltages were only differing from 0.3V to 0.1v between the black surface and the white edge.  At the distance to the ground (under 3mm) even the flat black of the sumo ring was being detected.  This was solved by cutting the nylon spacers in half and reattaching the board.  With about 5mm distance between the board and the ring I was getting the behaviour and voltage differences  I wanted.  Next was onto the real work, the main board.

Wednesday, August 14, 2013

Pennybot chassis part 3













A chassis remade sans wheels

With the programming and breadboard design done, and the schematic finished it was time to start working on a board layout.  Not long into this process I worked out the chassis I had wasn't ideal.  It was only 8cm wide but 10cm long.  I didn't have room for a decent front scoop and the line sensors would be a very tight fit.  I was using a Tamiya base plate and I considered that I could simply rotate the board and easily make pennybot wider (out to 9.6cm) without having to change any of the holes I had drilled in the motor brackets which I really didn't want to have to make again.  Also the five AA batteries could now be mounted across the width of the chassis instead of along it so I would have more space at the front/rear and the centre of gravity would be all along the wheel axles.  I decided to cut down the motor brackets too so that they would only be the length of the motors themselves.  All this took a few hours on a Saturday.  The result was a wider pennybot with a better battery placement, but I had swapped one set of issues for another.  The Tamiya board is only 6cm wide, thus with the motors brackets and batteries there wasn't very much room (ie free 3mm holes in the board) on the front or rear to attach sensors, circuit boards, etc.  I could buy a bigger Tamiya board but had just done an order to Little Bird electronics and didn't want to pay postage again.  With a big sigh it was time to make a new chassis (number three) from scratch.

For my new chassis I wanted to make sure I remembered to do some key points.  I can get lost in problem fixing and forget the wider implications of design choices (and regret them later).  For all the mounting holes rather than drill straight through I would drill and tap 3mm threads.  This way I wouldn't need any bolts and wouldn't need space for the nuts.  That did mean I would have to cut down every bolt to size.  Bless the dremel.  I also wanted the base plate to be as big as I needed it.  Ie 10cm long and approx 8cm wide as the wheels and axles shafts would take the width to 10cm.  Looking through the scrap box I found an old plastic electronics project box which I never got round to using.  The box was curved on each side so cutting one half in the middle would give me a pre made scoop.  Also the dimensions fitted.  Some quick hacksaw and dremel work and I had a new base plate.  I put the axle shafts at the midway point and drilled and tapped the mounting holes.  I wasn't sure if the tapped screw holes into the plastic would be strong enough but they held.  Then the 5 AA batteries were placed underneath and things were looking good.


















Batteries and sneak peak at the sensor board

Next up would be the front line sensor board.

Monday, August 5, 2013

Schematic and DesignSpark review


After getting the breadboard version of pennybot working it was time to draw up the schematic.  I first roughed it out on paper and then looked at what software to draw it up properly.  Normally I would use TinyCad as I had for my previous designs.  However I had in mind that I might want to have a professional pcb made up so I needed something with the functionality to generate the gerber files, drill plots, etc.

RS Components now have free schematic and pcb layout software package called DesignSpark.  Currently it runs only on Windows.  What is great about the software is the very extensive parts library and the option to link directly into RS Component's online store and search for parts, then download the schematic diagram and pcb layout information of that part.  Note that not all the components in RS components store are currently have this setup.  Free to use but you need to register to save your files.

Designspark comes with a nice tutorial which covers the process of schematic design, creating a pcb from that schematic and finally generating a BOM, gerber files, design reports, etc.  All in all very nice.  The best feature for me was the ease of generating a pcb and being able to generate a 3D view all in the one tool.

So final opinion?  I think I will keep trying out Designspark and use it for all my schematics going forward.  I'm sure the part library will only grow over time and the pcb layout functionality is very nice.

While originally keen to have a pcb made the cost has put me off.  The usual American offerings (expresspcb) are out due to postage costs.  There are local options (iTead for example) but for a one off board I'm still looking at the $80+ mark.  Point to point soldering here I come... once I work out the board layout.