NRLink and PF Motors

This is where you talk about the NXJ hardware related topics such as the brick, sensors, LEGO pieces, etc.

Moderators: 99jonathan, roger, imaqine

NRLink and PF Motors

Postby alvegh » Fri Jul 25, 2008 10:11 pm

Hi

I am trying to make the PF Motors work with a Mindsensors NRLink

I looked at the RCXLink and also the ncx-examples for the NRLink for inspiration, but I cannot get any reactions from the motors.

The NRLink seems to be transmitting data according to its flashing LED's but nothing seems to be received by the PF-receiver.

Any help would be appreciated.

Best regards
Alex

My basic sensor-wrapper looks like this
Code: Select all
public class NRLink extends I2CSensor {

    private static final byte NRLinkCommandReg = 0x41;
    public static final byte NRLinkDefault = 0x44;
    public static final byte NRLinkFlush = 0x46;
    public static final byte NRLinkShortRange = 0x53;


    public static final byte NRLinkSelectPF = 0x50;

    private static final byte NRLinkMacro = 0x52;

    public static final byte Motor_Ch1_A_Float = 0x50;
    public static final byte Motor_Ch1_A_FWD = 0x53;

    private byte[] buf = new byte[2];

    public NRLink ( I2CPort port ) {
        super ( port );
    }

    public int runMacro ( int addr ) {
        buf[ 0 ] = NRLinkMacro;
        buf[ 1 ] = ( byte ) addr;
        return sendData ( NRLinkCommandReg, buf, 2 );
    }

    public int runCommand ( byte command ) {
        return sendData (NRLinkCommandReg, command);
    }
}


And this is my simple testprogram
Code: Select all
    public static void main ( String[] _Args ) {
        NRLink link = new NRLink ( SensorPort.S1 );

        LCD.drawString ( link.getVersion (), 0, 0 );
        LCD.drawString ( link.getProductID (), 0, 1 );
        LCD.drawString ( link.getSensorType (), 0, 2 );

        link.runCommand ( NRLink.NRLinkFlush );
        link.runCommand ( NRLink.NRLinkDefault );
        link.runCommand ( NRLink.NRLinkShortRange );
        link.runCommand ( NRLink.NRLinkSelectPF );

        while ( !Button.ESCAPE.isPressed () ) {
            link.runMacro ( NRLink.Motor_Ch1_A_FWD );
            try {
                Thread.sleep ( 2000 );
            } catch ( InterruptedException e ) {
            }
            link.runMacro ( NRLink.Motor_Ch1_A_Float );

            try {
                Thread.sleep ( 2000 );
            } catch ( InterruptedException e ) {
            }
        }
    }
alvegh
New User
 
Posts: 6
Joined: Fri Jul 25, 2008 10:02 pm

Return to NXJ Hardware

Who is online

Users browsing this forum: No registered users and 1 guest

cron
more stuff