Friday, August 31, 2012

Inductorless wah pedal (coloursound)

Inbetween hacking CNC drilling machines, and almost as a respite from it, we've been busy preparing some guitar effects to show off at the up-and-coming Brighton Mini Maker Faire.
As well as a variation on the earlier Fuzz Factory pedal (made during a BuildBrighton workshop) we've been trying one of these inductorless wah pedal effects -




The final board size is really tiny. This is a perfect candidate for use in some kind of onboard electronics as well as a traditional pedal. Here it is alongside one of our Fuzz Factory boards (wah above, fuzz below):


When we've got it working, the idea is to replace the 100K linear pot on the wah effect (we'll leave the optional volume control out) with a digital potentiometer and use a microcontroller to set the wah intensity. This should allow us a couple of different options for activating the wah -

  • A wii controller would allow us to rock the guitar up and down, using the actual guitar body as the pedal rocker.
  • An ultrasound range finder would allow us to change the wah effect by strumming at different positions along the guitar body

In fact, once we've managed to hook up a microcontroller to control the wah effect, the possibilities are endless!

CNC Mold Machining for magnetic plates Resin Casting

Today i CNC machined the molds out of 12mm thick MDF for resin casting of magnetic plates.The tool used was 8mm end mill at 70inch/minute using 3mm per pass depth of cut. The mold machining took 35minutes on the CNC router. The cast resin will help bounding the magnet with the CS plates so that the magnets stay at high RPM.


 Hole drilling started on my home made CNC machine.

 and the rest of the pictures are below.
and the magnetic plate fitted exactly in the MDF mold as desired.

CNC drilling machine - testing everything

This is one of the most exciting blog posts for a while. After working on the CNC drilling machine as part of the BuildBrighton �50 CNC challenge for a few weeks, we're actually at the point of putting software, hardware, nc drill parsing and motor controller all together and actually trying to cut a PCB.

Actually, we don't have the drill part running yet - but this test shows actual movement, and we've used a laser dot in place of a drill head. But it shows a (sort-of) working CNC machine....


Instead of jumping in at the deep end and trying to draw a complex PCB (the printed pattern on the paper) we started off with a simple square. But as you can see from the video, we deliberately drew (and mounted) the square on an angle, to simulate mounting a PCB on the cutting bed on a wonky angle.

The software takes care of the rotation and follows the dots.
The first few seconds of the video show the machine being calibrated - the software prompts you to place the cutting head over a hole, record this location, then move the head to a second hole. This is what you see as the head travels diagonally across the board at the start (and the slight delay in the finer movement is us changing some parameters on the PC to reduce the jog step size).

The software then works out the cutting path (in this case, a simple down-across-up type pattern) and sets the motors spinning!

It's interesting to note that the cutting head doesn't necessarily follow the "lines" between the dots (if the dots were on the corners of a square for example), since it is a point-to-point machine, rather than a line follower. We'll try to demonstrate this more clearly in a later post.
But for now, sit back and enjoy our first CNC test.

It's not bad. It's not perfect - we need to take out any backlash in the gears (the motors themselves have quite a bit of "slop" on the spindle because of the internal gearing) to get greater accuracy but as an initial test - and particularly the handling of skewed boards - we're quite pleased with progress so far!

Next time we hope to actually cut (or maybe just draw felt-pen dots on) something.....

Thursday, August 30, 2012

4 armed robot can play the drums



Today, I just decided to share this video in a post instead of writing about it. Hope you enjoy the robot's tunes!

SOIC to DIP breakout board - SOIC14 to DIP14

After an earlier success with our CNC motor testing, we decided to wind down for the night by making a breakout board for our little digipots from Farnell.

