Showing posts with label servo board. Show all posts
Showing posts with label servo board. Show all posts
0

Still keeping busy

Posted by Chris on Friday, August 21, 2009 in , , ,
Once again, it's been a busy few weeks up in Nerd Towers.
As well as seeing the launch of the usb-multiple servo board via BotBuilder, work continues apace with the ScoreSure Golf Pro game scoring device.

On top of all this an exciting new group has started down here on the sunny south coast - BuildBrighton. It's where a load of like-minded nerdy guys and gals get together and make stuff, using bits and bobs salvaged from all kinds of disused electronic equipment.
Last night was a good meeting - even though a few of the regular faces were missing, there were some really interesting people down there, working on some brilliant ideas. For example, Dangerous Dave was demonstrating his Wii-controlled wheelchair (like Stephen Hawking on speed), Tom spent no time at all ripping up some micro-cameras for his Arduino-based robot, and there was even talk of building a video-enabled weather balloon in the coming weeks!

For the group, I've also put together some videos demonstrating the power and simplicity of ExpressPCB, first covered in an earlier post here. Quite a few members of the BuildBrighton group are quite keen to get their ideas off the breadboard stage and build their own PCBs. ExpressPCB is an excellent tool to use to do just this.

More videos will be posted here as time allows....




0

Servo boards go into production

Posted by Chris on Monday, August 17, 2009 in , ,
It's been an exciting time recently with a few nerdy ideas finally getting to production stage. Which is what the Nerd Club website was originally all about - bringing people together to share ideas, help out with each other's projects, and to get something (finally) finished.

The first such project is the USB-based multiple servo controller board. The prototyping is complete, the hardware (electronics) is finished, the firmware (microchip code) is done and the online flash editor is ready for uploading to its final destination, on the BotBuilder.co.uk website

Here's a photo of the final board in production, complete with silk-printed decals.
The board is available in kit form (solder-it-yourself) and read-to-go, from www.botbuilder.co.uk.


0

Robot Studio v1.0 - video online

Posted by Chris on Friday, August 07, 2009 in , , ,
A quick introduction to version 1.0 of Robot Studio.



A flash-based editor (so animations can be stored online and shared) for controlling servos using a 12-channel board with build-in eeprom playback. Add a point by clicking anywhere on the graph. Move points around by dragging. Delete points from anywhere in the graph and it will rebuild to "mend the hole" (for any nerdy-types interested in this kind of thing, it was achieved using a double-linked list, not nasty arrays!)

All points above the centre line mean the servo turns clockwise (at the very top of the graph = full right), and below means turn anti-clockwise (points at the bottom of the graph = full left). Servos can be designated as "angular" (normal motion) or "rotational" (hacked) and the distance of the point from the centreline then controls the speed of the servo.

Because different servos behave differently (one continuous rotation servo may be at dead stop at 50% pwm, whereas another may creep round until at 55%) each servo channel can have its own centre line. All points above this line turn the rotational servo clockwise, all points below turn it anti-clockwise.

The absolute minimum and maximum values for each servo can be set independently. Any points added outside these absolutes are snapped into the acceptable range.

Playback animation and watch the software servos onscreen. Press the export button and you're presented with a stream of bytes. Copy and paste these bytes into the eeprom loader application, and your servo-board is loaded up with data and ready to play back your animation!

The 12-channel servo board is controlled by USB and is recognised as a HID-compliant device (no nasty drivers to install and are even Mac-compatible). The board also supports serial communications, making it compatible with Arduino. The controller boards can be daisy-chained using serial comms, increasing the servo channels from 12 to 24, to 36 etc.

Version 1.0 of Robot Studio supports a single board.
Multi-board support is being developed for v2.0

The controller boards are available to buy at http://www.botbuilder.co.uk/store

2

Servo controller board. Complete?

Posted by Chris on Friday, August 07, 2009 in , , , ,
After a few problems at the RobotBrighton Demo (the least of which was not being able to get the board to work properly!) things were looking bleak for the multiple USB servo controller.

It didn't matter what sequence of bytes the online editor spat out, they could never be sent (and read back) from eeprom consistently.
Sometimes bytes were missing, sometimes byte values were changed for others, and sometimes, the bytes read back looked nothing like those that were supposedly written to the device!

It turns out that the problem was a timing issue, between the MCU and the eeprom.
You see, the processor is running at 20Mhz, whereas the eeprom can only manage a measly 400khz (yes, khz) at best. This obviously leads to timing issues, particularly when writing to eeprom.

