Showing posts with label oomlout. Show all posts
Showing posts with label oomlout. Show all posts

Monday, 17 October 2011

Interesting servo hack

After reading a few other articles about hacking servos to make them rotate continuously, I noted quite a few people suggested disconnecting the rotary pot and replacing with a voltage divider made up of 2 x 2k resistors (in a sort-of Y shape)



Our servo is much too small to fit extra components inside it, but without these, it doesn't seem to work. It spins in one direction, by sending a repeating 1ms pulse every 20ms, but increase the pulse length to 2ms and instead of running in reverse, the servo just judders and makes a nasty noise.
(if the servo is "centred" at 1.5ms, a pulse of 1ms tells it to move 90 degrees in one direction, and a pulse of 2ms tells it to move 90 degrees from centre in the other direction. By removing the pot input, the servo never knows where the head is so should continue to move).

Removing the pot seems to have caused the problem.
To simulate the pot, we soldered a piece of wire from the board where it was connected to the potentiometer (we should have snipped the end nearest the pot, not nearest the board and we could have re-used the bit of wire without extra soldering!) and connected to a voltage divider on the breadboard, made up of two 2K pots



This sort-of solved the problem, but not quite.
The servo no longer judders, but it's not not right. With a pulse width of 1ms, the servo runs at full speed in one direction. A pulse width of 2ms makes it run in the same direction, only much slower.
Maybe this is because we're using power and ground on either side of our voltage divider, rather than taking them off the internal pot (but then to get at those wires would require completely dismantling the servo!)

Now we could play about with the resistor values, or maybe even replace them with an exterior potentiometer (with the wire from the servo connected to the wiper and each end connected to power and ground) but here's a thought....

Pulling the signal on the wire to ground causes the servo to run at full speed in one direction.
Pulling it to power (5v in our case) causes the servo to run at full speed in the other direction.
So now we have a binary method of moving the servos either forwards or backwards - simply connect this new wire to an output pin and pull it high to drive the servo in one direction, and pull it low to drive it the other way.




Edit...
interestingly, we did have to make some changes to the servo control values to get the servo to work consistently without juddering. When pulling the signal pin high, we set the servo signal length to zero. When pulling the signal pin low, we set the servo signal length to 2ms. This resulted in the servo running at full speed in opposite directions. (using a signal length of 1ms and pulling low occasionally caused juddering so we ditched it!)

The downside to this approach, of course, is that we don't have a way of programmatically stopping the servos from turning. For our little robots project, we'll live with this restriction.
It's a fine balance between coming up with a project that can be completed inside a couple of hours but still demonstrates "hardware hacking" and spending all day perfecting servo controls which probably wouldn't get used!

Anyway, this is to document how we hacked our micro servos to allow us to create little tiny robots, instead of the big monstrosities normally associated with continuous rotation servos ;-)

For anyone interested, here's the Oshonsoft BASIC PIC code for our servo test board:


Define CONF_WORD = 0x3f18
Define CLOCK_FREQUENCY = 4

declarations:
       Dim servolen As Word
       AllDigital

init:
       Config PORTB = Input
       Config PORTA = Output
       OPTION_REG.7 = 0 'pull-ups on PORT inputs
     
startup:
       While PORTB.0 <> 0
              'do nothing: we have to press the button to start
       Wend
     
loop:

       'button controls direction
       'connect the extra wire from the servo
       'to pin PORTA.1
       If PORTB.0 = 0 Then
              High PORTA.1
              servolen = 0
       Else
              Low PORTA.1
              servolen = 2000
       Endif
            
       'servo control signal
       'for our hacked servo, signal length doesn't matter
       High PORTA.0
       WaitUs servolen
       Low PORTA.0

       WaitMs 15

Goto loop
End

Hacking to make a continuous rotation servo

As part of the up-and-coming HackLlan show-and-tell session, and for the follow-up workshop, we're making robot kits in preparation for the Robot Week Wales.

As with most robotic projects, this begins with hacking some servos to make them rotate continuously. We could just buy factory-set rotational servos from our pals at Oomlout but as the workshop is to include "hardware hacking" we figured we'd have a got at modifying some micro servos.

We're after making some small, compact robots so these micro servos are the perfect size (plus of course, a ready-made continuous rotation servo is £11, a micro servo less than half this at £5 each). We already had a couple of these from an earlier project but if all goes well with this experiment, we'll be buying more!

At this stage, we're not sure if the modifications will work, but we've looked into how a servo works. It's basically a small motor with a control board. The output from the motor is geared right down, giving the servo plenty of torque (twisting power). The control board has a microcontroller and a rotary potentiometer, which is turned as the motor moves the servo "horn", which is connected to the shaft of the motor.

These easiest way to explain this is to have a look at what goes into a servo.
Whenever you take anything apart, the most important tool you can have is a digital camera - and a hammer. Hammers open anything ;-)


We put the hammer to one side and open up the servo with a tiny jeweller's screwdriver.
We actually found that the smallest flat-headed screwdriver worked better than even our smallest cross-headed 'driver (despite the servo having cross-headed screws holding it all together).

You can see that the motor shaft has plenty of cogs, gearing the output down many, many times. This is what gives the servo motor it's power.


Underneath the control board, you can just make out the rotary potentiometer. As the motor turns, the gears and cogs also turn, and the shaft on the second "pile" of cogs causes the wiper on the potentiometer to turn. This signal is fed back onto the control board, so that when the servo head has reached the required position, it knows to stop turning the motor.


We traced the wire from the pot to where it meets the control board. Taking photos (so it can be replaced later if necessary) we snipped the wire from the pot and taped it up. Now, when the motor turns, the control board won't know where the servo head is, and so will keep turning the motor.

The last thing to amend is the physical lock on the servo head.
A small "lug" on one of the cogs stops the head from turning too far during normal operation.


We snipped this lug off the cog and reassembled the servo, using the earlier photographs as reference. We then put the head back on the servo and turned it by hand, to check that it does, indeed, turn through 360 degrees. The last thing to do now is to check that the servo direction can be controlled by our microcontroller.....

Friday, 29 July 2011

oomlout.co.uk

Arduino and general geek-kits specialists oomlout.co.uk sent a surprise - and very welcome - package to Nerd Towers this morning. It follows a discussion with Aaron at Oomlout (does it look weird with the first "o" capitalised?) which in turn came about after demonstrating a few project ideas from these very pages to Chris at HPC Laser (where we recently bought our spanky LS3020 machine)



Oomlout have been providing Arduino type starter kits for years and have excellent facilities up in Halifax. In fact, getting your stuff from them means you're dealing with likeminded nerds and geeks - these guys don't just put components into boxes and sell them on, they actually use and build stuff with them too!
A lot of the machinery at Oomlout has been designed and built by Aaron and the guys - cogs made from laser cut acrylic, arms moving on servos, all connected to homebrew control boards: if ever you need advice on what to get for your own projects, at least you know you're dealing with people who know exactly what you're going through!

Enough blather about what a cool bunch of guys these are, let's have a look at what we've got:



I'm personally no great lover of Arduino, but this starter kit has got me genuinely intrigued. As well as the main Arduino control board, there's everything you'd expect to find to get you started - breadboard, jumper wires, LEDs, resistors and so on - and some slightly more exotic components for the more adventurous, including a motor, pushbuttons, micro potentiometer (to make rotary dials), transistors, LDR (light dependent resistor), a shift register, a relay and a piezo sounder/buzzer.
All in all, some pretty interesting components - maybe not enough to make one big uber project with everything in it, but certainly enough to learn and understand about each one and what it could be used for.
As well as this little lot, we also got some micro servos (we're already familiar with what to do with these!) a big beefy continuous rotation servo - can be used as a high-torque motor for driving things around the place - and one of the most intriguing parts in the box, an ethernet shield.



Already we've plans for the ethernet shield, following our failed mBed HTTP client project. We'd love to find out how robust the Arduino-to-web communication is and whether that would be a more suitable for our SMS-to-web and switching unit projects.

However, the thing that is really impressive about the Oomlout starter kit is the documentation.



Each component in the starter set is introduced, with a description of what it is, what is does and how it can be used.



These are coupled with try-it-yourself type examples with real world images of what the project will look like on the board. Having run a number of workshops for BuildBrighton, I know how useful these can be. Working from simple schematics and photos off the internet is a very worthwhile exercise, but to new users, it can be confusing. Until you're comfortable with understanding how a circuit diagram translates into which wire goes where on the circuit board, a diagram showing what the end result will look like is an invaluable aid. These diagrams are also slightly "exploded" so you can see exactly what goes where - something which can be tricky if you're following a project from a website and it has only one or two photos of the finished project, taken from an obscured camera angle.



For me, the very best bit of the starter kit is the simplest of ideas.
Each project has a paper overlay which exactly matches the breadboard layout, and has the components used printed at actual size. The end result is a sheet which you can stick to your breadboard and simply poke the components through, ensuring that every leg and every wire goes into exactly the right place.



It's such a simple idea, I'm amazed it's not more popular.
I've never seen this approach before, and it's as brilliant as it is simple.

So even if you're an old hand, whether you're starting out, or just looking for something different to get out of a rut, check out the Oomlout website. If their level of attention to detail on the other products is as high as it is for the starter kit, you're sure of some great help and advice along the way - and that in itself is worth ten times the value of the components in the kit!