Ideally we were after some 10k digital pots that could handle up to 9v (to try out some digital effects pedals) but the nearest we could find were 20k, up to 16v (most digital potentiometers run up to 5v and we've heard some bad things about using 5v digitpots with a 9v supply). 20k instead of 10k is fine, we'll just use half of the available range (so we'll have 128 steps instead of 256 to play with). All this would be fine, except the chips themselves are teeny-tiny little things! So we had to make up some breakout boards:

Soic to Dip 14pin


These we easy enough to toner transfer (using a laminator, not a household iron) but a bugger to etch! The traces are a tiny 0.25mm so over-etching/under-cutting was a bit of a problem. From four boards (we only made up half of the boards in the design) only one was good enough to use without any doctoring!


Using solder paste and a fine-tipped soldering iron (and some blue-tac to hold everything in place while soldering) we got this little chip stuck down and tested in a few minutes. Sadly it was then too late for any testing, so we'll just have to get this hooked up and tried out some time soon...

Wednesday, August 29, 2012

Wind Mill Fabrication Started

I have been collecting components  for few years for  fabrication of  1KW horizontal axis wind turbine diameter 12 foot. Last year i purchased 24 Magnets Rs.500Ea, a Car wheel hub for making the axial flux generator for the turbine.

Recently did some activities for making this wind turbine functional till the end of September 2012. Structure being fabricated in local market. I have made the CAD model of Wind turbine blades using NACA 2412 profile.

Here is the Magnetic plates of the Axial flux wind turbine.




Here is the average wind speed data and other parameters for Karachi.

New robotic targets used at shooting ranges



Currently most military shooting ranges use pop-up targets for soldiers to practice using their weapons. Later on in the future, this may change. We can already see some new target technology being developed and used today. Take Dynamic Robotics wheeled robots for example. They can be remote controlled around the range, and simulate moving hostile enemies. When it's not being controlled via remote control, it's executing a program that marks a path for it to follow. All these new methods make the shooting range a more realistic and better practicing environment for the soldiers. Thanks for reading and check out the video above to see the robot in the line of fire!

CNC motor testing via USB

There's an often held belief that you can't do CNCs without a parallel port on your PC and cleverly timed move instructions. That may have been the case back in the day, but we've had the nineties guys, USB is all the rage!

So we're building a USB CNC controller board.
We're quite lucky that these cheap little 5V 28BYJ48 steppers have already been stepped down. They're supposed to be 1/64 but inside they're geared down again. There are loads of places all over the internet which say that they're stepped down again by 1/32 - meaning you need 64 * 32 = 2048 steps for one complete revolution.

If that's the case, we should be able to get pretty precise movement, even with a massive gear/cog riding on the shaft, and without having to bother with the complexities of micro-stepping. There's only one way to be sure - and that's spin one around and count the steps!

In-keeping with our NC drill software, we're looking to build a USB controller which we can give a number of steps and have the motor(s) play out those steps. We've no idea at the minute how many steps we may need to move up to (depending on how many steps per revolution these motors actually need) so we've allowed for a 4-byte value to be sent to our trusty 18F2455 PIC microcontroller.

We're using (as ever) a generic HID device interface and sending data in 8 byte packets.
  • The first byte (byte zero) is our "command byte".
  • If the value is one, it's a command to set the x motor step count
  • If the value is two, it's a command to set the y motor step count
  • The second, third, fourth and fifth bytes make up our 4-byte value (0-2,147,483,647)
  • The sixth byte (byte 5) is a direction - one is anit-clockwise, zero (or any other value) clockwise.

After sending the x-axis step count (or the y) the controller board stops all motor activity (since if the motors are spinning when new values come in, the x- and y- axis will go out of alignment with each other, as the earlier axis will be ahead of the later one).

Only once the command byte 254 is sent do the motors actually spin up.
For as long as the x/y step count has a value greater than zero, the motor(s) are given a signal to move them onto the next step. The step-count value is decreased by one each time one of the axis motors steps. Once both motors have a step-count value of zero, a flag is set to tell the PC that the motors have stopped spinning and the head is now in it's correct position.

Here's a video of some early testing:


What's happening here? Thanks to the autofocus on our camera-phone it's not too clear - but if you squint and stand back from the monitor you might see:

Firstly, the command byte (7th byte) is given the value 1 (set x motor step count), along with the second byte (from the right) set to 16. Since our x count is a 4-byte value, we're setting it to 16*256 = 4096.
We repeat these values with the command byte set to value 2 (set y motor step count) then clear the buffer and send the command value 254 to get the motors spinning.

Giving our control board a value of 4096 makes the motor complete one full rotation.
So there we have it. Our stepper motor has a 1/64 step angle, geared down, not by 1/32 as some other forums suggest, but a full 1/64 again. 64 * 64 = 4096 so this is the number of steps required for a full rotation.

The video then skips back to a blurry laptop screen, where we enter the same values, but this time setting byte 4 to 1. This is the direction byte. When this is set to one, the motor spins in the opposite direction.

All in all, we've had quite a successful evening - we've got both axis motors spinning from a custom-built PIC-based USB (HID device) board and some software which we can talk to the board with and get predictable results. Now we just need to remember how to work with Timer1 to create a 20m/s interrupt on the PIC and we can use this to send servo commands for the z-axis (drill up, drill down and motor speed).

Tomorrow is another BuildBrighton open evening.
There's even a slim chance that after the beers and pizza, we might actually get something working......

NC drill file format - origin is bottom left

So far we've been working with screen co-ordinates, with the origin (0,0) at the top left. But when reading/parsing NC drill files, the origin seems to follow cartesian co-ordinates with the origin in the bottom left (like you get when drawing a graph on a piece of paper).

So a quick hack later and our software now starts with the dot nearest the bottom-left-hand corner of the board


It then prompts to move the drilling head to the top-right-hand corner hole


And calculates a cutting path from the current hole (the top-right) back, not necessarily to the origin, but in a way that passes through each hole.


When the cutting head reaches point A, the general rule to follow is "move to the nearest undrilled dot". If we were doing this job manually, we'd probably go from point A to point E, continue working up the board, then move to the left and work our way back down again.

But that doesn't actually follow the "move to the nearest dot" rule. From point A, the nearest dot is point B, so that's the path that's taken. Now at point B, point E is still further away than one of the other, non-drilled, points. So the head moves to point C instead. When it gets to point D, however, the nearest undrilled hole is point E, so the cutting head moves there and continues in a more predictable pattern.

We could probably "iron out" these peculiar movement patterns by looking ahead more than one hole at a time, but that's an awful lot of work for something that we've not even tested yet! For now, we'll live with a few quirks until we've seen it actually drill a PCB board!


Tuesday, August 28, 2012

The robotic air purifier, airs new best friend



When we think of air purifiers we tend to think of motionless machines with vents. However, with new robotics technology, air purifiers can now be mobile and automated machines. Let's take the Moneual Rydis H800 Robot for example. It's able to move around its environment using a range of motors and sensors. The sensors help it detect objects, while the motors take care of getting around. It's air purifying technology is basically the same as opposed to any other air purifying machine, except this one can clean more air because it can move around. Charging is a breeze with this robot too. Simply plug the bot into it's charger for two and a half hours, an you get a four hour running time in return. Thanks for reading and check out the video above to see this robot being showed off at the CES 2012!

The Makerbot 1/6th Scale Electric Car Model Is Completed


I am amazed that this project is already completed this morning.  No major problems and the assembly went together without a hitch.  Not to say that 126  hours of designing this project did not help with all of this coming together correctly. Add to this another 150 hours of making and assembling  parts.  This brings the grand total of hours in this project to 276 hours. Whew! A lot of fun to figure out this design and see it all come together though.  Here are are the final photos of the model.


This photo is the two part assembly for the head rests for the seats.  The two holes in the bottom of the red outer part will receive the aluminum mounting pins for the headrest to be positioned on to the seats.


Here the seat back parts are laid out to show you the assembly.  No glue was needed in the assembly of any of the parts of the seat.  All of the parts snapped right into place and are tight enough so gluing them together simply was not needed.



The seat backs are completed with the headrests and white inserts mounted.  It really makes the seats stand out with the contrasting colors.


This photo is of one of the seat bottoms.  These two parts alone for one seat took a little over six hours to print using the Makerbot 3D printer. It was a real nail biter while printing the last seat bottom with the red plastic.  I had very little left on the spool and was afraid that I would run out of plastic before it completed.  I had more red plastic on hand but it was not the same shade of red.  Luckily it printed out just fine and I was able to complete the assembly with no problems.




 Here one of the seats is completely assembled ready for mounting in the model car.  An aluminum pin is used in the base of the seat to allow for it to pivot forward as a real seat would in a car.  Again no glue was needed in any part of this assembly.  My efforts in the designing of this model paid off with the fit up of all the parts and the completed look.




These three photos are some good shots of the model by itself and a figure in the drivers seat.  



These last two photos are of the belt drive system that ties the electric motor to the rear wheel.  The belt was printed on the Makerbot 3D printer and is not flexible. The pulleys are made in two parts so that the belt could be mounted onto the motor and the drive system.  It all turned out very well. 



One last photo.  I think the underside of the model looks just as good as the top side.  As you can see, lots of machine screws to hold it all together.  Pretty though don't you think?

  The next step will be to possibly build a fiberglass body for the model.  I have a couple ideas as to how this can be done but as yet have not started work on it.  I think I will sit back and admire my efforts for now and do some thinking on the next phase of this project.  I hope you've enjoyed the photos and info that I've passed on to you over the past month or so.  If I get the body figured out I will post that as well and keep you up to date.  Either way I think my efforts on this project have once again turned out very well so it's all good.

CNC drilling software development

Ever used Mach3 for your CNC machine? Or RouteOut? Or one of those other CNC applications with a myriad of settings so that it can support any type of CNC machine?

If you've ever bought a second-hand CNC machine off eBay or tried to build one from salvaged parts, you know how difficult it is to work out (or guess at) the settings to make it work. Sometimes you end up shoving numbers in and keep tweaking until the actual output sort-of matches the drawing files you give it.

Well not any more....

Not only has Robot Steve redefined simple CNC design, with his awesome push-fit chassis, but this custom-written software is designed to do away with CNC-hardware-related headaches. Simply load a file, manually move to head to a start position (origin), move the head to a second position, then hit go.

At the minute the software can read NC drill files.
Here's the app reading a drill file generated from an Eagle PCB


After calculating the scale and rotation for each point (at the minute we're just working on scale, having just read in an nc drill file) the software runs through each point, creating a "cutting path"


At first, something appears to have gone wrong down the left-hand side. But on further inspection, the software is actually following the simple rule "move to the nearest hole that hasn't been drilled yet".
Because we set the origin to the top-left-most hole then travel to the bottom-right-most hole, the cutting head  should be at the bottom right of our PCB.
From here, it starts with the rule "move to the nearest point" then marks it as "drilled" when it gets there.
Repeating for only holes that haven't been drilled creates the cutting path above.


Monday, August 27, 2012

New patrol robot to be used by Austin, Texas police



Police in Austin, Texas have obtained a new patrol robot. It's small, durable, and can be sent into houses to check for suspects and hostile intruders. The robot is named "ARA Pointman." The police of Austin also have the intention of using this robot to patrol the streets. The robot itself has a camera, four wheels, a signal receiver, and strong motors. It's camera is used so the user can see the robot's environment. The motors help the robot push open doors and climb stairs with ease. It's remote controlled so the police have complete control of this tough little bot. Thanks for reading and check out the video above to see it in action!

CNC drilling machine first test (x- and z- axis)

After a successful couple of hours at the nerd cupboard, we managed to get Steve's CNC design working in two axes. The test board simply uses buttons to turn a connected stepper motor clockwise and anticlockwise (we've yet to finish our controller software) but proves the concept of moving a drilling head across a gantry and performing a plunge-and-drill operation.



Exhilarating stuff!
We're particularly pleased with the dual-servo control: the first servo is actually an RC motor controller and sets the drilling spindle spinning. Then the z-axis servo plunges the drill head, pauses, and retracts the head, before stopping the drill spindle. (In code we "detach" the z-axis servo so that it is only powered for as long as is required.)

Surely it's only a matter of time before the y-axis (cutting bed) is in place and we're ready to try out some custom software to drill our first board!

CNC drilling software (open source?)

We're still not 100% au fait with the requirements for open source, GNU licences and all that kind of stuff - does everything in the chain have to be open source? Can we use our preferred PIC microcontrollers to make a USB device when the Microchip software and USB libraries are not open source? Does it really matter?

We're blundering ahead with our software, but have hit upon two potential problems - and hopefully workable answers to them:

The first is converting the NC drill file units (mm or inches) into steps on our CNC machine.
Since a big part of our design process is to make the machine easily repeated and built from spare parts (salvaged printers are a great place to get hold of cheap steppers) we're trying to work from the assumption that the end user knows nothing (or very little) about their hardware.

Rather than have the user enter all kinds of values to describe their hardware (or worse still, guess at them) we thought we'd have a simple manual calibration routine at the start of the software. Simply put, the user loads their pre-printed/etched PCB onto the cutting bed and moves the drill head above the top-left-most hole (the software will highlight one if there are multiple possibilities). This will form the origin (co-ordinate point 0,0) for our cutting routine(s).

The software will then find the bottom-right-most hole (furthest away from the origin) in the drill file, highlight it and prompt the user to move the drill head (maybe using the computer keyboard's arrow keys or similar) above this second hole. Using these two co-ordinates we can calculate two vitally important things: scale and rotation.

In the NC drill file we have co-ordinates for every point on the board. Using pythagoras theorum (a^2 = b^2 + c^2) we can calculate the distance R1 between the top-left and bottom-right points. On our actual PCB, this represents the same distances between the same two points. The only difference is the units used to measure this distance.

In the same way the same distance can be described in imperial (inches) and metric (millimetres) by multiplying one set of values by a constant, we can do the same to convert inches or millimetres in the NC drill files into steps on the CNC machine. Let's pretend both images (above) are exactly the same size. Let's say the distance R1 is measured in millimetres, but we want the same distance R2 in inches. We know that 1 inch = 2.54cm and 1cm=10mm. So we can easily compare R1 (mm) with R2 (inches) by multiplying R2 by 25.4 (or dividing R1 by 2.54 to get R2, the same distance in inches).

We don't know what this constant value is to convert our NC drill measurements (mm/inches) into number of steps, but we can calculate R2, the distance the drill head travelled between two points, in terms of steps. Knowing the value of R1 (in, say, mm) and the distance of R2 in steps allows us to calculate the scale between the two. Scale = R2/R1

The great thing about using the first hole as our origin point is that it doesn't actually matter at this stage whether or not the PCB board on the CNC machine is dead square. If the PCB board were not aligned exactly squarely, the difference between these two distances would be exactly the same, since they both describe the radius of a circle with it's centre point at the origin

 So now we've worked out the scale (the constant to multiply our NC drill hole positions by to convert distances in mm/inches into number of stepper motor steps) we now need to work out the rotation of the PCB on the cutting bed

Even if the PCB on the cutting bed were badly skewed, the ratio (scaling) between R1 and R2 would be the same. We know the location of the bottom-right-most hole from the origin according to our NC drill file, and we know the distance of the same hole on the actual PCB in terms of number of steps travelled in both the x and y axis. What we need to do is calculate by how much the PCB has been rotated.

One way to do this is to calculate the angle (from the origin) of the diagonal in the NC drill file (the larger of the three angles above) then calculate the angle from the origin of the current position of the drilling head.
Since we know the position of the cutting head from the origin in terms of steps (we count the number of steps moved in both the x- and y- axes) we can calculate this angle (the green diagonal) quite easily.

Using simple trigonometry:



If we rotate the bottom triangle 90 degrees clockwise, we can see that we've described a right angled triangle, where the adjacent side is the number of steps travelled in the y axis, the opposite side is the number of steps travelled in the x-axis, so tanA = stepsY / stepsX

From here we can calculate the angle of the position of the drilling head from the origin.
Using the same principles, and with the values from the NC drill files, we can calculate the angle between the bottom-right-most hole and the origin (top-right-most hole). The opposite side of this triangle is the difference between the x co-ordinates of the two holes and the adjacent side is the difference between the y co-ordinates of the two holes, so tanA = (y1-y2) / (x1-x2)

Knowing these two angles, we can subtract one from the other to calculate by how much the PCB has been rotated on the cutting bed. Now we know the scaling AND rotation, we can simply apply these to every point in the NC drill file, to get the number of steps needed to move in both the x- and y- directions to reach in point on the actual PCB on the cutting bed.

Apply rotation to a co-ordinate point can be acheived by using a rotation matrix:



What this scary looking equation boils down to is - the coordinates (x',y') of the point (x,y) after rotation are:
x' = (x * cosA) - (y * sinA)
y' = (x * sinA) + (y * cosA)

Given that we know x and y (from the NC drill file) and we've calculated the rotation of the PCB on the cutting bed, we can work out:

xSteps = ( (x * cosA) - (y * sinA) ) * scaling
ySteps = ( (x * sinA) + (y * cosA) ) * scaling

where x and y are the co-ordinates given in the NC drill file.
And all without knowing how many teeth are on the CNC belt, how many steps the motors turn per full revolution or any of that other junk, nor without any headaches lining up the PCB to get it absolutely square and accurate on the cutting bed.

In theory, this provides a really nice and easy to use - if not entirely easy to understand for everyone - way of drilling every hole on the PCB, from an NC drill file, given the user has manually located two holes on the board.

Software design requirements for CNC drill machine

Robot Steve's late entry into the BuildBrighton CNC Drilling Machine competition has in some ways spurred us on and in others caused things to grind to a halt. In some ways, seeing such a simple, usable design has us wondering whether it's worth continuing with our little laser-cut caddy. The main difference between our approach and Matt's CNC monster was simply scale and cost:

Matt came up with a solid (though possibly over-engineered) design using linear bearings, rods and bolts by the bucketload, expensive steppers and belts - basically blowing the budget to create the best CNC type machine he could manage.
We stuck to the cheap-as-possible, easy to replicate route, but possibly at the cost of accuracy (we still don't know if our design will actually create a working, functional CNC machine!)

Steve's design fits nicely in the middle.
With 3d printed parts, built from a 3d CAD-based design, he can see his prototype working (virtually) before cutting or casting a single piece of plastic! Yet with minimum part count and easy push-fit construction, there's no need to worry about bolting plastics edge-to-edge and trying to get everything square. It's a great design.

So is it worth continuing with a slightly shonky design, knowing that eventually we'll probably adopt another in the near future? We'll leave that question, and spend our time constructively on the one aspect that no-one seems to have addressed just yet: software.

The budget allows for the complete build - including driver board/electronics and controlling software.
The easiest approach would be to get a MACH3 compatible driver board, hook up the steppers and run everything through some milling software like MACH3. But this is an expensive way of going about things, so we reckon custom software is the way to go.

Also, we're not drilling or milling blank material. Our PCBs with either already be etched, or have tracks and traces already marked on them, ready for etching. So before we start any drilling, we have to make sure our boards are perfectly lined up to begin with.

In something like mach3 we could do this by moving the drill head to a known position and placing the board underneath it, then moving the head to a second (known) position and rotating the board until this second point fits under the head. With the board in place, we could lock it down and start the cnc running.
MACH3 also has a myriad of settings, belt-tooth size, leadscrew adjustment values - all things which make it quite complicated and daunting to the untrained user. For our software we want:


  • Minimum settings screens - we don't care how big your stepper motor is, the tooth pitch, degrees per step and so on. The software should work with a wide range of machines without any complicated maths/physics calculations!


  • Auto-alignment - placing a PCB exactly squarely on the cutting bed is going to be difficult enough. Cutting the sides square is hard - knowing that you've placed one edge exactly squarely can be hit-and-miss, and if your edges aren't exactly true and straight, getting the whole thing to line up is almost impossible!


  • Auto-scaling for different measurement units - NC drill files are commonly described in imperial (inches) but there is software that uses (and an NC drill command for using) metric (millimetres). The software should be able to handle mm and inches without the need to re-calculate the drill position data in the NC drill file.

We're not worried about making everything open source, complying with GNU licences and all that - we're just looking to create some software that just works (in Windows at least) using whichever tools do the job. Of course, details of how the software is created will be explained, should anyone wish to re-create their own, but we're not ruling out any specific technologies just because it's not "open source" or GNU-a-like or anything like that!

Sunday, August 26, 2012

Late entry to the BuildBrighton CNC drill machine challenge

It's a bit late - though not as late as our actual machines are for being ready (they should have been drilling PCBs in time for last August's BuildBrighton Guitar Stompbox Workshop) - but we've had an exciting last-minute entry from Robot Steve.


Steve's taken the simplicity of our design but coupled it with the super-low cost option (and ease of construction) of a 3D printed solution. We think it looks amazing.


Using a servo for the drill plunge, this design keeps things about as simple as they possibly can be. The rails are structural as well as functional (carrying the carriage for the x/z axes) and the tiny steppers are mounted directly onto the moving parts. Rather than mess about with linear bearings, Steve has gone for the simpler (and cheaper) design used in many inkjet printers - greased rails and precision cut nylon blocks sliding along them!


We think the best thing about this design is the relatively low part count. Once you take away the cutting bed (a piece of cheap acrylic or some mdf) and the rails, you're left with a handful of cheaply produced 3d printed parts.


Steve sent over some early prototype photos. It actually looks better in real life!


Thursday, August 23, 2012

CNC linear rails testing

Down at BuildBrighton tonight, fellow PIC-programmers were in short supply, so with reluctance we had to crack open an Arduino Duemilanove and learn some crazy Arduino coding. It turns out it's not as difficult as it looks (but it does still make you feel a bit dirty).

To get things working, we just wanted to be able to turn a stepper motor clockwise and anti-clockwise. Here's the code we came up with:



int state=0;
int dir=0;

void setup(){
     pinMode(1, INPUT_PULLUP);
     pinMode(2, INPUT_PULLUP);
     pinMode(3, OUTPUT);
     pinMode(4, OUTPUT);
     pinMode(5, OUTPUT);
     pinMode(6, OUTPUT);

}

void loop(){
     //read the pushbutton value into a variable
     int inputVal1 = digitalRead(1);
     int inputVal2 = digitalRead(2);
     
     // Keep in mind the pullup means the pushbutton's
     // logic is inverted. It goes HIGH when it's open,
     // and LOW when it's pressed.
     if (inputVal1 == LOW) {
          // turn the motor clockwise
          dir=1;
     }else if(inputVal2 == LOW) {
          // turn the motor anticlockwise
          dir=-1;
     }else{
      // stop turning the motor
      dir=0;
     }
     
     if(dir!=0){
               // move the motor
               state+=dir;
               if(state<0){state=7;}
               if(state>7){state=0;}
               
               switch(state){
                     case 0:
                     // energise coil A
                     digitalWrite(3, HIGH);
                     digitalWrite(4, LOW);
                     digitalWrite(5, LOW);
                     digitalWrite(6, LOW);
                    
                     break;
                    
                     case 1:
                     // energise coils A+B
                     digitalWrite(3, HIGH);
                     digitalWrite(4, HIGH);
                     digitalWrite(5, LOW);
                     digitalWrite(6, LOW);
                     break;
                    
                     case 2:
                     // energise coil B
                     digitalWrite(3, LOW);
                     digitalWrite(4, HIGH);
                     digitalWrite(5, LOW);
                     digitalWrite(6, LOW);
                     break;
                    
                     case 3:
                     // energise coils B+C
                     digitalWrite(3, LOW);
                     digitalWrite(4, HIGH);
                     digitalWrite(5, HIGH);
                     digitalWrite(6, LOW);
                     break;
                    
                     case 4:
                     // energise coil C
                     digitalWrite(3, LOW);
                     digitalWrite(4, LOW);
                     digitalWrite(5, HIGH);
                     digitalWrite(6, LOW);
                     break;
                    
                     case 5:
                     // energise coils C+D
                     digitalWrite(3, LOW);
                     digitalWrite(4, LOW);
                     digitalWrite(5, HIGH);
                     digitalWrite(6, HIGH);
                     break;
                    
                     case 6:
                     // energise coil D
                     digitalWrite(3, LOW);
                     digitalWrite(4, LOW);
                     digitalWrite(5, LOW);
                     digitalWrite(6, HIGH);
                     break;
                                             
                     case 7:
                     // energise coils D+A
                     digitalWrite(3, HIGH);
                     digitalWrite(4, LOW);
                     digitalWrite(5, LOW);
                     digitalWrite(6, HIGH);
                     break;
                    
               }
               
               delay(1);
     }
     
}




It's a simple state machine - when the motor is turning clockwise, we energise the coils in sequence 1...2...3... etc, when running anti-clockwise we go 7...6...5.... etc

Doing this allows us to quickly and easily make the motor run by pulling an input pin low (pull-up resistors mean the inputs are always high with no input on them).


Here's a video showing the motor in action:

Battery Packs Installed In Makerbot Electric Car Model

The past couple of days have brought another jump forward in my efforts to complete the 1/6th scale Makerbot electric car model along with a marathon session of printing parts.  Here's what I've managed to get done.


With the addition of the battery box assemblies to the model it is getting to look more complete and definitely more colorful.  Total number of hours to print the parts for the battery box assemblies comes up to just five minutes short of 22 hours.  Yesterday being the longest day with the printing of the battery box assembly that mounts behind the seats of the model.  The box alone took seven hours to print.  I was just happy that the print did not fail on me and I would have had to start it over again.  But with the Makerbot being what it is I once again am pleased to have set a new personal record for print times with this part alone.  


The smallest of the battery box assemblies is this one which would be the size of a regular car battery if it was in a real car.  This is mounted to the motor mount assembly and all the machine screws are hidden inside the battery box itself so that I could get a nice clean installation. 


Just ahead of the motor and what will be behind the seats once they are printed and installed is the main battery box. The hardware to mount this box is fed up through the floor of the model into the base of the assembly to hold it in place.  This assembly represents 17 lithium batteries housed in a battery box container.  It is to scale so it is interesting to see how little space it actually takes up considering that the other battery is the size of a regular car battery.  All the battery posts were painted silver to give them just a little bit more detail in the model. 


This view of the model show you the two front battery box assemblies.  The real puzzle to solve in the installation of the assemblies was how to mount them and still allow room for the front rack and pinion steering to still work.  This was accomplished with mounting brackets on the bottom of each assembly that holds them in place to the floor of the model.  The front battery box assembly will need to be removed once the steering column is installed with the gear to mate up with the rack on the steering assembly.  There is not a lot of room to get your hands into the model with the front battery box in the way.  It is just simpler to remove it until all the other components have been put into place.


This view shows you a good perspective as to the component layout in the model.  The blue box just ahead of the dash is the motor controller for the electrical system.  Needless to say that if this was built for real with a fiberglass body it would need access panels to get at the electrical system and batteries.  Most likely the front of the vehicle would have a hood that opened up of even have the entire front end tip forward for easy access.  The batteries behind the seats are pretty much in the open and would only have to have a cover over them to protect the batteries and passengers. It would also  allow additional cargo area behind the seats.


The next step in the assembly will be the printing of the seats.  This will take me a couple of days to get done along with a few smaller parts that will be needed to complete this portion of the model.  Once I am happy with all of this I will look into making a fiberglass body to complete the model.  This all depends on what it will take to put that part of the assembly together.  Even if I stop at this point and don't build a body, the Makerbot electric car model is still quite impressive to see and has been a lot of fun to create.  Like everything else that I work on here at the Tinker's Workshop. That should be the motto of  my site.... "If it isn't fun then why bother".