Loginskip to content

Digital I/O on Input Port - part I

news/
hacking/
NXT Repository/Tutorials/

Perhaps the least documented or used feature of the NXT is the possibility of direct digital input/output using pins 5 and 6 of the input ports. When working in “Custom” sensor type, these two bits can be manipulated directly using IOMapRead and IOMapWrite ‘invoke’ commands in NXTToolkit, which in principle means a NXT-G block can also control these pins. At startup these pins are set as digital input.

In the image above you can see a nice application - using a input port to get rotation readout from the built-in tachometer encoders of the NXT motor. These encoders are usually connected to pins 5 and 6 of the output ports, and they change from 0 to 1 with a small phase difference in a 2 degrees cycle. Below is a simple (and not perfect!) LabView code which monitors the encoders (assumed connected to port 1) and counts up/down showing the rotation count on screen (click to enlarge):

To use other ports, one need to specify the currect IOMap position - offset 12 for port 1, 32 for port 2, 52 for port 3 and 72 for port 4.

In the next posts I will detail more on the hardware internals involved and digital output from the input port, as well as how to do the same tricks with RobotC (whose next planned release is supposed to support input from these two bits very easily).