How To: Make NXT – PF Cables


By on March 26, 2011

This guide will tell you how to create your own Lego Mindstorms NXT to Lego Power Functions cable, to control any PF motor or light, how to program it, and what you can do with it.

What you’ll need:

  • An expendable regular NXT cable
  • An expendable PF (could be an extension cord, light, motor of XL motor)
  • Soldering equipment
  • Insulation wire
  • Some very basic electricity knowledge
  • If under 18: permission from parent/ guardian to solder, and cut your NXT/ PF wires

Steps

  1. Get a good workspace set up; make sure you’re either outside or keep some windows open (solder is toxic); also lay something on your table to catch falling solder.
  2. Cut the NXT and PF cables in half, keeping about 5 cm (2 inches) of wire on both.
  3. Strip both wires down to the copper; for the NXT cable, cut off the blue, yellow, green and red wires; strip the black and white ones.
    NXT to PF illustration 1
  4. Connect one of the middle two PF wires to the white NXT wire (it doesn’t really matter which one; if you’re making multiple cables, though, keep┬áconsistent), and connect the other one to the black wire.
    NXT to PF illustration 2
  5. Solder these connections and individually insulate them so they’ll never be able to touch each other.
  6. Twist the wires together and insulate the whole thing to complete your cable, you can heat shrink it if you have the means to.
    NXT to PF illustration 4

Programming

Since both the Lego power functions and Mindstorms NXT work on 9v (6 AA batteries), programming them together isn’t very difficult. All you need to do is use a regular motor function (or motor block in NXT-G) to send power through one of the three possible ports (this won’t work with sensor input ports). One very important thing, though, is to turn off the built in motor PID control, because the program doesn’t get any feedback from the PF it’s controlling. So, it’ll always turn the power to 100 to compromise the speed it doesn’t think it has.

So this (RobotC code)…

task main(){
  int waitMSecs = 50;
  nMotorPIDSpeedCtrl[motorA] = mtrNoReg;
  nMotorPIDSpeedCtrl[motorB] = mtrNoReg;
  nMotorPIDSpeedCtrl[motorC] = mtrNoReg;
  motor[motorB] = 25;
  motor[motorC] = 50;
  while(true){
    motor[motorA] = 0;
    wait1Msec(waitMSecs);
    motor[motorA] = 100;
    wait1Msec(waitMSecs);
  }
}

… would make the PF function connected to…

  • Port A: flicker on and off every 50 mSecs.
  • Port B: turn on to 25% of the maximum power.
  • Port C: turn on to 50% of the maximum power.

So, now you’re able to connect ANY Lego power function straight to you’re NXT, and, without any difficult programming, control it straight from there very accurately, with the possibility to use timers, loops, reverse power, dimming and much more!

Links:

© 2009-2013

Unless otherwise specified, all rights reserved to Leon Overweel.

Links
Social
Search