Advice on Trilobot

Hi,
My name is Stephen and I am an A level Computer Science teacher. We have recently purchased some Trilobots and (on backorder) Rpi 4 8Gbs to help introduce the students to robotics and physical computing, as well as other areas (Operating Systems, sensors etc. etc.)
I have two things I would like some advice on please.

Firstly, the Pi 4s will have to triple duty as both project resource, hackable desktop computers and robot brains. To make this easier, I intend to design and print “pod” cases (or possibly a lid for the standard case) that will allow us to clip the RPi on the top of the trilobot, where the battery normally lives. My intention is to relocate the battery to between the layers, effectively swapping the battery and Pi. I have extension GPIO cables I can then plug in to the Pi and the Triolobot board (there will be slot in the lid of the pod to take the cable)

Can anyone see any problems with this idea?

Secondly, and much harder, I have replaced the standard motors with MMMEs. I now want to try and read the encoders. I have added an IO Expander to each bot to help. Essentially, for basic speed control, I need the IO Expander to time between encoder state changes and allow the time values to be retrieved by the Pi. What is the simplest reliable approach for this? Can this be done without writing custom code for the Nuvotron?

Ahoy Stephen! Our robotics supremo Chris says this:

The IOExpander has built-in support for counting encoders. There is also the option to count_microsteps , which gives higher resolution for this type of application: https://github.com/pimoroni/ioe-python/blob/bd83c2934277140c31874ca0f06e6e8e0df6482f/library/ioexpander/__init__.py#L410

Can anyone see any problems with this idea?

Seems sound, though the top board doesn’t have GPIO holes, so you’d have to adapt the 2x20 to cables, then back to 2x20. Or 3D print your own top board using the mechanical drawings.

Thanks Hel and Chris

I was going to take a GPIO extender cable over the side.

Thanks, the code samples look helpful. The one challenge I have now is I have translate everything; we code in Java rather than Python, but we have gotten pretty good at doing that.

On the MMMEs, what is the encoder output like? How many pulses per motor rotation and is it a single signal or two like some I have seen elsewhere?

No worries - hope you manage to get it working! :)

MMMEs output a standard two pin quadrature signal, which lets you know speed and direction. The decoding of this is handled by the firmware of the IO Expander, meaning you just get a count value back that increases or decreases over time.
As for counts, the magnetic discs we use you get 12 counts per revolution of the motor’s drive shaft, so multiply that by the gear ratio to get the final counts per revolution (e.g. 12 * 50 = 600).