Laser cutting in the UK

10 September, 2009

Sometimes I wish I lived in the states because there is a service for everything and everyone. In particular I’m thinking about how easy laser cutting (and other forms of machining) is for tinkerers like me and my readers.
Has anyone had any experience of laser cutting services in the UK? Please post in the comments if you had a good/bad experience, or if you’re seeking a service.


I can’t machine for toffee

24 February, 2009

I had a go at doing some mechanical work at the weekend. I tried to machine the acrylic I bought and create some kind of joint using a stepper motor. I have to say that I failed rather miserably!

I tried scoring and snapping the stuff only to find that a cut length of anything longer than about 10cm was impossible! A hacksaw proved much better but I really don’t have the benches, vice, etc to make a decent job of it. I’m now thinking about getting something made up. The problem with that is that I’m finding it difficult to start designing when faced with a blank screen on a CAD package. It is holding the robot arm project up though.

21022009130

In other news…

I purchased some bits off ebay. Firstly I bought some Picaxe compatible kits to help me prototype. Some of these are Picaxe-08 kits so I shall be making some compact stepper motor controls shortly. They were from rkeducation (they also have a web site).

Secondly, inspired by a kite aerial photography (and some RC) videos I decided to buy some radio gear. I now have a 6 channel transmitter and receiver which work well with the servos I have. I see a few more projects coming up…


Recommended Robotic Books

29 January, 2009

Here’s a few of my favourite books I refer to on a regular basis. If you do intend to buy one of them please consider using the links provided to support my robot expenses!

My Robot Books

Programming and customising the PICAXE Microcontroller, David Lincoln, David Lincoln (More Info)

This is a fantastic book! Really accessible, plenty of examples, and loads of help with coding. I’m technical but not a hard-core programmer so this book works well as both a teaching aid and also a reference book. It also covers all the PICAXE chips (8 to 40-pin), how to connect them up, program them, and use their special functions. This is well worth the (relatively small amount of) cash. I have found a couple of times now (and BasicX24: I’m looking at you!) that you buy some hardware but the documentation (or software or programming hardware) is really poor or expensive. Not the case here – If you’re planning on developing for PICAXE chips then More info

Mobile Robotics: Inspiration to Implementation, Anita Flynn et al. (More Info)

This was a favourite book of mine for a long time and is considered to be one of the definitive ‘bibles’ for robotics hobbyists. It’s getting a little dated with regard to the microprocessor of choice (an 68HC…) – at least with the amazing crop of hobbyist chips available these days (Picaxe, Stamp, Arduino, PICmicros, Amtel AVR, OOPic, etc). That was what put me off attacking the electronics side of the main project discussed inside. Saying that the book is great in two respects: 1) It’s inspirational and well written, and 2) It discusses many of the details of building a mobile robot in depth. These include motor choice, battery choice, and sensors. The book is crying out for a new addition but I think it’s still worth a look if you’re getting into the field as a hobby, particularly at the current price.

Robot Builder’s Bonanza (ed 1, 2, and 3!), Gordon McComb et al. (More info)

I’ve incredibly got two editions of this book and there exists a 3rd edition already. Whilst I can’t comment on the latest I’d like to say a few words on the series which will hopefully inform anyone considering a purchase.
It sells itself as a practical how-to guide and I have to say that in some respects it’s smack on but in others it’s lacking somewhat. As with Mobile Robotics it discusses sensors, batteries, and motors. The 2nd edition even discusses choice of microprocessor and includes the Stamp, the BasicX, and the OOPic. I’m sure the 3rd edition will include some of the more recent trends such as the Arduino too. My main criticism of the book is the mechanical how-tos which take up a lot of the space. These attempt to show you how to build robot arms, etc., and how to deal with gears, chains, and sprockets. They ALL use aluminium section and frankly look ropey. I’m sure that they do what they’re supposed to but I consider these sections the least useful. It does tell you how to work with different materials (plastics, wood, etc) but I would loved to see some plastic section builds of the kind I see so many of on the web.
To be fair though it does have some well thought out sections and it’s a good general reference on electronics, interfacing with microcontrollers and PCs, and plenty of programming examples. Although I have been a little critical I still think it’s a good purchase (particularly because of the price – in fact I think I’ll buy edition 3 now! Done!…).

