Designing a board for NXT/EV3 with MANY ports


I'd like to design a board for Lego Mindstorms NXT/EV3 that has many I/O ports.

The board, like the original "smart" bricks, would have 2 kind of ports:

  • sensor ports (two modes: analog, and I2C)
  • motor ports

However, unlike the original "smart" bricks, which are quite limited, it would have at least 8 motor ports and 8 sensor ports.

I'm asking help to find a suitable board, or a suitable design for this large number of sensors/motors.

Each sensor port requires an ADC (for sensors operating in analog mode, like temperature and touch sensors), and requires two digital I/O ports for the I2C protocol (SCL, SDA).

So, the sensor ports put a requirement of at least 16 I/O ports, and 8 ADCs.

Each motor port requires two PWM lines thru a motor driver like L293D, and two digital inputs for reading the quadrature encoder output, with programmable interrupts.

So, for at least 8 motors, there is a need for another 16 PWM ports, and 16 I/O ports with programmable interrupts.

In total: 48 I/O ports (16 output ports with PWM, 32 input/output ports with programmable interrupts), 8 ADCs.

Now this requirement is a bit beyond the specs of popular amateur boards like Arduino, Galileo, etc…

How would you recommend to design this solution?
Are there boards with this number of ports at a reasonable cost?

Would be more cost effective to attach further ICs to one of such boards? In detail:

  • a PWM driver like the TLC5940 would satisfy the PWM requirements (and it is daisy-chainable, in case one would like to double the number of motors)
  • external ADC, or perhaps simple analog multiplexer ICs can satisfy the requirement of ADC ports

However, the number of IO ports with interrupts is quite high… I'm not sure if each port needs dedicated ports with programmable interrupts. Maybe there exist a solution to shrink this number of ports to a minimum, by using some kind of multiplexer or other trick..?

Could you comment on this project? Which board would you choose? How would you design it? Which ICs would you add?

I said 8 motor ports and 8 sensor ports, but the more the merrier 🙂

Best Answer

As an Atmel FanBoy, I can give you some biased feedback.

First of all, I'll refer you to @Ignacio-Vazquez-Abrams 's comment: Getting 8 simple to use separate I2C busses is going to be the most challenging. You are probably going to end up having to find a way to multiplex one bus, if that becomes a problem, I advice a trip around google and if that doesn't help a separate question, because all of it is a bit much to cover for me right in this one answer.

Then, many of the Atmel MCU's (of which quite a few different ones are used in fact by Arduino) have enough pins and ADC channels to do what you want. If you want to start development with Arduino tools, you can probably find quite a few Arduino posts and/or instructables about getting your own board design working with the Arduino tooling. I'm not sure if you are going to want to stick with the sketch stuff once you have to handle this many interrupts, though.

EDIT1: I forgot to add, 9 out of 10 of the 8bit AVRs have PinChange Interrupt on all the I/O pins, to my knowledge all ATMega (the larger chips with more than 20pins) devices do. Again to my knowledge all ATXmega 8/16bit devices have even a more advanced PinChange interrupt system, but at least a PinChange interrupt on all pins.

EDIT2: But PinChange interrupt will, depending on device, usually go per 8pins, so you will have to check yourself which pin was the culprit, but running at 12MHz or more, that'll take virtually no time, so if they stay asserted about 1ms, and you know or learn how to write a good interrupt routine, it should be easy. (12000 clock cycles at 12MHz in one ms, so to an MCU 1ms is a WORLD of time!

If you want to find and use an appropriate Atmel 8bit/16bit MCU, go here:

Atmel 8/16bit selector

They have all these options that you can select limits in and then it will just show you which devices fit your requirements. Some are even specifically geared towards PWM motor control with advanced dead-time generation.

I think with your 16PWM channel requirements you are going to end up with an Atmel XMEGA though, not a big problem, they are affordable enough, they are amazingly powerful, they already have hundreds of example uses out there on the web, but... To my knowledge there isn't an Arduino board with one, so I don't know (not an Arduino fanBoy) if the tools can support one.

Alternatively you can use similar tools to select other devices with other vendors. Atmel (and others) also make very extensively equipped ARM Cortex-M processors, such a Cortex-M could get you very high performance from your system, allowing you to, over time with development and such, to approach NXT2.0 or even EV3 software complexity, if you wanted.

Related Topic