Using multiple Inventor HAT Minis

Hi, thanks very much for responding. I’ll respond in order.

I’d never thought about connecting an N20 motor (well, a driver) directly to an IO Expander, but as it has PWM support, yes, that makes good sense. But you might want to document that somewhere, it was news to me (and I’m a big fan of the IOE).

On a PR, that’s a good idea. I could also just email the one changed file (__init__.py) to tech support. I’ve actually done a local copy of the library into my own project directory so I’d have to re-clone the repo.

I hadn’t thought of board.ioe.set_i2c_addr(), yes, a better choice.

I did kinda both. I used the sharp end of a Knipex tweezer to de-pin all four cables I had and fix it. Twiddly. The front two motors on the robot need a longer cable as the Pi and IHMs are at the back of the robot, so I ordered a pair of 10cm reversed cables from AliExpress and they arrived today. Again, I just think this should be documented, as some of your customers will have Pololu motors and wonder why they don’t work. It appear Pimoroni and SparkFun are the same, Pololu reversed. But given they’re a major supplier of N20s and have the widest range, lots of people will be using them.

Regarding Plasma, a shame. I don’t want to be running my robot OS under sudo. Though I’m not on this small robot using the servo or GPIO pins anyway and the motor LEDs work fine. I’ve got a Tiny FX W on the robot so the blinkin lights are its job.


There’s one thing that I found curious. I spent much of yesterday on it and finally gave up.

There’s the normal code for setting up the pair of IHMs:

aft_controller = InventorHATMini(address=0x17, init_servos=False, init_leds=False)
fwd_controller = InventorHATMini(address=0x16, init_servos=False, init_leds=False)

…and then I grab the motors off of each and all is fine.

But when I created a MotorController class and put those two lines inside the class so that its __init__() method created them, then grabbed the motors off of the class instance, the motors didn’t move. I added print statements all over inside the IHM and Motor classes and they printed identical results between the root script and class approaches, i.e., I could find nothing different at all.

The only solution (after much of a day trying) was to pass the aft_controller and fwd_controller objects to the class constructor from the startup script, which worked. What this says is that it’s impossible to instantiate the InventorHATMini objects within a Python class. The solution is not ideal, but workable.

I’m a journeyman/intermediate Python programmer and I frankly was baffled by this.