Friday 14 January 2011

Major Assembly Completed







Apologies for the image heavy post, with luck I wont have to do that again.

Ok, just like the title says, the major part of the assembly has been completed. As you can see from the images, the robot itself is quite a neat little beast. I on the other hand, am not famous for my tidyness, so the wires you see poking around all over the place are down to my cack-handedness in doing as the manual suggested and "tucking them under the chassis".

Still and all, its done, together nicely and servos are tested and working. What I need to do now is write and test the program/circuit suggested by the manual which will inform me if something screwy is happening to the bot or whether its behaving strangely because of low power.

It isn't behaving strangely at the moment of course, the circuit is intended to let me know if it does.

Turns out, all the code and exercises the manual has taken me through so far is simply an exercise in pre installation testing, or sub system testing. Not the first time I've heard of the concept, but the first time I've thought about it really outside an object oriented computer program, which this thing most certainly is not.

Next on the agenda is testing iterative testing to find the values which will make each servo turn at the same rate, forwards and backwards.

This is an exercise the manual takes you through, because regardless of the fact that you centered the servos before putting the bot together, the servos will still turn at slightly different rates.

Why, I hear you ask?

Servos seem to be set up so a particular configuration of signal instructs the server to do nothing. This seems strange, until you consider the fact that the servo is capable of turning at a variable speed. The speed of the servo is determined by the width of a modulated power signal which arrives at the servos terminals. In addition, a servo is capable of travelling clockwise and counterclockwise, which is a good thing, a servo which went in only one direction would be useless after the first use.

So, in order to get the servo turning in one direction or the other, at one speed or another, we simply vary the width of the power signal which will arrive at the servo's terminals.

The center signal is the width of signal which means the servo doesnt turn at all. In short, its an instruction to stop.

Now, while we are working with some amazing bits of kit, capable of measuring down to a couple of millionths of a second, we aren't working with top of the line, nano-engineered, nuclear precision equipment. That means, when we went through the somewhat fiddly exercise of centering the servos, what we actually did was the equivalent of putting a needle somewhere between two "on" switches.

When we send a signal to the servo, we do it using the command PULSOUT [pin number], [duration].

The [duration] part of the command is the number of microseconds (one millisecond is one thousand microseconds) we want power supplied to the servo. That is what is meant when someone mentions the "width" of the "up" signal.

In addition, the "up" signal is followed by a command to the microcontroller to stop sending power to the servo for a given period of time.

In PBASIC, that command is given as PAUSE [duration], with the [duration] element given in milliseconds.

Most servos use an "up" (I'm going to stop surrounding that with quotes) signal with a width of 1.5 milliseconds as a signal to do nothing. If the width is any more than that, the servo will turn one way. Any less, it turns the other way.

Amazingly, it is possible to pass a signal with a width as small as two microseconds through the BS2. Possible, however impractical. However, knowing the smallest resolution means we can calculate exactly how to structure the PULSOUT command when we center the servos.

If we call two microseconds the smallest time unit the BS2 is capable of dealing with, it makes it easier.

One millisecond has 500 of these BS2 time units in it, and when we center our servos, we need a signal width of 1.5 milliseconds. So, since the PULSOUT command uses these time units for its duration parameter, we simply provide the command as follows:

DO
    PULSOUT [pin number], 750
    PAUSE 20
LOOP

While the command is running, we are getting busy with the screwdriver and adjusting the potentiometer until the servo stops moving.

So, with all that background, we can look at what probably happened when we centered the servos.


Looking at that diagram, we can see that while the perfect placement would put us on the 750, the likelihood is that the servos "center" was placed somwhere between the two boxes, as shown by the two red needles on the diagram.

That diagram I made is pretty, but still only tells part of the story. We can see on the diagram that there is a nice neat spacing on both the CW side and the CCW side. Looking at the diagram, it seems if we pass a signal with a width of 755 to the servo, it may well start turning, very very slowly in a clockwise direction. Likewise, if we pass it a signal with a width of 745, it will turn the opposite direction, again, very very slowly.

Not the case unfortunately. It may be that a width of 753 starts the servo turning in a clockwise direction and a width of 746 starts it in a counter clockwise direction. I suspect every servo is slightly different.

Didn't mean to go on for quite so long, but it was worth it.

In case many of you haven't guessed yet, I am using this blog equally as a way of cementing the knowledge in myself as much as to inform.

So, next exercises are beckoning, till the next update!

No comments:

Post a Comment