Thursday, 13 February 2014

Interface Bench Test - Part 1

My general plan for testing this interface is to perform a complete bench test outside of the Armdroid enclosure.

Only when I'm happy with everything, will I remove my existing circuit board and make the changes necessary to accommodate either circuit in future.

The picture on the right shows the circuit board remounted on the base plate to help protect everything whilst testing.


My initial inspection check-list included:
  • Check the board for dry joints and re-solder any found
  • Visual inspection - looking for signs of burnt-out components etc.
  • Held the board under a strong light and checked the underside to ensure there no solder bridges between the tracks (as per the instruction manual)

Power Connection

Colne Robotics implemented a modified 4-way socket to ensure correct polarity using a polarising pin.   I crimped up a power supply connector, but didn't bother to protect from incorrect installation.  I will just have to be very careful!

Basically, you need to ensure +15 V is applied to the right most pin (as pictured below), and GND to either of the left-two most pins:



My bench power supply has now been preset to output 15.4V with a maximum current of approximately 3 Amps.

A basic power check was performed to verify the +5V power regulator (7805) is good, and all chips are receiving power.   If you measure the input voltage to the 7805 regulator, this should be approximately 12V after the input voltage has been resisted through R14 (big green thing) which is rated 18ohm 5w :


To check each individual chip is receiving power - check all datasheets and measure with a multimeter by checking the VCC pins have approximately +5V, with the exception of the ULN2003 Darlingtons which should have +15V on their COM ( pin 9 ) connections.


Computer Connection

This is where things are different to my prototype model.   This generation of circuit board uses a 10-way IDC connector, instead of the not-so-good edge style connector.


I made up a small 1-foot length of IDC cabling terminated with female connectors on both ends.

You can clearly see in the photograph above, red stripe indicates pin 1.  Pin numbering of these connectors are easiest described by an illustration:



At the other end - consideration was also given how to breakout the ribbon cabling:


I recently purchased this breakout board from Winford Engineering of Bay City, Michigan, USA.

It's a 2x5 (10-way) 0.1" IDC header breadboard adapter which makes for a perfectly reliable way of connecting Armdroid to Raspberry Pi, Arduino, etc.  As you can see, with an adapter like this, it's quick and easy to test what pin does what using a multimeter/digital logic probe.  Also, the PCB silk-screening makes it very easy to identify the pin-outs for this type of connector.

Anyway, if you happen to order one of these, please do mention my name whilst ordering, John will certainly go out of his way to accommodate you!


Stepper Motor Connection

I've previously talked about the Armdroid's official motoring number goes 1 - 6 left to right.  For the purpose of testing, I have installed a single stepper motor into channel 1 as pictured below:


When we get some idea channel one is working satisfactory, all remaining channels will be tested.


Microswitch Sensors
Not currently being tested - will need to add the optional 74LS366 3-State Buffer (IC5) to enable this feature.   I actually intend to show how you can add these sensors sometime, if your Armdroid is missing them.


Finally, a photograph of the interface ready to start bench testing:


Next, we'll confirm the interface pinout assignments, and soon be in position to connect up the Arduino.

Thursday, 6 February 2014

Driver Testing

In my previous post, we tested a stepper motor by manually pulsing the motor coils, and that was all basic stuff.

Shortly afterwards, it occurred to me, building a test circuit around the ULN2003A Darlington Driver wouldn't be such a bad idea.   I could use this circuit to verify each of the four ULN2003 drivers (IC13 - IC16) from my interface board.  You could also use this to test a driver and stepper in one!

By replacing any faulty driver chips, we should then be in a position knowing everything on the High Current side of the interface circuit is good.

The following test circuit uses an Arduino to sequence the motor steps, and has also been designed around Colne Robotics stepper motor wiring:


Notice how two inputs are exchanged - this is necessary to make the Arduino Stepper Library compatible with the Armdroid's stepper motor wiring (see previous posting); otherwise the pulse sequences will be wrong, the motor will not rotate.

I've previously talked about the hardware switching of two lines Qb and Qc, this is easily illustrated looking at the outputs of the ULN2003 and how they map to stepper motor coil inputs A + C and B + D

