two axis diagonal joging steper program
Owen
Posts: 100
Can anyone lead me in the right direction in the programing of a jog mode i'm building in a stepper motor aplication? I want to be able to control two stepper motors one for Xaxis and one for the Yaxis that pan and tilt a camera. The jog is controlled by a realbasic program from my computer through a serial connection. I have been able to write a program that will jog move the camera either X or Y but not both at the same time (to create a diagonal move). the next catch is I also need to return the number of steps each moter has taken so my control program can keep track of the current XY position, which works in my current program but only one axis at a time. Any one tried somthing similar? shouldn't be any different than joging x and y at the same time on a CNC i think. I included my toplevel object and the Joging modes object in case anyone has some time to look over it. Any help would be much apreciated
many thanks,
Owen
many thanks,
Owen
Comments
Keep track of the position by having a variable with the running total of step pulses, add for + direction subtract for - direction.
Graham
p.s. No IDE on this PC
I don't know who big of camera you want to mount but before you reinvent the wheel check out http://www.servocity.com/html/spt200_pan___tilt_system.html. It is suppose to work on camera up to two pounds.
Another idea for you that could help if you want to build your own is http://www.austriamicrosystems.com/03products/products_detail/AS5040/description_AS5040.htm This way you always know the current position without counting steps (what happens after a reset when you don't know where you are pointing?)
I guess one final suggestion is the Robotis Dynamixel servos like the AX-12 or the DX-117. You can control both of the servos you will need using a single half-duplex serial port and you can pre-program both servos with a speed and destination position and then start them at the same time. I am planning to modify the new proto board to support both servos for some robots I want to build
On boot up, you home all motors to a limit switch or current sense trigger of a hard stop. The reference to home should set all variables to 0.
Send X a string of 10000, the motors moves 10000 steps, of course you have to write a ramp and decel, so for example ramp for 1000, run for 8000, decel for 1000.
Or, send X = 10000 followed by Y = 10000. What I do is send a tab delimited string with motor ID plus position followed by CR. The Propeller identifies the ID, and updates the variables for each motor.
Here is a RB method that could be on a button for example:
MoveX
MoveY
MoveZ
MoveR
MoveX
You can have a slider set with your prefered range of steps for each motor, say from 0 to 100000. When you change a slider, write on ValueChanged something like this below. I set it so if I have a button pressed called AutoMove, the change of a slider will send it's new position value out. The values can also be sent by a button called Send All for example.
Then, on the Propeller side, read the strings, convert to decimal, apply a case statement to the ID's. The main cog updates X position, the X cog picks up the new position and moves the motor autonomously. When in motion, the X cog is still looking to see if any new position has arrived, if so, it acts accordingly, if the position is in the other direction, a decel is applied, and a move to the position takes place.
You can assign arrow keys to the RB app so that it scans the keyboard so many mS. You assign the keys to update a slider value for example add 50 for each timer iteration. A timer period of 33ms is good. Create a timer that loops a method like this called navKeys, and run each motor from the arrow keys:
Post Edited (originator) : 1/23/2007 3:09:00 PM GMT
in regards to Grahm's post, my problem wasn't isn't the math to make it move at 45 degrees it's the way to comunicate from my serial comunication to the main object to the object controlling the stepper motors. The dificulty for me is that I am sending a serial command to move the motors and when the toplevel object gets that command it starts the object to manualy control the motors in two new cogs one for each axis. and when the motors are to stop a serial command is sent to the object conrolling the motors to stop.
I just solved my problem about 30 min ago
I know my questions have been a bit general but if anyone has any example of somthing similar they have tried to do or ideas to simplifiy or improve what I have already done and has the time, I would be interested. I'm new to this and all the examples and input everyone has given me has gone a long way.
this is a great forum and thanks for everyones help,
Owen
I must have been posting as originators post came in
this realy helps me
Thank you