You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is no ADC driver for the NXT yet. We need a file adc_nxt.chere 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).
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.
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.
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?
Activity
laurensvalk commentedon Dec 16, 2025
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_nxtdriver can then have a similar process loop as the one foradc_ev3to request a new sample on every roundtrip.laurensvalk commentedon Sep 21, 2026
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.
dlech commentedon Sep 21, 2026
Does the gpio on pin 6 need to be input, output or both when using the NXT color sensor?
laurensvalk commentedon Sep 21, 2026
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.
dlech commentedon Sep 21, 2026
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?
laurensvalk commentedon Sep 21, 2026
That is a good idea. Will give it a go.