Raspi I2C connection

Hi Everyone!
I’m building a robot with two brushless DC hub motor wheels that I want to control over the internet using the surrogate.tv platform. The platform has template “bot” code for controlling a two-wheeled robot (Code expained: a two wheeled bot with Surrogate.tv - Hackster.io). However, the code is not set up for an I2C connection between my Raspberry Pi 4B and my motor controller and it also looks like it is for controlling brushed DC motors only with general GPIO pins. Am I correct that I will need to write completely new code or could the template code be modified, and if so, how? Any helpful comments would be appreciated!!
Andrew

3 Likes

Hi Andrew,

Welcome to the forum!

Yeah, you sould be able to chop and change the supplied code to add the functionality from your motor driver. Swapping out the initialisation and class calls to move the robot from the original code would be the best way to port it over.
Do you have a link to the motor driver you picked up?

Liam.

Hi Liam - thanks for responding!

The link to the motor driver is a PDF at https://skysedge.com/robotics/nearzero/NearZero%20-%20Quick%20Start%20and%20Manual%20-%20Firmware%20v2.0.pdf

The link to the python code that comes with the motor driver is here:

The link to the “bot” code (and explanation) on the surrogate platform is here:

Kind regards

Andrew

1 Like

Hi Andrew,

Since your motor controller is “dumb” in that it can only accept commands on how fast (velocity) or “hard” (current) to move a wheel, you might need some code in the middle to translate the directional movement of your users on the internet to wheel movement. This is usually called Differential Drive Kinematics. Here’s a decent paper I found on the maths involved.

Alternatively if you’re just after buttons on the user side to rotate the robot and move it forward and backwards, this would be a lot easier, as you’d just have a direction button trigger something like a speed from one or both wheels in a particular direction.

Keen to see where you go on this one!
James

Hi James

Thanks for your reply and providing the link to the paper below – much appreciated!

Fortunately, it looks like the code supplied with the motor controller has differential drive built in and the template code on the website has 8-way direction commands, but the challenge will be “meshing” the template code (which is not set up for I2C communication) with the controller’s supplied code!

Would be great to collaborate with someone proficient in python programming to get this project up and running and any suggestions would be welcomed!

Kind regards

Andrew

1 Like