Finding the exact cause of the problem was a nightmare, particularly with a demo that was running late (and looking quite likely to not happen at all). Luckily, the problem was easily resolved by added a 5ms delay after writing each 4-byte chunk to memory. So now the board works just fine.

Which is just as well, otherwise it would mean that this last week would have been wasted, as most of it has been spent perfecting the Flash-based servo editor interface



This spanky editor allows you to control up to twelve separate servos using a simple click-n-drag interface. It uses a double-linked list to keep track of each of the graph points, allowing them to be dragged around and their position within the horizontal timeline to be altered quickly and easily. As each point of the graph is dropped into its new location, the graph is redrawn quickly without the need for popping and pushing array elements around the place. Linked lists are perfect for when you need an array of items that could regularly change place within a list.

0

USB servo controller

Posted by Chris on Monday, July 27, 2009 in , , ,
In a break from all the golf coding of recent weeks, a previous project made a welcome reappearance this week - the multiple usb servo controller. Welcome in that it gave us an opportunity to actually complete something and get that warm fuzzy feeling that so often accompanies putting a project to bed!



The hardware development is complete. Data can be sent to the device using a USB connection, and is as easy as copy-and-pasting a list of bytes from the online editor. Below is a video of the test app used to send data to the servo controller board eeprom. You can see the data values and see them being played back in the video above:



A new version of the editor is currently in progress and when complete can be found, along with a whole host of support materials, at www.botbuilder.co.uk.

0

If you can't build it, simulate it

Posted by Chris on Tuesday, June 23, 2009 in , , ,
Despite the lack of news recently, it doesn't means things have gone quiet up here in Nerd Towers. In fact, it's the very opposite - beavering away making clever things means less time to write and tell you about them. But here's something that we're really quite proud of: a servo simulator.

In collaboration with botbuilder.co.uk we're making a USB/serial servo controller which uses EEPROM to store a sequence of commands to control the servo(s). The idea is that you can plug the robot into your USB port, download a "servo script" and sit back as your robot puppet performs it's sequence of tasks.

Using these excellent 360 degree servos the simulator allows you to set the min/max bands for each servo in a list, and to set the centre point. Servo movement over time is defined by plotting points on a graph. The editor also lets you play back (i.e. simulate) your servos movement so you can fine-tune your graph(s).

Here's an early version of the Flash-based online interface (in time it's hoped that users will be able to share servo scripts through the website, hence the online editor):



In this example, servos 1 and 3 have been hacked for continuous 360 degree rotation. Servo 2 is a "traditional" servo, moving through 0-180 degrees.

0

Another project complete?

Posted by Chris on Friday, May 15, 2009 in , ,
My hands are shaking as I type this, as I think I've finished yet another project. Yet another? Ok, maybe this is my first, fully-finished, nothing-more-left-to-do project. But I think it's done.

