PDA

View Full Version : Programing question for stepper motor controler




larswik
Mar 18, 2008, 01:12 AM
Hello, I started learning Java a couple of years ago and got to the point of building simple random number generators and so on. During that time my mom passed away and my goals shifted.

I have a project that I am working with some friends on. We are working on controlling a stepper motor and everything is fine from the motor to digital driver that connects via RS-232.

My question is, I would like to control this motor via wireless Bluetooth. I would like to create a simple JAVA app that has a slider that can run from my laptop or maybe iPhone or Touch in the future.

I have read problems of using JAVA/Bluetooth on this site so I thought I would ask.

How should I approach this project?

Thank you.

-Lars



jeremy.king
Mar 18, 2008, 10:09 AM
How should I approach this project?


You will most likely have to use a third party library thats compatible with OS X. AFAIK, there aren't any freely available bluetooth implementations out there - see http://www.javabluetooth.com/ for more info.

larswik
Mar 18, 2008, 10:18 PM
Thanks for that post. There seems to be only 1 company that supports OS X for bluetooth. But I guess it is due able with just the one.

Thanks for the insight.

-Lars

Muncher
Mar 18, 2008, 11:08 PM
Are you trying to directly control a stepper motor using a serial port? If so, that's low-level, and Java might not be the right language for that. If you have a decoder on the other end, it would be a different story.

ScoobyMcDoo
Mar 19, 2008, 06:15 AM
So, on the OS X side, I'm not sure why you would need a 3rd party product. You can use OS X's bluetooth stack. The docs are here (http://developer.apple.com/referencelibrary/HardwareDrivers/idxBluetooth-date.html). What did you have in mind for the side of the motor? Does the motor supplier have a bluetooth interface for their motor, or are you planning on designing your own hardware?

jeremy.king
Mar 19, 2008, 09:28 AM
So, on the OS X side, I'm not sure why you would need a 3rd party product.

Maybe because his intention was to use Java.

ScoobyMcDoo
Mar 19, 2008, 10:19 AM
Maybe because his intention was to use Java.

So, you can't use the bluetooth stack from Java? Just curious why that is? I only use Java from time-to-time, so don't know all the ins-and outs, but I thought you could get to just about any system service using JNI.

jeremy.king
Mar 19, 2008, 10:26 AM
So, you can't use the bluetooth stack from Java? Just curious why that is? I only use Java from time-to-time, so don't know all the ins-and outs, but I thought you could get to just about any system service using JNI.

Well you *could* use it. JNI would be the way to talk to those libraries, but you end up writing a bunch of extra code (http://developer.apple.com/technotes/tn2005/tn2147.html) to accomplish it and you definitely lose any portability.

I agree that Java is not the best choice of technology, but he asked for a Java solution and there aren't many out there.

Berlepsch
Mar 19, 2008, 01:35 PM
I guess the easiest way is using the RFCOMM protocol for Bluetooth. All you need a RFCOMM capable bluetooth module as a receiver on the motor side for that. Then you set up a Serial Port connection from the Bluetooth preferences, and for the Java side you install the com port support from rxrtx.org.

That should be sufficient to get a start, if you want to add more sophisticated bluetooth support, you are probably better off with (objective-)C and XCode.

larswik
Mar 21, 2008, 02:52 AM
Let me clarify what my intentions are. For this project, I am looking to create a remote control focus for my camera. I have a 35mm adapter for my video camera and in order to use my steady cam I need to do remote focusing since I can not have wires running to the camera.

The goal was to use many off the shelf components from stepper motor, Digital driver unit with an RS-232 port and then a RS-232 Bluetooth connector. On the other end of the wireless connection is a laptop or perhaps the iPhone if Apple release the SDK's and Java works on the phone.

I know a little about Java programing and that is the program that I was hopign to continue working with. It seems like everything I need is off the shelf except for a simple program with a touch screen slider (or mouse) to move the stepper in real time.

Thanks,

-Lars

Berlepsch
Mar 21, 2008, 06:29 AM
Let me clarify what my intentions are. For this project, I am looking to create a remote control focus for my camera. I have a 35mm adapter for my video camera and in order to use my steady cam I need to do remote focusing since I can not have wires running to the camera.

The goal was to use many off the shelf components from stepper motor, Digital driver unit with an RS-232 port and then a RS-232 Bluetooth connector. On the other end of the wireless connection is a laptop or perhaps the iPhone if Apple release the SDK's and Java works on the phone.

I know a little about Java programing and that is the program that I was hopign to continue working with. It seems like everything I need is off the shelf except for a simple program with a touch screen slider (or mouse) to move the stepper in real time.

Thanks,

-Lars

Lars,

this is just the type of setup I had in mind. If you google for "RS232 bluetooth module", you'll find a lot of possible bluetooth receivers that you can use. The trick is that they work like a "wireless serial" connection on top of the bluetooth protocol. Once you have set up your Mac (or other bluetooth enabled device with support for serial connections), you send your RS232 commands for the motor controller directly through the serial port that you have configured on the Mac, e.g. /dev/tty.Bluetooth-Serial.

To do that in Java, you need support for accessing the serial ports; e.g. by using the libraries you can download from www.rxtx.org.

This is just an outline of how you can get your task done; you will have to fill in the details yourself.

larswik
Mar 22, 2008, 01:46 AM
Wow that is great news, thanks for your reply. I will look into that site and see what I can find.

Thanks!

-Lars

rahulkattikar
Jan 22, 2009, 11:33 AM
hello friends my name is rahul,
i am doing one project our project is remote controlled gun in which one gun is mounted and the vertical and horizontal motion are controlled by steeper motor.

we are controling two stepper motor through microcontroller . but i want to control that through pc ,means through mouse. according to mouse that motors should turn as soon as i click the mouse that trigger should fire.


i know it is difficult but still i have hopes that any one cah help me

and one imp thing is that i have to submit the project up to 10 feb so ....pls.

notjustjay
Jan 22, 2009, 12:09 PM
hello friends my name is rahul,
i am doing one project our project is remote controlled gun in which one gun is mounted and the vertical and horizontal motion are controlled by steeper motor.

we are controling two stepper motor through microcontroller . but i want to control that through pc ,means through mouse. according to mouse that motors should turn as soon as i click the mouse that trigger should fire.


i know it is difficult but still i have hopes that any one cah help me

and one imp thing is that i have to submit the project up to 10 feb so ....pls.

First, way to resurrect an old thread instead of creating one of your own.

Second, what you want to do is fairly easy. Some simple Google searches and reading ought to be all you need.

Assuming you already have the microcontroller in a state where you can command the steppers in either direction, you just need to develop a communications protocol between the microcontroller and the PC. I believe most modern uC's have a TCP stack, or you can use serial or parallel ports. Some boards support industrial protocols like a CAN network.

Of course you must have considered whether to use relative or absolute positioning. In either case, how do you intend to calibrate it? Step counting (dead reckoning)? Shaft encoders? Sensors? A feedback control loop?

Then you just write your PC app to monitor mouse movement and translate them into commands to send to the microcontroller.

Good luck.