Motion Control systems

Discussion in 'Mac Programming' started by larswik, Aug 20, 2010.

  1. larswik macrumors 68000

    Joined:
    Sep 8, 2006
    #1
    Hi, This is still way above my skill level but thought I would ask a few questions since this is where I hope to be heading with my programing skills.

    I have been looking on the net for information regarding Objective C programs being able to control stepper motors for a simple motion control rig. My hope was to have a GUI on a Mac transfer data via bluetooth/USB to a device to move stepper motors.

    I am not finding a lot on the net about Objective C doing this. Most all of it is C++, visual basic and so on. Can it be done in Objective C?

    Thanks!

    -Lars
     
  2. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #2
    It's not the language so much, it's the drivers.

    Also remember that any code written in plain C is also Objective-C code, with identical semantics. And Objective-C++ has the same relationship to C++.

    So step one is to figure out the drivers. Or if there aren't any, to write some. If it's in plain C, you can always come back later and put an Objective-C wrapper around it, if that simplifies things.

    For example, AMSerialPort wraps some nice Objective-C classes around serial-ports. The serial-driver can be anything, including a device driver that's actually a USB-to-serial converter chip.
    http://www.harmless.de/cocoa-code.php

    A lot of amateur motion control is done with VB or C++ because those are widely known by amateur programmers, and there happens to be readily available drivers. So it's kind of a chicken-and-egg problem.

    IOKit is the basis for drivers on Mac OS X, and it's not the easiest thing to dive into. However, you can often find readily available drivers for chips like the PL2303 USB-to-serial converter, and just hang a microcontroller with a builtin UART on the other end of the serial port. Otherwise you have to get hold of microcontrollers with builtin USB and write the whole friggin' driver yourself. Or cobble it together from parts left by some earlier pioneers. For an amateur, it's usually easier to go the serial-port route.

    You can also do fun things with MIDI devices, not all of which are audio synthesizers. Years ago someone showed me a lighting controller that was MIDI based. Not cheap, because it was for professional stage shows, but he programmed it just like any MIDI device.


    What are the stepper motors connected to? What's the motion control rig for? My guess is a camera, but I've seen stranger things.
     
  3. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #3
    Have you considered LabView? http://www.ni.com/mac/labview.htm Probably overkill, but ...

    B
     
  4. larswik thread starter macrumors 68000

    Joined:
    Sep 8, 2006
    #4
    Chown33, thank you very much for taking the time to detail this out for me. I was thinking of getting this as a starter kit

    http://www.sparkfun.com/commerce/product_info.php?products_id=9951

    It included a Arduino USB where I can download OS X drivers from the site. It comes with a project book with built in code, here is an example code..

    Code:
    int ledPin =  13;    // LED connected to digital pin 13
     
    // The setup() method runs once, when the sketch starts
     
    void setup()   {                
      // initialize the digital pin as an output:
      pinMode(ledPin, OUTPUT);     
    }
     
    // the loop() method runs over and over again,
    // as long as the Arduino has power
     
    void loop()                     
    {
      digitalWrite(ledPin, HIGH);   // set the LED on
      delay(1000);                  // wait for a second
      digitalWrite(ledPin, LOW);    // set the LED off
      delay(1000);                  // wait for a second
    
    Do you think this would be a good place to start?

    Thanks again for your help!

    -Lars
     
  5. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #5
    If you are going to get an Arduino you'll probably want to avoid using the language above (Processing?) and compile your own C or C++ cross compiler.

    Details in my blog if you want to get an understanding of whats involved. I still need to update parts of it though.
     
  6. lloyddean macrumors 6502a

    Joined:
    May 10, 2009
    Location:
    Des Moines, WA
    #6
    Cromulent

    I'm confused by your statement above! That language above is C++. The project makes use of an SDK to simplify things for those just getting into AMTEL embedded programming.

    The included IDE is very simplified and completely cross-platform and more than adequate for beginners. The Macintosh version of the IDE is a bundle containing an entire set of terminal accessible AMTEL cross assemblers, C/C++ compilers and linkers. Pretty near complete with the standard C (but not C++) library.
     
  7. larswik thread starter macrumors 68000

    Joined:
    Sep 8, 2006
    #7
    Thanks for the link to LabView. I think you are right and it is a little over kill.

    Cromulent - Thanks for that info and I went to your blog and it looks vast. I hope I can track down the information. I am only about 1/4 the way through Objective C Programing 2.0 but most of that code on that project page looked very familiar.

    It would be fun to buy that kit and use the command line that I am learning on to turn on/off LED's and spin motors to start. If you have a direct link to the info on your blog I could start to read it.

    Thanks again folks for all the great advice and help I get here!

    -Lars
     
  8. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #8
    Hmm I can't remember where I read it but I could have sworn that the Arduino made some modifications to the C language to make it easier. Ah well.

    Anyway the reason I stuck with using AVR libc, AVR GCC and AVR GDB (and the reason I still recommend them) is that using the Arduino libraries felt like cheating. The whole point of embedded programming (for me at least) was to practice skills that are pretty rare in normal desktop programming. Plus the AVR instruction set makes it much easier to do assembly programming, which you will definitely need the AVR GCC tool chain to accomplish.
     
  9. xStep macrumors 68000

    Joined:
    Jan 28, 2003
    Location:
    Less lost in L.A.
    #9
    That would be the first link in his signature.
     
  10. lloyddean macrumors 6502a

    Joined:
    May 10, 2009
    Location:
    Des Moines, WA
    #10
    That would be true only if the user preference hasn't disabled it!
     
  11. xStep macrumors 68000

    Joined:
    Jan 28, 2003
    Location:
    Less lost in L.A.
    #11
    Cool. I didn't recall that was an option.
     

Share This Page