Wishful Coding

Didn't you ever wish your computer understood you?

Cyber 310

We got 2 robotic arms from a school lab that did them away. After we got them, they had been accumulating dust for ages in our shed, with one failed attempt at making them work in between.

This was my second attempt. As you can imagine, there aren’t nearly as many people writing about robotic arms as there are writing about Clojure or Node.js, so documentation is sparse.

The most useful (English!) resource I found was this collection, which has original manual pages he got from a museum(!). I contacted him for a couple more pages, which where very helpful.

I can only say it was very hard to find out how easy it was to control this arm.

Basically, you have one pin for every motor, and 2 control pins. To send a command you just set the motor pins, and then turn the corresponding toggle pin on and off.

To reverse motor 2:

01000000
01000001
01000000

To turn motor 3 one step:

00100000
00100010
00100000

Once I figured that out, I probably spent most of my time installing stuff on Windows, then installing Ubuntu and installing there.

To make PyParallel work, I had to rmmod lp and to run as root.

The code, might you have a dusty Cyber 310 in your shed:

import parallel
from time import sleep

base = 1
shoulder = 2
elbow = 4
leftwrist = 8
rightwrist = 16
grip = 32
prf = 64
strobe = 128

p = parallel.Parallel()

def direction(m):
    p.setData(m)
    p.setData(m+strobe)
    p.setData(m)

def step(m):
    p.setData(m)
    p.setData(m+prf)

def move(steps, *motors):
    dir_pattern = abs(sum([m for m in motors if m < 0]))
    step_pattern = sum(map(abs, motors))
    
    direction(dir_pattern)
    for i in range(steps):
        step(step_pattern)
        sleep(0.01)
import os, pygame, cyber
from time import sleep

os.environ["SDL_VIDEODRIVER"] = "dummy"
pygame.display.init()
pygame.init()
j = pygame.joystick.Joystick(1)
j.init()

#axes = {cyber.base:0, cyber.shoulder:1, cyber.elbow:2, cyber.leftwrist:3, cyber.rightwrist:4, cyber.grip:5}
axes = {cyber.base:0, -cyber.shoulder:1, -cyber.elbow:4}

def dead_int(real, deadzone=0.5):
    if real > deadzone:
        return 1
    elif real < -deadzone:
        return -1
    else:
        return 0

print 'Initialized Joystick : %s' % j.get_name()
try:
    while True:
        pygame.event.pump()
        #sleep(0.01)
        movements = [k*dead_int(j.get_axis(v)) for k, v in axes.iteritems()]

	x, y = j.get_hat(0)
	if x == 0 and y != 0:
		wr = (cyber.leftwrist+cyber.rightwrist) * y
		movements.append(wr)
	elif x != 0 and y ==0:
		movements.append(cyber.leftwrist * x)
		movements.append(cyber.rightwrist * -x)

	if j.get_button(0):
		movements.append(cyber.grip)
	elif j.get_button(1):
		movements.append(-cyber.grip)	

        cyber.move(1, *movements)
        
except KeyboardInterrupt:
    j.quit()
Pepijn de Vos