21
NXT Custom Sensors Charles Manning [email protected] Overview of existing sensors Making your own cables Making your own sensors

NXT Custom Sensors - Voyagerusers.actrix.co.nz/manningc/lego-nxt/NXT_custom_sensors.pdfNXT Custom Sensors Charles Manning [email protected] Overview of existing sensors Making your

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: NXT Custom Sensors - Voyagerusers.actrix.co.nz/manningc/lego-nxt/NXT_custom_sensors.pdfNXT Custom Sensors Charles Manning cdhmanning@gmail.com Overview of existing sensors Making your

NXT Custom SensorsCharles Manning

[email protected]

● Overview of existing sensors● Making your own cables● Making your own sensors

Page 2: NXT Custom Sensors - Voyagerusers.actrix.co.nz/manningc/lego-nxt/NXT_custom_sensors.pdfNXT Custom Sensors Charles Manning cdhmanning@gmail.com Overview of existing sensors Making your

Standard Lego sensors

● Touch switch● Light sensor + output LED● Ultrasonic distance (up to 255 cm)● Sound● Others

– Battery voltage– Time– Quadrature encoders in motors 

Page 3: NXT Custom Sensors - Voyagerusers.actrix.co.nz/manningc/lego-nxt/NXT_custom_sensors.pdfNXT Custom Sensors Charles Manning cdhmanning@gmail.com Overview of existing sensors Making your

Third party

● Bluetooth– Serial port profile– GPS– Cellphone– Laptop

● I2C (hightechnic etc)– Tilt– Gyro– Compass– ...

Page 4: NXT Custom Sensors - Voyagerusers.actrix.co.nz/manningc/lego-nxt/NXT_custom_sensors.pdfNXT Custom Sensors Charles Manning cdhmanning@gmail.com Overview of existing sensors Making your

Connectors

 

       RJ12                     Lego               Lego

Page 5: NXT Custom Sensors - Voyagerusers.actrix.co.nz/manningc/lego-nxt/NXT_custom_sensors.pdfNXT Custom Sensors Charles Manning cdhmanning@gmail.com Overview of existing sensors Making your

Lego “Modified RJ12” connector

● Same size and pins as RJ12 6P6 modular connector● Latch is offset for safety?

– Can't plug in phone/modem/etc.● Pin 1 is latch side.● Cable

– 6­way modular telephone cable ( sicom CAM6)– 1mm pitch ribbon for extra flexibility– Max 1 metre (according to Lego, longer should be OK)

Page 6: NXT Custom Sensors - Voyagerusers.actrix.co.nz/manningc/lego-nxt/NXT_custom_sensors.pdfNXT Custom Sensors Charles Manning cdhmanning@gmail.com Overview of existing sensors Making your

Modified crimp tool

● Standard RJ12 6P6C– NB Not cheap  RJ11 ­ 6P4C tool!

● Small file, time and care– File away space to allow the latch to fit.

● You can always borrow mine.

Page 7: NXT Custom Sensors - Voyagerusers.actrix.co.nz/manningc/lego-nxt/NXT_custom_sensors.pdfNXT Custom Sensors Charles Manning cdhmanning@gmail.com Overview of existing sensors Making your

Sourcing special connectors

● mindsensors.com– Special offset plugs & sockets

● Pugs approx USD0.50● Sockets approx USD1

– Extra cables– ... and other bits & pieces

● hightechtic.com

Page 8: NXT Custom Sensors - Voyagerusers.actrix.co.nz/manningc/lego-nxt/NXT_custom_sensors.pdfNXT Custom Sensors Charles Manning cdhmanning@gmail.com Overview of existing sensors Making your

Connector pinout● Analogue input

– 10­bit ADC (0..1023)– 10k pull­up in NXT– Legacy mode power out!

● Power approx 4.3V– 180mA (total all sensors)

● Digital I/O (x2)– I2C (@9600bps)– Switch enable (DIGITAL0)

● Special firmware– RC servo control, UART,...– Your imagination 

Page 9: NXT Custom Sensors - Voyagerusers.actrix.co.nz/manningc/lego-nxt/NXT_custom_sensors.pdfNXT Custom Sensors Charles Manning cdhmanning@gmail.com Overview of existing sensors Making your

RCX Legacy Mode

● WARNING! WARNING! WARNING!– Analogue Input can also output 9V pulses.– This supports RCX powered sensors connected 

between pin 1 and 2.– Need current limiting resistor on pin 1 for safety.

● YOU HAVE BEEN WARNED

Page 10: NXT Custom Sensors - Voyagerusers.actrix.co.nz/manningc/lego-nxt/NXT_custom_sensors.pdfNXT Custom Sensors Charles Manning cdhmanning@gmail.com Overview of existing sensors Making your

Switch sensor (Lego)

● R1 for Legacy mode safety.

Page 11: NXT Custom Sensors - Voyagerusers.actrix.co.nz/manningc/lego-nxt/NXT_custom_sensors.pdfNXT Custom Sensors Charles Manning cdhmanning@gmail.com Overview of existing sensors Making your

