Submitted by Lars on Fri, 08/20/2010 - 07:46
Posted in
Hi! I found the forum while doing a search and I am glad you folks are here. Months ago I had a project idea and it has turned into a hobby kinda using stepper motors of course. I started to learn Objective C hoping in the future to create a GUI for controlling steppers. This forum seems like a great place to flush out ideas and help to problem solve.
What I am hoping to do from my Mac OS X right now is to get s stepper motor that I can control from my mac using objective C code. Perhaps you kind folks can direct me to some recommended hardware from stepper motor, driver, USB connection and what ever software I would need to be able to use Objective C to control the stepper motor.
Thanks very much!
-Lars

Well, to be clear - you would
Well, to be clear - you would need to be able to create a GUI, using objective C, and then as long as Objective C provides some means of interacting with some communication port (which I presume it does =) - either Serial, USB, Network, Wireless, Bluetooth, etc. then you just have to figure out how you want to communicate with a device. There really are a _lot_ of options on that front.
You can go with a traditional option, that is used a lot in CNC - direct control of stepper drivers via a parallel port, but I'm pretty sure no modern Apple is shipped with a parallel port, so you're more than likely going to have to have something that you can interface with via a USB or Serial-over-USB port. You're not going to be able to do effective, real-time control over stepper drivers directly via a USB port. (There are, after all, only two data lines in a USB cable, and the money you'd spend on a USB-enabled break-out board will buy you lots of better options with more control.) You'll need something attached to it that does the actual control, and then you control that device via your program. This is the standard methodology these days, there are lots of options for this something - and microcontrollers are popular, easy to use, easy to find, and inexpensive these days. I'm going to recommend the Arduino, I'm sure others will point out one or more of the thousands of other options out there - then, you would just connect it to your USB port, and then use standard Serial port capabilities within Objective C. (The arduino uses a USB port, but it includes a USB->Serial converter chip, so it's treated like a normal serial port.)
Then, you've got lots, and lots of options - there's plenty of code on here to load on the Arduino, and plenty elsewhere that'll drive a stepper, and then you just send the right serial data to tell it to do what you want it to do. (In fact, the TimeLapse Engine, on here, is specifically designed to be controlled via software running on a computer via a simple serial protocol.)
As for drivers, the options are many, but any step/direction driver is interchangeable with another, so you're not forced to make that decision now.
!c
Thank you very much for that
Thank you very much for that information and breaking down the different steps from computer GUI to stepper motor and the parts in between!!!
I was surprised when I did an internet search the lack of Objective C programs that could do this work. Seems like most people default to Visual Basic, C or C++.
I went to sparkfun.com to find a good starting point for hardware, I am guessing this would be a good start.
http://www.sparkfun.com/commerce/product_info.php?products_id=9951
Thanks again.
-Lars
Lars, I'm not sure why
Lars, I'm not sure why Objective C is rarely used, but I think it's penetration outside of the Apple world is not quite as deep, and it's just a matter of number of people interested vs. numbers of platforms in play =)
That's a good kit, there are also other good kits out there too, that will offer you some different options, like the ones from ladyada: http://www.adafruit.com/index.php?main_page=product_info&cPath=17&products_id=68 (she has another with example layouts for a breadboard, etc.)
For the drivers, a good driver to start with is with the easydriver, sparkfun sells them, and they're quite inexpensive. Pololu also has a great driver with more power for about the same price in the A4983 http://www.pololu.com/catalog/product/1202
While the Arduino is programmed in C++, they've added a lot of stuff to the IDE and the language to make it easier to use and your experience with Objective C should carry through just fine. It's as easy as saying
digitalWrite(PIN, HIGH);to change the state of a pin. This way you can focus on handling user input and the really cool work on the computer w/ obj c.If you want to start learning how to do camera-related things w/ the arduino, here's one tutorial that walks you through building a basic circuit and the different ways to do timing for a camera intervalometer: http://openmoco.org/node/88 There are lots of tutorials on this subject out there, but I hope this one provides a little more detail for you. If you don't want to deal with the microcontroller side any more than setting it up, I can help you understand how to control the openmoco engine software.
Of course, don't hesitate to ask if you run into any troubles, or need any help with anything.
!c
Thanks again! That explains
Thanks again! That explains why Objective C is not used as much. Not because it can't, but because people have been using other software for a long time. This site seems perfect for help and helping others wanting to do motion control projects!
Quick question about the 'Drivers' Even if I get the basic kit which comes with a Servo and a DC Motor I would still need a Driver for a Stepper Motor? I thought I would just be plugging in the Stepper to the bread board part of this kit to run it. What is the purpose of the driver that the Kit by itself can not do?
Thanks much!
Driving a stepper motor is
Driving a stepper motor is different than driving a normal DC motor, and different than your average servo. Namely, they require the right sequence of voltages applied to different wires to move to the next pole. They do not move continuously, instead their movement is made of very discrete motions, this requires control of at least 4 separate control lines for a stepper motor. Due to the fact that very few of them can be powered by less than 40mA (the maximum current draw from any arduino pin), and none that would be powerful enough to move a camera at that current draw, you will need at least an H-Bridge type circuit to let it draw power from the power source, and just control the flow of power via the logic pins.
A stepper driver not only allows you to separate logic and motor power supplies, but they also abstract you from the complex logic of turning the right poles on at the right time. Distilling motor control down to two control lines: one for direction of the movement, and one for instructing the motor to take a step. Most also provide microstepping and chopping capabilities. Microstepping allows you to position the motor _between_ two of its poles, so for example, with a 200 step/revolution motor (1.8' stepper) 4x microstepping gives you 800 positions per revolution. Of course, while microstepping increases resolution, it decreases accuracy, but it has other advantages in that it allows you to accelerate faster than full stepping by helping to avoid resonance within the motor - through smoother transitions from pole to pole. A chopping driver runs the motor at up to dozens of times its rated voltage, while monitoring and limiting current draw to prevent stalling or damage to the motor. This allows you run, say, a 6V motor at 12V - the benefits of which are greater velocity and max speed allowed while keeping available torque (stepper motors lose torque as speed increases due to back-emf created in the motor, running at much higher voltages helps to compensate for this). I almost always run in a chopping mode - which means I almost always supply at least 2x the voltage on the badge of the motor. That means for a 12V system, I choose motors rated at 6V or less. It is necessary to increase the voltage by at least 2x the rated voltage to take advantage of chopping control.
Basically, a $15-20 entry-level driver keeps you having to figure out how to create complex timing for pole-to-pole transitions, and provides features that would take an entry-level developer months to implement correctly. =)
!c
Again thanks for the detailed
Again thanks for the detailed explanation of the stepper. Do you run any of your stepper motors with encoders to make sure you have an exact position? Does the Driver also except the encoder information or is that passed to another board?
-Lars