How would I use an older (v1) version of the Hi Technic NXT Infrared Seeker v2 in ev3dev with micropython?

223 Views Asked by At
  • ev3dev version: 4.14.117-ev3dev-2.3.5-ev3
  • ev3dev-lang-python version: All output of dpkg-query -l {python3,micropython}-ev3dev*:
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                   Version          Architecture     Description
+++-======================-================-================-=================================================
ii  micropython-ev3dev2    2.1.0            all              Python language bindings for ev3dev for MicroPyth
ii  python3-ev3dev         1.2.0            all              Python language bindings for ev3dev
ii  python3-ev3dev2        2.1.0            all              Python language bindings for ev3dev

Problem

I am trying to somehow connect the old version of the HiTechnic NXT Infrared Seeker, part number MS1042. I have been able to find vanishingly little information on this module.

Background Info: Device Browser -> Sensors reveals just one sensor connected (a LEGO Ultrasonic Sensor), when this IR seeker is fully and securely plugged in. Device Browser -> Ports -> ev3-ports:in1 (where the ultrasonic sensor is connected) shows ev3-input-port as driver name, ev3-uart as status. Device Browser -> Ports -> ev3-ports:in2 (where this IR seeker is connected) shows ev3-input-port as driver name, nxt-i2c as status, which looking at the documentation for the new IR seeker, seems correct.

Code:

#!/usr/bin/env python3

###############
### IMPORTS ###
###############

from ev3dev2.sensor import Sensor
from ev3dev2.motor import LargeMotor, OUTPUT_A, OUTPUT_B, SpeedPercent, MoveTank
from ev3dev2.sensor import INPUT_1, INPUT_2, INPUT_3, INPUT_4, Sensor
from ev3dev2.sensor.lego import UltrasonicSensor
from ev3dev2.led import Leds

left_motor  = LargeMotor(OUTPUT_A)
right_motor = LargeMotor(OUTPUT_B)
us = UltrasonicSensor(INPUT_1)
ir = Sensor(INPUT_2, driver_name='ht-nxt-ir-seek-v2')
ir.mode = 'DC'
us.MODE_US_DIST_CM = 'US_DIST_CM'

while True:
    print(ir.value(0))
    # print( str(us.value()) + " mm")

Error:

Traceback (most recent call last):
  File "/home/robot/Project_3/main.py", line 16, in <module>
    ir = Sensor(INPUT_2, driver_name='ht-nxt-ir-seek-v2')
  File "/usr/lib/python3/dist-packages/ev3dev2/sensor/__init__.py", line 78, in __init__
    super(Sensor, self).__init__(self.SYSTEM_CLASS_NAME, name_pattern, name_exact, **kwargs)
  File "/usr/lib/python3/dist-packages/ev3dev2/__init__.py", line 223, in __init__
    chain_exception(DeviceNotFound("%s is not connected." % self), None)
  File "/usr/lib/python3/dist-packages/ev3dev2/__init__.py", line 54, in chain_exception
    raise exception from cause
ev3dev2.DeviceNotFound: Sensor(ev3-ports:in2) is not connected.

Variations of 'ht-nxt-ir-seek-v2' such as v1, removing the v2, seek -> seeker, do nothing for me. Fundamentally, it is failing to recognize the device as connected. I'm not sure where to go from here. Writing my own driver seems daunting, and hopefully unnecessary given that this device has been in wide use before - I'm just not certain how to find such a driver, or integrate it into ev3dev/micropython.

EDIT: This seems similar to an issue discussed on the ev3dev GitHub page concerning UART rather than i2c. However, my expertise is not advanced enough to really understand what's going on.

EDIT 2: You can see the solution to this problem at the end of the GitHub issue I opened.

0

There are 0 best solutions below