Custom 2­switch sensor● This gives 4 voltage levels

– 1024 = none– 660 = S2– 512 = S1– 400 = both

● Experiment!

Page 12: NXT Custom Sensors - Voyagerusers.actrix.co.nz/manningc/lego-nxt/NXT_custom_sensors.pdfNXT Custom Sensors Charles Manning cdhmanning@gmail.com Overview of existing sensors Making your

LDR Sensor (Custom)

● Not as good as Lego light sensor● No LED

– Easily added● Other resistive sensors

– Thermistor– Potentiometer

Page 13: NXT Custom Sensors - Voyagerusers.actrix.co.nz/manningc/lego-nxt/NXT_custom_sensors.pdfNXT Custom Sensors Charles Manning cdhmanning@gmail.com Overview of existing sensors Making your

Hall Effect Sensor (Custom)

● Detects magnets● LED useful for debugging

– Optional● Tee configuration

– Share port withI2C sensor

● R2 just for safety– RCX legacy mode

Page 14: NXT Custom Sensors - Voyagerusers.actrix.co.nz/manningc/lego-nxt/NXT_custom_sensors.pdfNXT Custom Sensors Charles Manning cdhmanning@gmail.com Overview of existing sensors Making your

Hall Effect (cont.)

● Fridge magnet is alternate strips of North and South.– Can be used as a linear movement sensor

● Use as a start reference for a rotating encoder.● Use your imagination!

Page 15: NXT Custom Sensors - Voyagerusers.actrix.co.nz/manningc/lego-nxt/NXT_custom_sensors.pdfNXT Custom Sensors Charles Manning cdhmanning@gmail.com Overview of existing sensors Making your

I2C sensors

● Maximum flexibility● Maximum challenge● Use 9600 bps I2C connection

– Up to about 1k bytes per second max– Can multi­drop sensors

● 127 in theory, a few in practice– Input and output

● Data layouts– Lego Standard– General purpose I2C devices (LCD, memory, ADC,...)

Page 16: NXT Custom Sensors - Voyagerusers.actrix.co.nz/manningc/lego-nxt/NXT_custom_sensors.pdfNXT Custom Sensors Charles Manning cdhmanning@gmail.com Overview of existing sensors Making your

Why AVR?

● Free tools (gcc etc)– Multi­platform (Linux, Windows, OSX, etc)

● Wide power voltage (1.8V to 5.5V)● Designed for C● Low cost● Packed with peripherals● Fast (1 clock instructions)● Reasonable amount of memory

Page 17: NXT Custom Sensors - Voyagerusers.actrix.co.nz/manningc/lego-nxt/NXT_custom_sensors.pdfNXT Custom Sensors Charles Manning cdhmanning@gmail.com Overview of existing sensors Making your

MBOYS ATIO Sensor

● Uses ATMega48 AVR micro● Interfaces to

– 4 Analogue channels (eg. light sensors)– 8 IO pins– Can expand to more

● Sensor configured by software

Page 18: NXT Custom Sensors - Voyagerusers.actrix.co.nz/manningc/lego-nxt/NXT_custom_sensors.pdfNXT Custom Sensors Charles Manning cdhmanning@gmail.com Overview of existing sensors Making your

Mboys01  schematic (simplified)

Page 19: NXT Custom Sensors - Voyagerusers.actrix.co.nz/manningc/lego-nxt/NXT_custom_sensors.pdfNXT Custom Sensors Charles Manning cdhmanning@gmail.com Overview of existing sensors Making your

Mboys Sensor

● Extensible framework– Simple to modify for 

other purposes– RS232 debugging

● Uses less than ¼ of RAM and FLASH

● Uses less than 10% of CPU

● Lego layout● Read

– 0x00 “MBOYS   “– 0x08 “ATIO       “– 0x10 “1.1”– 0x18 Inputs

● 4xADC● PIND

● Write– 0x40 PIND direction– 0x41 PIND output

Page 20: NXT Custom Sensors - Voyagerusers.actrix.co.nz/manningc/lego-nxt/NXT_custom_sensors.pdfNXT Custom Sensors Charles Manning cdhmanning@gmail.com Overview of existing sensors Making your

Accessing ATIO from Lejos

I2CSensor sensor = new I2CSensor(SensorPort.S1);int poll = 1;byte[] data = new byte[5];boolean done = false;

LCD.drawString(sensor.getProductID(),0,2);LCD.drawString(sensor.getSensorType(),0,3);LCD.drawString(sensor.getVersion(),0,4);

sensor.sendData(0x40,(byte)0x07);sensor.sendData(0x41,(byte)(poll & 0x07));

sensor.getData(0x18,data,5);

Page 21: NXT Custom Sensors - Voyagerusers.actrix.co.nz/manningc/lego-nxt/NXT_custom_sensors.pdfNXT Custom Sensors Charles Manning cdhmanning@gmail.com Overview of existing sensors Making your

Resources

● Books– “Extreme NXT” Gasperi et al– “Maximum Lego NXT” Brian Bagnall

● www– embeddedjanitor.blogspot.com– philohome.com– hightechnic.com– mindsensors.com