New raspbian and Python 3 - does not work

I've been struggling to get my Diddyborg metal working again since I installed the latest Raspbian. I've followed your instructions elsewhere, and got the Python2 code running, but as the libraries I need are python 3 only, I need to use Python 3. I tried recreating the python3 version of the picoborgrev library, but it does not recognise the board:

Loading PicoBorg Reverse on bus 1, address 44
Missing PicoBorg Reverse at 44
PicoBorg Reverse was not found
Are you sure your PicoBorg Reverse is properly attached, the correct address is used, and the I2C drivers are running?
Scanning I²C bus #1
No PicoBorg Reverse boards found, is bus #1 correct (should be 0 for Rev 1, 1 for Rev 2)
No PicoBorg Reverse found, check you are attached :)

Is there something different that is needed for Python 3?

Thanks

Tim

piborg's picture

As far as I know the only changes before were for the print statements into function calls.

It is likely that the Python 3 versions of the io.read and io.write functions need to be using the new bytes datatype instead of the string type.

I have thrown together a new version (attached below), but I do not have any boards to hand to test it with.

If that does not work try torsti76's version that he got working with Python 3 on the BeagleBone: Re-Start aware PIC code

GeekyTim's picture

You are good! Works first time. Now I just need to complete the code to make it drive :-)

GeekyTim's picture

And just to test I converted the diddySequence.py code to python3. It works. Well done Aaron.

Attachments: 
piborg's picture

Great, it is good to hear your Diddy is up and driving again :)

I have updated the older uploaded version with this new copy now as it should work with both new and old versions of Raspbian.

For anyone else who ends up on this post the download link is:
https://piborg.org/downloads/picoborgrev/PicoBorgRev3.py.txt

GeekyTim's picture

I'm wondering if I've found a 'problem', or it could be my misunderstanding. If I use PBR.SetMotor1(1.0) the motor turns for perhaps half a second then stops. Reading the code, the motor should continue turning until you change that value?

piborg's picture

It sounds like the communications failsafe is enabled. What this does is turn both motors off if you do not keep sending new control commands to the PicoBorg Reverse at a regular interval, about 2-3 per second minimum.

This is used in our DiddyBorg joystick script to handle when a wireless controller runs out of range or battery. We also use the functionality on robots like DoodleBorg where we do not want it to run away if the script crashes :)

I would suggest making sure it is turned off in the script before trying to control motors, but after the Init() call:

PBR.SetCommsFailsafe(False)
GeekyTim's picture

That was it! Sweet16 is now driving!

Thanks for your help! Brilliant as usual.

Subscribe to Comments for "New raspbian and Python 3 - does not work"