Update: The third edition has arrived! The first thing that struck me is just how big it is compared to the other editions. In fact I think each edition is about 1.5x bigger than its predecessor! There’s some interesting bits on toy hacking, some more recent electronics bits (like the use of accelerometers), etc. Edition 2 talked about a range of microcontrollers – this edition scales back to talk about the Basic Stamp (2) only. I can see why they chose to, they can go into more detail and not worry about being experts in everything, but it’s a bit of a shame. Worth the purchase though…


Bipolar stepper motor control with Picaxe and L293D chips

28 January, 2009

I’ve now got a schematic and program for running a bipolar stepper motor via a serial interface (just as for the unipolar case). This is important for the robot arm cause because two of the three steppers will be of the bipolar kind.
Where driving the unipolar stepper required only current ‘pushing’ (ie all in the same direction through a common ground), a bipolar motor requires current to flow in both directions. The following image shows the difference.

steppers

In theory the control of this is very easy with two half H-bridges (essentially four transistors) controlled by several Picaxe output lines). The basic concept is shown below.

image

(Source: http://commons.wikimedia.org/wiki/File:Bipolar_Stepper_Motor_H-bridge.png)

The L293D chip has the requisite transistors and a nice interface (with lots of extra features that my DIY skills couldn’t match). I’ve also used it in the mobile robot experiment to control the direction of 2 motors.

As with anything like this though, one needs to think through the sequence and outline a table of output values corresponding to the steps, as below.

Direction Coil 1 Coil 2
N + 0
NE + +
E 0 +
SE +
S 0
SW
W 0
NW +

At first I was using 6 output lines (!) – 4 for each of the transistor inputs and 2 for enabling or disabling the L293D’s 2 ‘half h-bridges’. In this configuration it could be reduced to 4 by using an external NOT gate (because 2 of the controls are always the opposite of another 2). Such a scheme would look like this:

Direction EN1-2 1A 2A EN3-4 3A 4A
N 1 1 0 0 0 0
NE 1 1 0 1 1 0
E 0 0 0 1 1 0
SE 1 0 1 1 1 0
S 1 0 1 0 0 0
SW 1 0 1 1 0 1
W 0 0 0 1 0 1
NW 1 1 0 1 0 1

But while trouble shooting this (I had swapped LSBs with MSBs so it probably did work after all!) I came across a site tying the enable lines Hi and using 4 control lines. At the poles one of the loops must have zero current flowing through it. In the above scheme this is done by setting the enable line Low and ignoring the A values. In the 4 line scheme this can be achieved by sending the same control output to both ends of the loop (ie the potential difference across the coil is 0). Then the table looks like this (including half stepping):

Direction 1A 2A 3A 4A
N 1 0 0 0
NE 1 0 1 0
E 0 0 1 0
SE 0 1 1 0
S 0 1 0 0
SW 0 1 0 1
W 0 0 0 1
NW 1 0 0 1

That makes the schematic as follows:

bipolar_schematic

…and the program as follows. Note that this program is designed to wait until it detects a serial input on input 0 (pin 17) in the form of three bytes: The first is a qualifier – 85 uniquely identifies this stepper motor – the second is the number of steps – 0-255, and the third is the speed – 0-127 is backwards, 128-255 is forwards.

'Serial driven stepper motor by DMT195

symbol posrotor=b0
symbol numturns=b2
symbol speeddir=b7
symbol direc=b8
symbol pulsegap=b3
symbol counter=b4
symbol modrotor=b1
symbol outbyte=b5

posrotor = 1 'set starting position

start:    'main sequence - wait for command then move the motor
 numturns=0   'sets a default number of turns
 high 7    'reset ready flag
 serin 0,T2400,(85),numturns,speeddir 'get serial data
 gosub getspeed   'get the direction and speed
 gosub move       'perform number of steps
goto start

getspeed:
 if speeddir>128 then  'find direction and store in direc (1 is +ve, 0 is -ve)
  direc=1
 else
  direc=0
 endif
 speeddir=speeddir//128
 'gets the speed 0-127 negative, 128-255 positive (higher =faster)
 pulsegap=264-2*speeddir
return

move:
 for counter=1 to numturns
  pause pulsegap      'wait before moving again (set by speed)
 if direc=1 then
  posrotor=posrotor+1 'increase/decrease the step by one
 else
  posrotor=posrotor-1
 endif
   gosub moverotor  'set the rotor position for this step
 next counter
return

moverotor:
 modrotor=posrotor//8    'find out where the rotor arm should be (1 of 8 positions)
 lookup modrotor, (0x08,0x0A,0x02,0x06,0x04,0x05,0x01,0x09), outbuyte
 '(%00001000,%00001010,%00000010,%00000110,%00000100,%00000101,%00000001,%00001001) is (0x08,0x0A,0x02,0x06,0x04,0x05,0x01,0x09) in hex
 'looks up the step from the sequence and applies it to the output pins
 pins=outbyte
return

Please leave comments if you’ve found this useful or if you think I’ve made a mistake.

I have something to say about accessing all these devices through a single serial port too but that will have to wait for one or two more tests…

Update: Of course this can be done with a PICAXE 08(M)  with the 4 outputs and 1 serial input to spare. The pinouts would have to change as would the respective program. If there’s enough demand for me to document this I will. Let me know in the comments. Consider using this little board from Technobots.

Update 2: I’ve reduced the code length by using a lookup table instead of the select/case structure. I’ve also use hex to reduce the size of that line (but included the binary values in a comment below for those that are interested).


Quick screenshots of the PHP-to-Servo file running

23 January, 2009

The client sees the following when entering the servo control test page:

image

After entering some data the output of the Python script is added to the top of the page:

image

It’s all a bit rough around the edges but it works for now…


Edit my scripts to do home automation

20 January, 2009

I just read about a new product which I can’t resist saying will work really well with the kind of things I’ve been doing here with servo controllers! It’s a servo controlled switch!

Check it out! (via Hack-a-day and Makezine feeds)

image


Running the Python script over PHP5

19 January, 2009

It took some time to get this working so I’m quite proud that it does actually work now. There were a couple of subtleties that needed ironing out and I want to share them for those trying to do something similar. Here’s the code and then I’ll note a few lines in detail after…

<html>
<head>
<title>A first go at web control...</title>
</head>
<body>
<?php
if ( isset( $_POST['angle'] ) )
{
#Pass the variables and remove any system characters
$angle=escapeshellcmd($_POST['angle']);
$servo=escapeshellcmd($_POST['servo']);
$output=system("/usr/bin/python2.5 /var/www/cgi-bin/controlsscii.py pos  $servo $angle");
}
?>
<form action="page1.php" method="POST">
Input area:<p>
Servo number (0-7 limited resolution, 8-15 full sweep):
<input type="text" name="servo"><p>
Value (0-180 degrees):
<input type="text" name="angle"><p>
<input type="SUBMIT" name="submit" value="Try it!">
</form>
</body>
</html>

So firstly I had an issue with PHP going from v4->v5. Before the change variables were passed from forms with method=”POST” directly into variables. Now one has to access the $_POST environmental variable. escapeshellcmd() is used to ensure arbitrary scripts can’t be run.

$angle=escapeshellcmd($_POST['angle']);

The main problem I came across was getting the paths correct to the call to python. The correct eventual line is:

$output=system("/usr/bin/python2.5 /var/www/cgi-bin/controlsscii.py pos  $servo $angle");

I initially had the full path to the script but not that of python itself. An exhaustive web search and eventual examination of the Apache error log helped me narrow down this and subsequent problems.

The final tweak I had to make was to the serial port file (/dev/ttyS0) – I had to set the correct permissions such that the script could access it.

Updated: The code wasn’t formatted well enough for my liking. Some of it may go out of bounds. I will work this out, I’m sure.