It helps that it's mostly software based: a PIC controller with 12 independently controllable servo channels, which uses EITHER serial communications OR USB.
It also allows you to set the pulse width (the servos I'm working with seem to need a signal anywhere between 0.6ms and 2.2ms wide, to get them to move through the full 180 degrees).
Data is sent to the PIC using two-byte instructions - a letter to indicate which servo number (A-L correspond to servos 1-12, where A=1, B=2 etc.) followed by a number representing the percentage movement required.
So for example, A50 means move servo number one 50%.

Two special instructions are also included:
Y = set min pulse length (where 100=1ms, 60=0.6ms etc)
Z = set pulse length for 100% movement (where 100=1ms, 80=0.8ms)

So in my case, using servos that require a pulse from 0.6 to 2.2ms I set up the controller by sending

Y60

If sending this data via USB, I then poll the 8-byte USB data/io report.
This is because the device, on receiving a USB data "packet" (8-byte data buffer is populated) I set byte(7) of the buffer to zero.
After the device has updated the necessary internal values, it sets this last byte to 0xFF (255 decimal) to say that it's ready for the next packet of data.
So polling this last byte value lets me know at the PC end when the device is ready to receive the next instruction which is

Z160

(after a pulse of 0.6ms, the maximum time before the signal should go low is 1.6ms, making a total pulse length of 0.6 + 1.6 = 2.2ms)

Using this approach, "standard" servo commands can be set, using Y100, Z100 (pulse length 1ms-2ms) but non-standard servos can also be used, by setting the "on" and "off" servo timings. Because different pulse lengths can be used, movement is achieved by sending a servo pin number/letter and the amount of movement required as a percentage (0-100). So to move a standard servo on pin3 through 50% we would use the command

C50

Easy huh?
Steve over at botbuilder.co.uk is working on turning this into a shield/daughter board for the Arduino, so that it can be used to provide up to 14 servo controllers (2 built-in to the Arduino + 12 on the board).

0

Multi-channel servo controller

Posted by Chris on Sunday, May 10, 2009 in , , ,
So here's the first working version of multi-channel, USB (and serial) driven servo controller. It's by no means complete, and for some reason, my servos only move 45 degrees either side of the zero point but the theory behind it seems to work.

Here's what happens, in a nutshell:
Unlike other multiple servo controllers, this one does not activate the servo pins in sequence (which, incidentally on a 20Mhz crystal limits you to 8 servos, maximum).
This controller switches on all servo pins at the same time, and uses timer1 to decide when each servo pin should be switched off.
Since all pins are on for the first 1ms, and are turned off during the second millisecond, this keeps 3-20ms (9/10ths) of the processing time free for data processing and other tasks (give or take a few nanoseconds for some basic time-keeping checks).

Using the same layout as my earlier USB project you can get some results quite quickly. Set your board out according to the schematic and drop the code (below) onto the PIC18F2455.

Attaching your servo signal wire to pin RB0 should move the servo to the zero position. RB1 should move the servo to one extreme, pin RB2 to the other. (in fact, if you look at the code, you should see that pins RB3-7 also move the servo to the same angle as RB1.

I'm still working on fine-tuning the code and experimenting with other servos.
I'm using a Hextronic HXT900 servo which doesn't appear to move through the full 180 degrees. The half-way signal does appear to put the servo into the centre position. However, when sending signals to move the servo to its extremes, it only moves 45 degrees in each direction, rather than the full 90.
I'm not sure whether this is a software issue, or whether it's particular to this servo model. Results of any further investigations will be posted here in time!

Oshonsoft PICBasic listing for 18F2445

Define CLOCK_FREQUENCY = 20
Define CONFIG1L = 0x24
Define CONFIG1H = 0x0c
Define CONFIG2L = 0x3e
Define CONFIG2H = 0x00
Define CONFIG3L = 0x00
Define CONFIG3H = 0x81
Define CONFIG4L = 0x80
Define CONFIG4H = 0x00
Define CONFIG5L = 0x0f
Define CONFIG5H = 0xc0
Define CONFIG6L = 0x0f
Define CONFIG6H = 0xe0
Define CONFIG7L = 0x0f
Define CONFIG7H = 0x40

'PORTA.0 is feature LED
'PORTA.1 is i/o LED
'these can be removed if necessary

declarations:
Dim ax As Byte
Dim i As Byte
Dim j As Byte
Dim t As Byte
Dim svh(16) As Byte
Dim svl(16) As Byte

usbcrap:
UsbSetVendorId 0x1220
UsbSetProductId 0x1234
UsbSetVersionNumber 0x1122
UsbSetManufacturerString "www.nerdclub.co.uk"
UsbSetProductString "Multiple servo USB controller"
UsbSetSerialNumberString "1111111111"
UsbOnIoInGosub usbonioin
UsbOnIoOutGosub usbonioout
UsbOnFtInGosub usbonftin
UsbOnFtOutGosub usbonftout

init:
AllDigital
Config PORTA = Output
Config PORTB = Output
T1CON = 0 'set all bits to zero

startusb:
PORTA.0 = 1 'turn on an output so we can see the pic is running
UsbStart
PORTA.0 = 0 'turn off output once USB has set up

startup:
'set the value for timer1 to count up to
'(count to 5000 = 1ms: highbyte=5000/256, lowbyte=5000 mod 256)
CCPR1H = 19
CCPR1L = 136

'to allow a 0-100% range, sv(0-15) can take the value 0-100
'(we multiply these up by 50 as the values are received, to give
'a range of 0-5000, which is 0ms to 1ms).
'these are some example values to test the middle and extreme
'ranges of the servo controller on pins 0,1,2

svh(0) = 9
svl(0) = 196

svh(1) = 0
svl(1) = 0

svh(2) = 19
svl(2) = 136

'1011 = special event interrupt, clear timer etc.
CCP1CON.CCP1M3 = 1
CCP1CON.CCP1M2 = 0
CCP1CON.CCP1M1 = 1
CCP1CON.CCP1M0 = 1

'PIR1.CCP1IF = 0 'clear any "bogus" reading
T1CON.TMR1ON = 1 'enable timer1

t = 0

loop:

  If t = 1 Then
    'turn on all servo outputs for 1ms
    PORTB = 0xff
    PORTA.0 = 1 'led to show timer is running
  Else
      If t = 2 Then
      'this is where outputs get turned off. Because there may
      'be a delay in processing this loop, we compare the actual
      'value held in Timer2 and if it's greater than our servo-off
      'value (0-100% multipled by 50) then turn that pin off

      If TMR1H > svh(0) Then PORTB.0 = 0
      If TMR1H = svh(0) And TMR1L >= svl(0) Then PORTB.0 = 0

      If TMR1H > svh(1) Then PORTB.1 = 0
      If TMR1H = svh(1) And TMR1L >= svl(1) Then PORTB.1 = 0

      If TMR1H > svh(2) Then PORTB.2 = 0
      If TMR1H = svh(2) And TMR1L >= svl(2) Then PORTB.2 = 0

    Else
      'turn off the servo outputs for the duration 3ms to 14ms (and 0ms-1ms)
      PORTB = 0x00
      PORTA.0 = 0 'turn off timer led

      'service the USB port for data
      UsbService

      'check to see if we've had two bytes of serial data
      If i = 0 Then
        'Hserget i
      Else
        If j = 0 Then
          'Hserget j
        Else
          'parse the two byte instruction and update the servo-off
          'values as necessary, then reset i and j to zero
          i = 0
          j = 0
        Endif

      Endif
    Endif
  Endif

   'check for CCP1 interrupt flag (even if interrupts are not
   'on, you can poll this flag to see if an event has occurred)
   'this really needs to be in an interrupt routine so that the timer
   'is kept as up-to-date as possible
   If PIR1.CCP1IF = 1 Then
     t = t + 1
     PIR1.CCP1IF = 0

     If t > 14 Then
       t = 0

       'reset the timer to exactly zero
       '(so if there's been a delay switching on, we're back in sync
       'when it comes to switching the signal off, otherwise there
       'might be a bit of judder as the time period between on and off
       'may differ by a few thousandths of a millisecond)
       TMR1L = 0
     Endif

   Endif

Goto loop

End


usbonftout:
Toggle PORTA.0
Return


usbonftin:
'we've received some data in the feature report
Return


usbonioout:
Toggle PORTA.1
Return


usbonioin:
'we've received some data on the data i/o, so
'update the necessary servo high and low byte values
'to get the selected servo to move to its new position

Return


0

Blog posts are just like buses...

Posted by Chris on Saturday, May 09, 2009 in , , , , , ,
...you wait for ages for one, then three come along at once.
Just a quick note to say that, despite there being no blog updates for a while, it's not all ground to a halt here at Nerd Towers.

After the success (mostly) of the USB relay switching device I've been inspired to help out with a project for Steve at www.botbuilder.co.uk, which is a USB-driven multiple-servo controller.

Simply put, to drive a servo, you need to send a signal pulse to the servo every 20ms or so (50hz) the duration of which must be between 1ms and 2ms.
A 1ms signal means "0 degrees" (or -90 if your zero position is half way between the two extremes). To move the servo to 90 degrees (or its mid-point) a signal of exactly 1.5ms must be sent, and a signal of 2ms represents "fully extended" or "180 degrees" (or 90 degrees if you're working from -90 to 0 to 90).

Many PICs have a PWM (pulse-wave-mode) module built into them, and some even have two or more. But very few (if any) can support up to 16 servos.
Allowing for errors, and a signal pulse time of 2.5ms per servo - remembering that each servo must have a signal sent to it every 20ms at most - the maximum number of servos that a PIC can control, serially, is 8.
(servo 1 takes 2.5ms, followed by servo 2, another 2.5ms, followed by servo 3 etc...)

8 x 2.5 = 20m/s.

And on top of all this, your PIC is running at 100% capacity - there's no room in there for receiving data requests to update the position of the servos.
So I'm trying to recreate PWM using an 18F series PIC, but using timer1 to create interrupts to drive all servo pins high at the same time, then use some form of offsetting to drive them low again after a period of time between 1ms and 2ms.

Look out for some Oshonsoft PICBasic code shortly (if I get it working!)

whos.amung.us

Copyright © 2009 .Nerd Club All rights reserved. Theme by Laptop Geek. | Bloggerized by FalconHive Supported by Blogger Templates.