OUT1 = Qd
OUT2 = Qb
OUT3 = Qc
OUT4 = Qa

You can compare in contrast to the more regular wiring of unipolar steppers (see Arduino example circuits) where the wiring sequence is more sequential.

Further clarification can be found in the circuit diagram/construction notes.
I really have no explanation why Colne Robotics choose this wiring arrangement.


The accompanying sketch continually rotates the motor in alternating directions - this is good enough to spot any motion irregularities:

 /*  
  * ID35 Stepper Sketch  
  * http://armdroid1.blogspot.co.uk  
  */  
   
 #include "Stepper.h"

 #define ID35_STEPS 48  
 Stepper id35_stepper(ID35_STEPS, 2, 3, 4, 5);  
   
 void setup()  
 {  
   id35_stepper.setSpeed(20); // RPMs  
 }  
   
 void loop()   
 {  
   // rotate clockwise  
   id35_stepper.step(ID35_STEPS);  
   delay(500);  
   
   // rotate counter-clockwise   
   id35_stepper.step(-ID35_STEPS);  
   delay(500);  
 }  
sketch_ID35_stepper.ino


The circuit was first tested with a new ULN2003A driver from my parts box.  After making sure everything was running smoothly, I removed each of the four darlingtons from my interface board, and fitted them, one at a time into the test circuit above.



Driver (IC16) extraction from Armdroid interface PCB




But, we're not done just yet....   The ULN2003A supports 7 channels of current amplification (IN1 - IN7), three of the ULN2003 (ICs 13 - 15) fitted to the Armdroid's interface use all seven of these channels.   To test these additional channels, simply re-wire the inputs to use IN4 - IN7 and likewise with the corresponding outputs to be OUT4 - OUT7, nothing else needs to change!

Re-arranged wiring to test IN4 - IN7

All of my darlingtons turned out to be good.  But, it's well worth checking these, as these are probably the components most likely to fail on a circuit of this age.

The two darlingtons replaced by ECG2013 equivalents - I hadn't heard of these chips before, but double checking a datasheet found on the internet indicates they have exactly the same ratings as the ULN2003 they replace.  Both are rated with an output current of 500 mA and maximum voltage 50 V.

I've added both datasheets to the resources section.



My next post will concentrate on final preparations for bench testing the interface board....

Saturday, 1 February 2014

Testing a Stepper Motor

If, like me, you want to determine whether a Stepper Motor is working, you'll probably be interested in this...

My recently acquired Armdroid is a complete unknown - we have no idea of its working condition.  This morning, I decided, in preparation for bench testing, making up a power supply connector would be a good starting point, then, checking we have a working stepper motor.  Knowing we have a working stepper means we can eliminate that during our problem solving, especially if the interface board has issues.


A quick and dirty test uses an LED connected to any two inputs of the motor.  By spinning the motor shaft by hand, electromagnetism causes electricity to be generated, and this can be seen by the LED flashing.  Repeat for all other input terminals.

The more scientific approach is to measure the resistance between the center tap, and each motor coil input.  This should be approximately 47 ohms per phase.

You can quickly get an idea of the working condition using either technique - in my case, this proved to be successful.



The steppers used in the Armdroid are the ID35 35014 types, originally manufactured by Philips.  These motors consist of six connections, and are generally known as Unipolar Stepper Motors.

For readers new to the theory and operation of steppers, I quickly assembled the following circuit to demonstrate in a short video how they work manually....


Sunday, 26 January 2014

Addition to the family

I appreciate it's been a while since updating the blog, but I'm pleased to reveal the latest addition to our family...

Photographs of the grand arrival :



Hiding inside was a very well packaged Armdroid 1 :



To bring you up to speed....  A couple of weeks ago, an opportunity came up to purchase another Armdroid.  There was a very good reason for this....  This particular model has the later generation of interface circuit.   You may recall, my working Armdroid is a prototype model, and programming this is completely different to the more common production models.

By having both interface boards at my disposable means I can develop and support software that will run on either interface.   I intend to develop a software library supporting both types of interface, and all my future software will be based on this library.   This will be good news for other Armdroid enthusiasts!


