LeJOS motor controller

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: 99jonathan, roger, imaqine

LeJOS motor controller

Postby unroller » Sat Nov 27, 2010 1:26 pm

I have done a comparison of LeJOS motor controller and Lego firmware built-in PID controller using a motor emulator. Results may be interesting for many LeJOS programmers. Also, I found a few bugs in LeJOS Motor implementation. The report can be fond in my blog http://nxt-unroller.blogspot.com/2010/11/compare-motor-controllers-of-lejos-and.html
Last edited by unroller on Sat Nov 27, 2010 5:45 pm, edited 1 time in total.
unroller
Novice
 
Posts: 41
Joined: Sat Sep 25, 2010 6:10 am

Postby gloomyandy » Sat Nov 27, 2010 3:51 pm

Hi, very interesting... As it happens I've been doing some work on an alternate motor driver that addresses some of the issues you raise. If you are interested I could make a version available to you to try (though you will need the very latest dev snapshot)...

A few questions...
1. How are you measuring speed?
2. What sample rate are you using for your measurements?
3. What sort of test rig did you use to create the variable load test?
4. In the high load test your results show the motor running at full speed when in reverse. Does this mean that you only apply the load in one direction?

If you have any pictures or video of the test rig I'd love to see them...

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4042
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Postby unroller » Sat Nov 27, 2010 6:46 pm

It's interesting. Is it the controller you described in the lejospid.pdf on your site?

I use motor's emulator. It solves circuit equation and the motion equation like this http://web.mac.com/ryo_watanabe/iWeb/Ryo%27s%20Holiday/NXT%20Motor.html. I use Apache common math library to solve differential equations.
The emulator calculates the speed and position every tick. In Lego controller tick is equal to 1 ms, in leJOS controller it equals to 4 ms. All diagrams are built using 4ms sampling interval.

For emulate variable load I used sine function like this:
Code: Select all
    private double loadForce(double omega, double time) {
        //variable load, bidirectional
        return Tau_d * 2 * Math.atan(10000 * omega) / Math.PI * (1 + Math.sin(time * 5) / 2);
    }


Yes, in high load test the load has been applied in one direction.

I can send you the test sources, if you are interested.
unroller
Novice
 
Posts: 41
Joined: Sat Sep 25, 2010 6:10 am

Postby gloomyandy » Sat Nov 27, 2010 8:59 pm

Hi,
No the driver I've been working on is a highly modified/simplified version of the current leJOS driver...

So are you your tests data driven rather than with a real motor and loads? If so that is pretty cool! I've spent some time this afternoon building various test rigs trying to reproduce some of your results for the existing leJOS driver and have managed to get a pretty good correlation! I'll try and post my versions of the graphs tomorrow if I get chance...

I'm currently struggling a little trying to get my new driver to cope with your load test that prevents the target speed being achieved... Basically it exceeds that capability of the regulator... But I can see that this is an interesting case and I'd like to get my driver to handle that case...

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4042
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Postby gloomyandy » Wed Dec 01, 2010 9:32 am

Hi,
Is there any chance you could make your Java version of the Lego motor controller available? I'd like to include it in the tests I'm currently running...

Thanks

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4042
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Postby unroller » Sat Dec 04, 2010 5:47 am

Hi, Andy

I have sent you the test project by e-mail. It contains some files from LeJOS that have been modified to support emulation.
You can find the test sources in src/test folder, and the regulator itself in src/nxt/regulator/modes folder.
unroller
Novice
 
Posts: 41
Joined: Sat Sep 25, 2010 6:10 am

Postby gloomyandy » Fri Dec 10, 2010 8:56 pm

Hi,
I've finally got around to writing up my results of testing various motor drivers. You can see them here:
http://www.gloomy-place.com/lejosmotor.htm
I'm impressed with how well some of them match up to the simulation from your tests!

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4042
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Postby unroller » Sat Dec 11, 2010 5:04 pm

Great work!

I'm glad to know that my model is pretty close to reality.
Do you plan to put your version of motor controller into LeJOS repository?

I have implemented the smooth reversion algorithm and added a diagram that shows it in action.

I did not include positioning tests because my implementation does not work well if there is an external load and smooth acceleration is turned on.
unroller
Novice
 
Posts: 41
Joined: Sat Sep 25, 2010 6:10 am

Postby gloomyandy » Sun Dec 12, 2010 2:36 pm

Hi,
I've updated my write up to include your additional test, plus a couple of related ones that you may find of interest. Again there is a very close correlation between the simulation and the actual real world test. The final extra test is interesting and I'm really not sure what is going on with the current driver...

I'm not sure my new driver will be included in a release. I'm currently discussing that with the other devs...

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4042
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Postby unroller » Tue Dec 14, 2010 12:11 am

Hi,

How does your driver perform rotation to a some angle with slow acceleration rate when medium or heavy load is applied? Does it arrive at the target angle with zero speed?
In my version of PID controller I have to increase Ki value to make sure that the driver will achieve the target angle under high load, but as a result it arrives at the target point with non zero speed.
Last edited by unroller on Tue Dec 14, 2010 2:44 pm, edited 1 time in total.
unroller
Novice
 
Posts: 41
Joined: Sat Sep 25, 2010 6:10 am

Postby gloomyandy » Tue Dec 14, 2010 8:06 am

Hi,
That sounds like an interesting test. I suspect it depends upon how the load is applied and if the load is a constant one or not. An easy test for me to do like that would be to use my load test rig (similar to the one Philo used). With this rig I can try moving against the load to a specific rotation point using slow acceleration. Is this what you had in mind? I guess another test would be to create an arm with a large weight at the nd of it and to rotate the arm vertically. This would produce a varying set of loads on the motor. As the arm is raised there is a high downwards load which drops towards zero as the load gets to the top, then turns into a negative load as the load is pulled down by gravity. It would be interesting to see how well motor controller stops the load at different positions in the cycle.

Do you have any particular tests in mind? If you can describe a physical test I'll try and build it!

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4042
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Postby unroller » Tue Dec 14, 2010 11:34 am

I tested my controller using the constant load.
I used two scenarios with different load values (0, 0.1 N*m, 0.2 N*m, 0.4 N*m):
1. Rotate to a medium angle (400 degree) using small acceleration value (300 deg/sec/sec). Speed is 600 deg/sec.
2. Rotate to a big angle (4000 degree) using small acceleration value (300deg/sec/sec). Speed is 600 deg/sec.

I found that my PID controller accumulates the integration error and the motor in the second test reaches the target angle with higher speed than in the first test.
unroller
Novice
 
Posts: 41
Joined: Sat Sep 25, 2010 6:10 am

Postby gloomyandy » Tue Dec 14, 2010 11:54 am

Hi,
That sounds like an easy test for me to do. I'll give it a go and see what happens...

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4042
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Postby gloomyandy » Wed Dec 15, 2010 12:35 am

Hi,
I've run a few tests and updated my results. I was only able to run the longer test up to 2500 as this is the max I can easily do with my load test rig. But this is sufficient for the target speed to be reached and I doubt if running for longer would produce different results...

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4042
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Postby unroller » Wed Dec 15, 2010 5:53 pm

Hi Andy,

Thanks for testing! I'm impressed with your controller!
In my current controller I use motion profile generator to calculate a next target point each time the PID regulator is called. It works well, but due to integral wind up the motor cannot reach the target angle with zero speed.
What approach do you use in your controller? Do you plan to publish it?
unroller
Novice
 
Posts: 41
Joined: Sat Sep 25, 2010 6:10 am

Next

Return to NXJ Software

Who is online

Users browsing this forum: Yahoo [Bot] and 3 guests

more stuff