Unregulated Motor not working with LCP

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

Moderators: imaqine, 99jonathan, roger

paula11
New User
Posts: 3
Joined: Mon Jul 24, 2017 5:26 pm

Unregulated Motor not working with LCP

Postby paula11 » Fri Sep 01, 2017 4:33 pm

Good evening,

I'm having trouble compiling and executing the following code as a Java Application (I'm using nxjpcc unregulatedMotor.java to compile and nxjpc unregulatedMotor to execute).

Code: Select all

import lejos.nxt.Button;
import lejos.nxt.LightSensor;
import lejos.nxt.MotorPort;
import lejos.nxt.NXTMotor;
import lejos.nxt.SensorPort;

public class unregulatedMotor {
   
   static LightSensor light;
   static NXTMotor mB;
   static NXTMotor mC;
   
   public static void main(String args[]) 
       {
      light = new LightSensor(SensorPort.S4);
      mB = new NXTMotor(MotorPort.B);
      mC = new NXTMotor(MotorPort.C);
      Button.waitForAnyPress();
      while (light.getLightValue() < 50){
         mB.setPower(50);
         mC.setPower(50);
      }
      mB.stop();
      mC.stop();
       }   
}


I have used LCP with leJOS before, but it does not seem to work with unregulated motors even though the class NXTMotor is available in leJOS PC API.

Could anyone help me please?

Best,
Paula

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

Re: Unregulated Motor not working with LCP

Postby gloomyandy » Fri Sep 01, 2017 7:12 pm

Looking at this code:
https://sourceforge.net/p/lejos/nxt/cod ... m/LCP.java
Which is the NXT side of the LCP code for leJOS, it looks to me as if you can only use regulated motors with leJOS.

But to be honest trying to run any sort of fine closed loop control over LCP is probably not a good idea. Why not split your code and have the time critical parts run on the NXT and have any UI or other parts run on the PC with your own protocol linking the two. That is pretty much how every program of any size I've ever written for the NXT/EV3 works.
leJOS news https://lejosnews.wordpress.com/

paula11
New User
Posts: 3
Joined: Mon Jul 24, 2017 5:26 pm

Re: Unregulated Motor not working with LCP

Postby paula11 » Mon Sep 04, 2017 2:45 pm

gloomyandy wrote:Looking at this code:
https://sourceforge.net/p/lejos/nxt/cod ... m/LCP.java
Which is the NXT side of the LCP code for leJOS, it looks to me as if you can only use regulated motors with leJOS.

But to be honest trying to run any sort of fine closed loop control over LCP is probably not a good idea. Why not split your code and have the time critical parts run on the NXT and have any UI or other parts run on the PC with your own protocol linking the two. That is pretty much how every program of any size I've ever written for the NXT/EV3 works.


So you usually implement a Master/Slave architecture with a Bluetooth connection?

My unsuccessful first attempt was running a line follower with PID control running only in PC. Considering that PID control depends on almost immediate actions, it's probably wiser to run this code directly on the brick.


Return to “NXJ Software”

Who is online

Users browsing this forum: No registered users and 4 guests