This Armdroid was purchased and shipped over from the USA.
Chris, if your reading, many thanks once again for your excellent packaging - as you can see, we arrived in one piece!

The metal work is in fantastic condition, and all the running gears and pulleys are all in good condition.  Interestingly, the stepper motors for the Shoulder and Elbow are not the standard ID35 steppers.  I haven't identified them as they have no visible manufacturer markings.


The large 37-way D-type connector shown above is not standard.

A quick inspection of the PCB :


Reveals this is definitely a single-interface issue (direct-drive without manual controller) supporting the usual six motor channels.  This is the circuit board described in the original construction manual, and matches the published circuit diagrams.

I soon discovered that 37-way D connector is a modification whereby somebody has wired directly to the motor coils, completely bypassing the interface circuit altogether.  Perhaps this means the board is dead?

The arm was carefully carried to my study to begin removal of the PCB and one Stepper Motor which will be used later for bench testing:



This would appear to be an Issue 4 board with a Copyright of 1981 by Colne Robotics Ltd.

On further inspection - apart from being very dusty, condition looks good.  Two of the ULN2003A Darlington Array Drivers have been replaced with ECG2013 equivalents, but I don't think there is anything here which can't be replaced, or repaired.

I made detailed notes of the wiring and setup used by this Armdroid.  Noticed the wiring for the stepper motor coils is not per the manual which talks about exchanging Qb and Qc by hardware switching these lines.   More on this later.

I then decided to employ the same highly specialised & advanced cleaning process that Rudi Niemeijer from the Netherlands used to clean his circuit board....




Yep, a bath in soapy warm water using a soft brush, and finally, a good rinsing to remove all residual detergent.   This circuit board will now be left out dry for several hours!

Disclaimer:  Don't go washing any old PCB without first checking for Batteries or Paper-based Capacitors!

I need to makeup a 10way IDC ribbon cable and get the appropriate connectors before I will be in a position to start bench testing.   I will be documenting my approach to testing and fault finding processes over the next weeks.  This should help other readers with their restoration projects.

I'm actually hoping to get all this accomplished by 15th March in time for the 1st Peterborough Raspberry Jam which I will be attending and demonstrating at the show & tell.

I also want to modify all the wiring inside my Armdroid to easily accommodate either interface board, this means the power and stepper motor connections will need some consideration as the boards currently use different connection methods.

And what will happen to the rest of this newly acquired Armdroid hardware you might be thinking?   Hasn't really been decided, maybe will be used for spare parts, be refurbished, or used as an experimental platform for more advanced projects.

Finally, changing subject....  I've been playing with a newly purchased Arduino Leonardo that I will also be supporting with my Armdroid Library, so plenty of exciting developments to look forward here...


See this getting started guide for more information.
I'll be blogging later how to setup the Ardunio IDE on Windows 8

Sunday, 8 December 2013

Cambridge Raspberry Jam - 7th December

Yesterday, was the 4th Cambridge Jam (CamJam) of 2013 at the Institute of Astronomy, Cambridge University.

We arrived early to set up the Armdroid display, and before we could finish unpacking everything we had a small crowd hovering around the desk.....


Above, Matthew (The Raspberry Pi Guy) was really taken by the Robotic arm, and wanted one!   Ryan Walmsley was demonstrating his RTK-000-001 motor controller board & buggy, and some of the other demonstrations was equally as impressive!

Unfortunately, my Raspberry Pi was randomly rebooting itself, so out came the manual controller to the rescue !


Eventually the Pi started behaving itself....   Perhaps there was a shift in wind direction ?

I recompiled some of the test programs with shorter delay statements to speed things up, this made the arm appear a lot more responsive when controlled by the Pi.

Daniel Bull was back with the mighty AstroBlaster arcade console...  We spent most of the day talking (fantasying) about 3D Printing technologies.   The question being... can we print replacement Armdroid components with enough precision not to require further machining ?   We will have to wait and see...


Later in the afternoon I had the pleasure of meeting Gordon Henderson, author of Wiring Pi.  This is the GPIO access library I've been using to write my Armdroid software.

I met lots of interesting people and wished I had taken more photographs.

