Armdroid 1

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Friday, 25 October 2013

RPi Interfacing

Posted on 13:17 by Unknown
Progress report on the Raspberry Pi computer control & software


A couple of evenings ago, decided to bite the bullet, and power up the Armdroid connected to my Raspberry Pi.

Needless to say, nothing happened...  but I could hear a slight clunk coming from one of the stepper motors.

Eventually, I realized everything was working, but my delay statements was initially so large, it was taking minutes just to crank a few rotations.   I gradually reduced the pulse delays to approx 500 milliseconds.

The motor addressing is a bit weird.....
Selecting motor 1, results in motor 5 spinning into life, etc.   I spent hours double checking everything, and so far, my only conclusion is that the fly leads connecting the Armdroid's interface PCB to the driver PCB is mixing up the address selection.   A couple of months ago I traced the entire interface board and was pretty happy I knew what to expect here, so I don't think the issue is with the software or that part of the interface circuity.

I really need to run everything with the board outside of the base, but to do that, I'll have to extend my motor cables and modify the power connections.   Hopefully, I can then probe away with my Logic Probe on the running circuit to see what's happening.



Anyway, here is an example of my test program written in "C"  :

 /*  
 * ArmTest.c: Armdroid Test
*
* Copyright (C) Richard Morris 2013 - http://armdroid1.blogspot.co.uk
 ***********************************************************************
*
 */

#include <stdio.h>
#include <wiringPi.h>


//// interface definitions ////

#define SYNC 0x01 // sync - output Low / input High
#define CDIR 0x10 // motor direction
#define CCLK 0x20 // clock driver circuitry

#define PULSE_DELAY 500 // delay in milliseconds


void setup()
{
wiringPiSetup();

// set pins 0-7 as outputs
int pin;
for (pin = 0; pin < 8; pin++)
{
pinMode( pin, OUTPUT );
}

// set Armdroid initially to input mode
digitalWriteByte( SYNC );
}

void drive_motor( int mtr, int steps, int dir )
{
if (mtr < 1 || mtr > 6) // check motor number in range
return;
if (steps <= 0) // no steps, nothing more to do
return;
if (dir < 0 || dir > 1) // check direction flag
return;

// construct control byte
// shift motor address into correct position
// add SYNC and CLCK bits
int output = CCLK + (mtr << 1) + SYNC;

// add direction bit if necessary
if (dir == 1)
{
output += CDIR;
}

int i;
for (i = 0; i < steps * 2; i++)
{
// output control byte, and delay
digitalWriteByte( output );
digitalWriteByte( output-SYNC );
delay( PULSE_DELAY );

// output again with sync bit - returns to input mode
digitalWriteByte( output );

// toggle clock-bit to generate next pulse
output = output ^ CCLK;
}
}

int main()
{
int motor, steps, direction;

setup();
printf( "Raspberry Pi - ARMDROID TEST\n" );

for (;;) /* repeat forever */
{
printf( "Enter motor number (1 - 6) ? " );
scanf( "%d", &motor );
printf( "Enter steps ? " );
scanf( "%d", &steps );
printf( "Enter direction (0 = clockwise, 1 = counter-clockwise) ? " );
scanf( "%d", &direction );

drive_motor( motor, steps, direction );
}
return 0;
}


Very much work in progress, so might not be the final cut, just yet !   The pulse delay of 500 milliseconds is still very slow, but this is good enough for debugging.

Having written this simple test program for 'prototype' variants, I fancy writing another version for Direct-Drive models.   Only the implementation of drive_motor() will need to change,  but, at the moment, I wont be in a position to test it.

I'll be adding the code to the resource page just as soon as I've figured out the best way to share files with eBlogger.




Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Posted in | No comments
Newer Post Older Post Home

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

  • Disarming...
    I started stripping the arm down this morning...  After reading the construction instructions a couple of times  and plucking up some courag...
  • MIT M-Blocks
    I know, I know, my friends....  This has nothing whatsoever to do with Armdroids, but these self assembling cubes revealed today by MIT are ...
  • Pi's up!
    This morning, my eagerly waited for Raspberry Pi arrived... For those who don't already have one, this really is a Credit Card size sing...
  • The Base
    Removing the base would probably have been easier on models without sensors, but with a little persuasion, the board eventually came out: Th...
  • RPi Interfacing
    Progress report on the Raspberry Pi computer control & software A couple of evenings ago, decided to bite the bullet, and power up the A...
  • RPi GPIO & Armdroid Interface
    GPIO stands for General Purpose Input/Output, and a GPIO pin can be set to logic high, or low, with a value of 1 or 0 respectively.  The Ra...
  • RPi Interface - completed
    Today...  Assembled my interface cable allowing connection from the Raspberry Pi interface circuitry to the Armdroid's parallel interfac...
  • Rearming - Part 2
    Nothing is particularly easy...... Having reassembled the arm, I soon discovered a serious problem...  The forearm and shoulder joints was c...
  • Interface "How it works"
    In my last update, I explained how my Armdroid's circuit was identified as a prototype model. I'm going to now describe how this wor...
  • Quick update...
    I thought I'd better touch base and let you know what's happening here...  House redecorating is getting there, but unfortunately we...

Categories

  • Armdroid
  • Electronics
  • Raspberry Jam
  • Raspberry Pi

Blog Archive

  • ▼  2013 (40)
    • ►  November (3)
    • ▼  October (9)
      • Motor Addressing
      • RPi Interfacing
      • RPi Interface - completed
      • RPi GPIO & Armdroid Interface
      • Motor Assignments
      • Raspberry Pi Setup
      • Bench Test (No. 2)
      • MIT M-Blocks
      • Timeout
    • ►  September (9)
    • ►  August (9)
    • ►  July (10)
Powered by Blogger.

About Me

Unknown
View my complete profile