[BrickPi+] Java Motors

Hello,
I’ve been trying to write some code in BrickPi Java. However, motors do not turn. Is there any documentation on how to use the motors in BrickPi Java?
Thanks,
KingRandomGuy

Could someone give some sample code with working motor turning (in java ofc)? Thanks.

There are example for running the motors here: https://github.com/DexterInd/BrickPiJava/tree/master/src/main/java/com/ergotech/brickpi/motion.

Can you try these out and let us know if they work for you.

-karan

I am probably missing something, but I do not see the examples. Aren’t those classes for the motor and motor port types? Any assistance is appreciated.

Can you check this example: https://github.com/DexterInd/BrickPiJava/blob/d304f7f49dd3e9ddb84e4f60d170190aaeab08d3/src/main/java/com/ergotech/brickpi/BrickPiTests.java

-Karan

Another user Maarten Storm has been working on getting the Java drivers working. I’m finally getting back to playing java and brickpi. A couple of things Maarten discovered. The pi4j libraries that are in github are old and don’t support all sensors. The baud rate supported by the old pi4j drivers weren’t sufficient. I started trying to get the latest pi4j working with brickpi, but wasn’t able to do anything due to work. Next week I have some time and plan to write some tutorials on my blog once I get it working.

You might want to ping maarten and see how he progressed on his new rewrite.

peter

Hey Peter, thanks for checking in on this issue! Any advice you have about Java for the BrickPi, we would love to hear it!

Hey Peter. Please post a link to your blog once you get it working.
Thanks,
KingRandomGuy

I got side tracked by work and broke my colarbone in a bicycle crash. Finally back to playing with Java and BrickPi. I haven’t had much luck with getting pi4j snapshot working with the old BrickPiJava code. I had to update it to use the latest pi4j serial class, but the motor doesn’t turn. Hopefully Maarten Storm can shed some light on his progress.

I’m going to have dive into pi4j and brickpi_python to see what is going on.

peter

Can’t help you with Java, but I’m really sorry about the collarbone break! OUCH!

I managed to get just the motor working with the older pi4j library and the old code. With the 1.0 pi4j snapshot, changes are needed to get it to work correctly. just sharing information in case other run into the same issue

I think I might know why the newer pi4j jar doesn’t work. The baudrate is too low. I am going to try making a new build with higher buad rates and see if that solves the issue. https://github.com/Pi4J/pi4j/blob/develop/pi4j-native/src/main/native/com_pi4j_jni_Serial.c

That would be a good catch for sure! Please do report back, regardless of the result. And good luck!

Hi! Any update on this? My girls are planning on starting to program with BlueJ on Thursday… We just cloned the github directory in class today.

Thanks!

Hey @woolfel, were you able to get this working with Pi4J at all?

If you use the old code with the old pi4j that is in the repository, the motor works ok. Not all of the sensors work with the old version. The newer pi4j baud rate isn’t high enough, so it doesn’t work. I haven’t had time to hack the new pi4j to allow higher baud rate. Hope that helps.

Hi, sorry I put this post in the wrong thread (posted it originally in the thread where John asked me to tell him how our first “light up” of the BrickPi went). We are running into a small problem with our BrickPi Java code being unable to import the Motor Control libraries… The compiler tells us that it cannot locate the files. Any code not requiring the motor control libraries seems to compile just fine, so it seems to be a motor issue (which is why I’m re-posting this here).

This happens with both the MotorTest Java files and the Example Project included in the GitHub files. Did we miss a post-git step before trying to run BlueJ?

Thanks!

I checked in the sample eclipse project I created to test the old PI4J library with the old code. You can find it here.

I haven’t made a pull request yet, but it works on my RaspPi 3 with the latest raspbian

I was able to fork and update Pi4J 1.1 to support higher baud rates. It builds and creates the jars, but I haven’t got the new driver for BrickPi working yet. One hurdle down and several more to go.

For those interested in the changes I made to pi4j for brickpi, here’s the links

hopefully this week I will have time to work on updated brickpi drivers using the latest pi4j