I've been invited to the forthcoming Peterborough Raspberry Jam starting in March which I'm really looking forward to attend.

Final picture of the day....  Yulia and myself, ready for a well deserved Beer at a local pub !   It was after all a long and very successful day.



We suffered a breakage in the afternoon....



The tension equaliser had been playing up all day, and eventually lead to failure of the fingers.  I suspect one of the retaining grub screws wasn't as tight as it should, this must have slipped.   If you look closely at the Kevlar which didn't snap, literately tore itself free.

Actually, I couldn't have asked for a better proving ground - the kids absolutely loved playing with the Armdroid, and really gave it a good hammering...   I've come away with a lengthy list of problems which need to be addressed & resolved for next time.

A full write up can be found at http://www.recantha.co.uk/blog/?p=7219 with an additional update http://www.recantha.co.uk/blog/?p=7290

Finally....   Big thanks to Michael and Tim, and all the Jam Makers for their superb organisation and dedication put into running such a good show.   Next jam will be Saturday, 8 February.

Saturday, 23 November 2013

Driving Multiple Motors

I've been working on a slightly more advanced test program capable of driving multiple stepper motors simultaneously...

Of course, they don't really run at the same time - that's not possible with this interface, but with some clever programming we can make them step, so that they appear to be moving at the same time.

This is desirable for speeding up operations by running in parallel, instead of sequentially driving motors.

Another important reason is controlling the Gripper action - in order to Roll (rotation) or Pitch (up/down) the wrist mechanism - we need to carefully apply counter-rotations to the left/right hand side motors to drive the differential gearing.

In my previous test program we stepped a motor by calling the drive_motor() function.  This was a blocking function, it would not return until all the steps have completed.   Instead of this, I've written a new routine called drive_all_motors() which takes an array of motor commands.  You can still pulse just one motor with this arrangement, or pulse multiple motors as required.

The motor control array is a relatively simple structure consisting of the desired number of steps and direction  for each of the six motors:

 // define motor control structure  
 typedef struct MTR_CTRL_TAG  
 {  
   int  steps;  
   int  dir;  
 } MTR_CTRL;  
   
 // declare our motor control array  
 MTR_CTRL motor_control[6];  

A motor which is not to be driven should have steps = 0
Assigning a positive number will result in that motor being pulsed to the specified number of steps

The implementation of drive_all_motors() takes this array, and calculates the total number of iterations needed to drive the motors.  After this, we form a tight loop and pulse each of the running motors, decrementing the number of remaining steps as we proceed:

 void drive_all_motors()  
 {  
   // calculate maximum number of steps (total iterations regardless of direction)  
   // for all motors  
   int max_steps = 0;  
   int motor;  
   for (motor = 0; motor < 6; motor++)  
   {  
     if ( motor_control[ motor ].steps > max_steps )  
     {  
       max_steps = motor_control[ motor ].steps;  
     }  
   }  
   
   // repeat until all possible steps have completed  
   int step, output = 0, control = CCLK + SYNC;  
   for (step = 0; step <= max_steps * 2; step++)  
   {  
     // for each active motor, drive it!  
     for (motor = 0; motor < 6; motor++)  
     {  
       // motor is active if we have any steps remaining  
       if ( motor_control[ motor ].steps > 0 )  
       {  
         // add motor address to control pattern  
         output = control + mtr_addr[ motor ];  
   
         // now, add direction bit if necessary  
         if ( motor_control[ motor ].dir == 1 )  
         {  
           output += CDIR;  
         }  
   
         // output control byte, and delay  
         digitalWriteByte( output );  
         digitalWriteByte( output - SYNC );  
         delay( PULSE_DELAY );  
   
         // output again with sync bit restored - returning to input mode  
         digitalWriteByte( output );  
         delay( PULSE_DELAY );  
   
         // decrement motor step counter (when clock pulse is low)  
         if ( (control & CCLK) == 0 )  
         {  
           motor_control[ motor ].steps--;  
         }  
        }  
      }  
   
     // toggle clock-bit for next clock pulse  
     control = control ^ CCLK;  
   }  
 }  

