locus sonus > audio in art
Lab 2007/2009: Julien Clauss, Alejandro Duque, Scott Fitzgerald, Jérôme Joy, Anne Roquigny, Peter Sinclair.
 
 
 http://locusonus.org/
 contact: info (at) locusonus.org

|2004|2005|2006|2007|2008|2009|


// 2008/02/12 20:37 / 83.79.30.191
!!step motor meets the ArtBus

Using the [ArtBus|http://sprocket.telab.artic.edu/Artbus/], a micro-controller designed at the Art Institute of Chicago (in development), for controlling a step motor. The project began during the FACE workshop, it will be hopefully used to control a video camera (or a microphone, or anything) remotely via an IRC (Internet Relay Chat) bot. (more soon) /ad

!!!software
In this case we use python code to send the messages to the ArtBus but is possible to use puredata or any other software that can talk to the serial port. Robb coded an OSC interface that serves as a mediator to allow comminication via the OpenSoundControl protocol. The code will be added to this page as soon as is properly tested.

!!!schematics
[http://nujus.net/~locusonus/dropbox/alejo/esquema_stepper%231.png]

!!!uses

Here, a little video clip that shows the interaction flow from irc chat lines (!east or !west) to python commands sent via serial communication to the ArtBus (or arduino, or whatever microcontroller board)

http://www.archive.org/details/ircbot2webcam


!!!code

The code below was tailored by favian voegeli with the help and comments of alejo duque (step motor patterns) based on code and ideas shared with robert drinkwater. It is a base example. The other half is the supybot configuration file that will allow the irc bot to send messages to the serial port.

{{
#! /usr/bin/python

import serial #import serial library
import sys, time


# sequence of patterns, each for 4 pins
# (adapt to your needs)


#http://en.nanotec.com/steppermotor_animation.html
#patterns = ((1, 1, 0 , 0), (0, 0, 1 , 1), (1, 1, 0 , 0), (0, 0, 1, 1), (0, 0, 0, 0)) # 4 steps to the Left=West
patterns = ((0, 1, 0, 1), (0, 1, 1, 0), (0, 1, 0, 1), (1, 0, 0, 1), (0, 0, 0, 0)) # 4 steps to the Right=East

# !Zz; resets all to see that is there

#patterns = ((0, 0, 1 , 1), (1, 1, 0, 0), (0, 0, 1, 1), (1, 1, 0, 0)) # invertido
#patterns = ((0, 1, 1, 0), (1, 0, 0, 1), (0, 1, 1, 0), (1, 0, 0, 1)) # ok!
#patterns = ((1, 1, 0, 0), (1, 0, 0 , 0))
#patterns = ((1, 0, 0, 0), (1, 1, 0, 0), (0, 1, 0, 0), (0, 1, 1, 0), (0, 0, 1, 0), (0, 0, 1, 1), (0, 0, 0, 1), (1, 0, 0, 1))

# artbus command prefixes
command = ('j', 'k') # j = low(0), k = high (1)

# serial config
ser = serial.Serial() # instanciate serial class as ser
#ser.port = '/dev/ttyUSB0' # connection device
ser.port = '/dev/cu.usbserial-FTPUZJAK' # connection device
ser.baudrate = 115200 # sets the speed
ser.timeout = 0.1 # to not occupy the line forever

# open serial connection
try:
ser.open() # opens serial port
except serial.SerialException, e:
print e # prints an error if it doesn't work

# create artbus_commands...

for sequence in patterns: # iterate over `patterns`...


for bit_number in range(len(sequence)): #...names pins and use each `tuple`
bit = sequence[bit_number]
cmnd = command[bit]
artbus_command = '!S' + str(cmnd) + str(bit_number+1) + ';'
# print and send artbus_command to serial connection
print artbus_command
ser.write(artbus_command) # !-bang J-analog board z-reset & semi-end_command
# read & print response
response = ser.readline() # reads the serial buffer
print response
# sleep a while
time.sleep(0.5)
print "" # next sequence of patterns


# close serial connection
ser.close()



'''
For this script these is the command in the python console:
sh-3.2# python fabian2.py

--

will create an output like:

!Sk0;
!Sj1;
!Sj2;
!Sj3;

!Sj0;
!Sk1;
!Sj2;
!Sj3;

!Sj0;
!Sj1;
!Sk2;
!Sj3;

!Sj0;
!Sj1;
!Sj2;
!Sk3;

'''

}}


!!!references:
http://en.nanotec.com/steppermotor_animation.html
http://www.x-robotics.com/motorizacion.htm
http://flickr.com/photos/pcomp/104968959/in/set-72057594070996918/
http://www.tigoe.net/pcomp/code/category/code/arduinowiring/51
http://www.instructables.com/id/S8UNBAPF3L1GTGI/

!!!gracias:
Robb Drinkwater, Ed Bennett, Locus Sonus, Scott Fitzgerald, Fabian Voegeli, Alejandra Elpueblodechina Perez.

[http://sprocket.telab.artic.edu/Artbus/front/AB_analog.jpg]