Adding another motor to the pbrJoystick.py?
Forums:
Hi all
I'm building an underwater ROV and have two of the three motors working that I need, which are the forward/reverse, and I changed it a bit to get a turn function.
I'm looking through the python file and I can't figure out how to address a second reverse board. I've set up the boards in a daisy chain and they each have their i2c address. So how would I go about adding this third motor? I just want it on and off at 100% + -, so i'd like to add it to a button, like square and triangle, or the D pad.
Any help? Much appreciated.
groome1320
piborg
Mon, 01/19/2015 - 17:20
Permalink
Adding another PicoBorg Reverse to pbrJoystick.py
That sounds like an awesome project, it is great to see people doing fun things with Raspberry Pis.
The first thing you want to do is change the starting part of the script to talk with the two PicoBorg Reverses.
Assuming they have I2C addresses 10 and 11 this would look like:
You can now use them all in a script like so
The next thing to do is to go through the file and change any lines which use
PBR
to usePBR1
instead.At this point the script should function normally, but the second PicoBorg Reverse will not be doing anything.
Next duplicate the
MotorsOff
andSetLed
lines at the end of the script, but forPBR2
like this:Then duplicate the
ResetEpo
line forPBR2
a little further above:Assuming we have our third motor attached to M1 +/- we want to add another drive value to the top of the loop:
and then apply it after the left / right motor values:
As an example I will define three positions on the D-Pad, for +100%, 0%, and -100%.
We want to do this in the joystick settings section at the top:
Finally we then add some code to detect these button presses and alter the
driveThird
value:Now we should have a script which uses the D-Pad to control the third motor on a second PicoBorg Reverse.
I have attached the original pbrJoystick.py modified like this as a reference.
groome1320
Tue, 01/20/2015 - 08:51
Permalink
Wow, thank you so much for th
Wow, thank you so much for the reply. Looking at this and comparing it to what I was writing, I got most of it but got thrown by the last section. I'll let you know how it goes and I'll post some pics of my build. Btw. The boards are amazing for how big and cheap they are.
Thanks again.
groome1320