The delay statements results in very slow running speeds when driven from a Raspberry Pi.  This is intentional as I'm still debugging my circuits, but we'll speed things up later.  We'll also consider speed along with acceleration/deceleration control in later versions of our software.

I'm going to start work writing a variation of the LEARN program documented in the manual allowing users to program sequences of movements & play them back.  This program will use the above technique as the bases for this work.  I also want to start abstracting the implementation details to make things easier to modify for direct-drive variants, and porting to other platforms.


The full source code for ArmTest_v2.c has been added to the software page.

Saturday, 2 November 2013

Motor Addressing Solved

Finally, I have solved the motor selection problems.   This blog update will try and cover both problems in detail....


1. PCB interconnections (only applies to prototype models)

As suspected the PCB interconnects was crossed on my Armdroid causing motor selects to drive the wrong motor.   The cables feed the the bottom two data bits (CDIR & CCLK) from the interface to driver circuitry, and look like this:


They combine two channels into a single connector at the other end.


They need to be wired such that the outputs on the interface board below feed directly into the corresponding inputs on the driver circuit board above in the same sequence.   As pictured above, the ordering is - starting from the left-hand side, motor #1 - motor #6


The colour coding of my cables are Purple, Blue, White, and Grey

The labels on all my connectors will be replaced in time to correctly reflect the motor channels they represent.


2. Motor Addressing Logic

The ordering of the Motor Address Bits was not as documented

The give away is the 74LS138 IC6
If you look closely at the pin-out for the 74LS138, you'll see that pins 1 - 3 are the input select bits, illustrated as follows:
The Truth Table says, to get output Y1 selected (ignoring the reverse logic), where Y1 happens to be our motor select for channel #1, you need to set the input pins as follows:

C B A
L L H

L = LOGIC LOW,  H = LOGIC HIGH


Looking at the interface schematics :



You can see address bits D2 - D4 are wired to the 74LS138 as follows:

D4   -->   A (pin 1)
D3   -->   B (pin 2)
D2   -->   C (pin 3)

Which means to select motor #1 the address bit pattern would have to be:

D4   HIGH
D3   LOW 
D2   LOW 

The most significant address bit is actually D2, and least significant D4.

This is not quite what the article in the ETI magazine documented for the interface specification.   Previously, I was setting addresses with the assumption D4 was the most significant bit - for example 001 in binary, instead of 100 binary.

I revisited the construction manual looking for further clarification, unfortunately the documentation is somewhat ambiguous here.

Of course, none of this is actually a problem... we're dealing with an address pattern that is essentially reversible, so if your happy to re-wire your motor assignments, everything will then fall out in the wash.

I decided not to do this, and instead will compensate in software...
By introducing an array of motor addresses, we simply index into this array to fetch the desired motor address bit pattern:

 // motor address bits  
 // 1 0x08 = 00001000  
 // 2 0x04 = 00000100  
 // 3 0x0C = 00001100  
 // 4 0x02 = 00000010  
 // 5 0x0A = 00001010  
 // 6 0x06 = 00000110  
 //              |||  
 //              ||+-- A3  
 //              |+--- A2  
 //              +---- A1  
 const int mtr_addr[] = { 0x08, 0x04, 0x0C, 0x02, 0x0A, 0x06 };


When constructing our output control byte, the new code looks like :

   int output = CCLK + mtr_addr[ mtr-1 ] + SYNC;  

I no longer need to shift the address bits into position because they are now already defined in the correct position.   The mtr-1 of course is needed because all arrays in "C" have indexes starting from zero.

Actually, I prefer this approach because it allows other readers to easily adapt to their Armdroid's configuration.   This is essentially mapping logical motor numbers to physical motor addresses.  If a motor has been incorrectly wired to the wrong channel, you only need to modify this address array to compensate.   Good eh?


The updated source code for the test program will be added later this weekend to the software section.


I still have plenty of other problems to investigate.  Some of the motors, not all, are not reversing properly, yet everything works when operated by the manual controller.   I also rigged up a test circuit to check the signals coming from the feedback switches - and not convinced this is working properly either.    But, resolving the motor addressing is certainly one step in the right direction.....