User avatar
savageautomate
Posts: 225
Joined: Thu Aug 16, 2012 3:20 pm
Location: USA
Contact: Website

Pi4J now supports a stepper motor interface

Tue Jan 01, 2013 11:38 pm

I recently added support to Pi4J to control stepper motors.
I created an interface similar to the Arduino stepper motor library:

Code: Select all

public interface StepperMotor extends Motor {
    float getStepsPerRevolution();
    void setStepsPerRevolution(int steps);    
    void setStepInterval(long milliseconds);
    void setStepInterval(long milliseconds, int nanoseconds);
    void setStepSequence(byte[] sequence);
    byte[] getStepSequence();
    void rotate(double revolutions);
    void step(long steps);
}

public interface Motor extends Component {
    void forward();
    void forward(long milleseconds);
    void reverse();
    void reverse(long milleseconds);
    void stop();
    MotorState getState();
    void setState(MotorState state);
    boolean isState(MotorState state);
    boolean isStopped();
}
Check out this article for more details and sample code:
http://www.savagehomeautomation.com/pro ... board.html

Image

Stepper Motor Component Interface:
https://github.com/Pi4J/pi4j/blob/devel ... Motor.java

GPIO Stepper Motor Component Implementation:
https://github.com/Pi4J/pi4j/blob/devel ... onent.java
Robert Savage | Follow me @savageautomate
http://www.pi4j.com | http://www.pislices.com
http://www.savagehomeautomation.com

User avatar
malakai
Posts: 1382
Joined: Sat Sep 15, 2012 10:35 am
Contact: Website

Re: Pi4J now supports a stepper motor interface

Tue Jan 01, 2013 11:43 pm

Awesome I may actually learn Java because of all your hard work. :)
http://www.raspians.com - always looking for content feel free to ask to have it posted. Or sign up and message me to become a contributor to the site. Raspians is not affiliated with the Raspberry Pi Foundation. (RPi's + You = Raspians)

User avatar
savageautomate
Posts: 225
Joined: Thu Aug 16, 2012 3:20 pm
Location: USA
Contact: Website

Re: Pi4J now supports a stepper motor interface

Tue Jan 01, 2013 11:47 pm

malakai wrote:Awesome I may actually learn Java because of all your hard work. :)
Excellent!
Java is a very popular language for embedded platforms. It's been a lot of fun developing with it on the Pi : :mrgreen:
Robert Savage | Follow me @savageautomate
http://www.pi4j.com | http://www.pislices.com
http://www.savagehomeautomation.com

Return to “Java”