Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

larswik

macrumors 68000
Original poster
Sep 8, 2006
1,552
11
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
 

larswik

macrumors 68000
Original poster
Sep 8, 2006
1,552
11
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

macrumors 65816
Apr 19, 2007
1,465
0
California
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

macrumors 65816
Nov 26, 2007
1,188
37
Austin, TX
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. 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?
 

ScoobyMcDoo

macrumors 65816
Nov 26, 2007
1,188
37
Austin, TX
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

macrumors 603
Jul 23, 2002
5,479
1
Holly Springs, NC
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 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

macrumors 6502
Oct 22, 2007
303
48
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

macrumors 68000
Original poster
Sep 8, 2006
1,552
11
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

macrumors 6502
Oct 22, 2007
303
48
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 http://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

macrumors 68000
Original poster
Sep 8, 2006
1,552
11
Wow that is great news, thanks for your reply. I will look into that site and see what I can find.

Thanks!

-Lars
 

rahulkattikar

macrumors newbie
Jan 22, 2009
1
0
help me

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

macrumors 603
Sep 19, 2003
6,056
167
Canada, eh?
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.