Skip to content

[NXT - help wanted]: Implement ADC module #2431

Description

@laurensvalk

There is no ADC driver for the NXT yet. We need a file adc_nxt.c here that implements pbdrv_adc_init and pbdrv_adc_get_ch.

Note: the NXT reads a few channels via the AVR coprocessor, and a few with the main CPU. We would need to sample both and make them available through the aforementioned API. nxos shows how to get the ones from the AVR. The ones on the main CPU can be read from the appropriate registers. The original firmware implements this if further references and configuration information is needed.

The CPU-based ADCs are used for the NXT color sensor (And partial sensor auto-detection).

Activity

  1. added
    help wanted
    topic: sensors
    software: pybricks-micropython
    on Nov 7, 2025
  2. added
    platform: NXT
    on Dec 8, 2025
  3. laurensvalk commented on Dec 16, 2025

    @laurensvalk
    MemberAuthor

    Quite a bit of progress was made in pybricks/pybricks-micropython#438.

    The basic framework has been set up, including structural things like platform port data. We can already read the ADC values on pin 1 of each port, which are coming from the AVR co-processor.

    What remains to be done is to configure the internal ADCs that connect to pin 6 of each port. We could set these up to sample them all sequentially and trigger an interrupt when the last channel is read. The adc_nxt driver can then have a similar process loop as the one for adc_ev3 to request a new sample on every roundtrip.

  4. laurensvalk commented on Sep 21, 2026

    @laurensvalk
    MemberAuthor

    This was mostly done in pybricks/pybricks-micropython@9e397c5.

    But unlike on EV3, we cannot simultaneously use the ADC on pin 6 and the gpio on pin 6 on ports 1, 2, 3. So the Color Sensor currently only works on port 4.

  5. dlech commented on Sep 21, 2026

    @dlech
    Member

    Does the gpio on pin 6 need to be input, output or both when using the NXT color sensor?

  6. laurensvalk commented on Sep 21, 2026

    @laurensvalk
    MemberAuthor

    Just input, and only briefly while we read the calibration table.

    So it is fine to have them locally switch. But it needs some work to disable only that ADC channel during this time or else the gpios just read zeros.

  7. dlech commented on Sep 21, 2026

    @dlech
    Member

    I was wondering if we could just read the ADC instead and say if value < X mv, then same as gpio low, else high. Maybe conversion rate is too slow though?

  8. laurensvalk commented on Sep 21, 2026

    @laurensvalk
    MemberAuthor

    That is a good idea. Will give it a go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedplatform: NXTsoftware: pybricks-micropythontopic: sensors

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions