motor control via processing

hi, i'm pretty new to both arduino and processing. i'm working on putting together a piece involving several dc motors for an upcoming art installation. i already have been able to get the motors spinning with arduino and some hbridges, but i'd like to interface with processing so that i can trigger the motors based on visual input. my trouble at the moment is with the interfacing.

it seems like the best way to do this would be to stick all of the hbridge legs on the first 8 inputs (there are 4 motors total). then i can just send a byte to PORTD (http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1160606668/2) each time to change the direction/start/stop the individual motors. i am confused on how to get the proper data format to PORTD, though, as it only accepts hex values and (i think) processing can only write ints, chars, bytes, and byte[]'s to the serial port. is there a simple way to make this conversion?

sorry for the very elementary nature of this question - i am still quite new at this. any help would be very much appreciated, though!!! thanks!

i forgot that i can't use pins 0 and 1 for digital IO while doing serial communication, so i am guessing this changes things quite a bit. looks like i'll have to flip each pin individually instead of writing to the entire port.

any recommendations?

hi

what kind of drivers are you using? Do you have a schematic by any chance?

My best guess would be to use the processing Serial library to send characters, then decode them in the Arduino to do certain things.

what about this: //pin setup Arduino pins 2,3 are outputs Arduino pin 2 is motor one enable Arduino pin 3 is motor one direction

//Control characters sent by processing: A1=motor one fwd = pin 3 high, pin 2 high A2= motor one bkwd= pin 3 low, pin 2 high A3= motor one off= pin 2 low

Code something like //motor A if "a" received over port{ if "1" received over port{ set pins to run motor fwd} if "2" received over port{ set pins to run motor bkwd} if "3 received over port{ set pins to diable motor driver}

//motor B if "B" received over port{ if "1" received over port{ set pins to run motor fwd} if "2" received over port{ set pins to run motor bkwd} if "3 received over port{ set pins to diable motor driver}

and so on....

hope this helps

D

hi, thanks for the kind reply!

i had actually just gotten things working when your message came through :)

i am using the SN754410NE quad half h-bridge this is the type of motor i am using: http://www.robotstore.com/store/product.asp?pid=1387&catid=1565

i ended up sending a byte array from processing with 8 elements: 0,1 = motor 1 2,3 = motor 2 4,5 = motor 3 6,7 = motor 4

depending on the values of each of these the motors change direction or stop. i am sending the same pwm signal from pin 9 to the h-bridge enables for all of the motors since they do not need to operate at different speeds.

the next step is tackling the rest of the logic for how i want to trigger the motors in processing.

thanks again for your help!