ev3dev / ev3dev-lang-python

Pure python bindings for ev3dev
MIT License
422 stars 146 forks source link

Trying to use Hitechnic FIRST Motor Controller for TETRIX #793

Closed Ammar-AlDabbagh closed 1 year ago

Ammar-AlDabbagh commented 1 year ago

After bashing my head against the wall for a week trying to communicate with these ancient devices using arduino, I gave up to try to talk to the things using EV3DEV. I got as far as installing everything, and everything seems well, but when using smb, I can't read anything off of it, everything responds as 0s.

>>>from smbus import SMBus
>>> bus1 = SMBus(4) #I tried bus NO. 0-8, all either fail or respond 0s
>>> bus1.read_i2c_block_data(0x01, 0x08, 32)
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

I find this odd because in #430 he seems to get them working perfectly.

Yes, their mode is set to i2c-other. However, it notes "Status: no-sensor".

Sidenote: I realize that I may have bricked them during my 'experimenting' with connecting them to Arduino ports with no resistors at 5v, amongst other things, but I have loads of them so I did switch them out for new untouched ones, but still no luck.

dlech commented 1 year ago

In the issue you linked, they are reading from register 0x42 instead of 0x08. It seems perfectly reasonable that reading from unused registers would return all 0s.

If it still doesn't work, the best thing to do is use a logic analyzer to see what is actually happening on the wires.

Ammar-AlDabbagh commented 1 year ago

See the spec sheet: link. According to that, 0x08 will respond with "HiTechnc" . 0x42 is used for encoders for this model, and I don't plan to use them. I'll hooking up the drivers with other non-tetrix motors anyway.

Curiously, this mirrors the problems I had with integrating them using Arduino, everything responds with nothing, crashing the connection. I don't know how to use a logic analyzer yet, but there is one at the lab, I'll hook it up tomorrow and see what happens.

Oh and one last thing, I did try a couple different registers. No matter which I pick, all zero. Also did try to daisy chain two of them, because maybe that changes the addresses to be more correct? But nope, nothing worked then either.

Ammar-AlDabbagh commented 1 year ago

Turns out, the motor controllers have built in logic that detects if a battery is connected. It will not function if it doesn't detect one.