w9lp
Posts: 3
Joined: Tue Mar 24, 2015 3:35 am

Gertbot Control using Python Drivers

Tue Aug 18, 2015 3:03 am

I've been back through forum posts spanning several years... haven't found anything on point. Apologies if this is duplicative.

I'm using RPi Model 2 and Gertbot board purchased recently to drive two small stepper motors. So far, hardware is set up and operational... I can launch Debug GUI and control both motors from the RPi GUI. I have moved on to writing Python code for an application that will run on the RPi and control the motors via the Gertbot.

I'm a novice programmer so I keep my code very simple and straightforward... no tricky type conversions or exception handling at this stage.

I began with the gertbot.py library and a quick test routine to test the Gertbot serial connection by reading Version and Error Status. Using the standard gertbot.py library, execution hangs while trying to read a response from the Gertbot over the UART. To be honest, several of the gertbot.py functions seem to be under development and may not have been validated.

I've also tried to refactor some of the gertbot.py code using the python-serial library... I've opened the port and used a method to confirm the port is open. However, I get no action or reply from the Gertbot in response to any command. I have confirmed command elements and that I am addressing the correct board ID.

I know the hardware is good thanks to the GUI-Debug app. Anyone have this nut cracked with Python?

Casey

User avatar
Gert van Loo
Posts: 2440
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Gertbot Control using Python Drivers

Tue Aug 18, 2015 12:30 pm

To be honest, several of the gertbot.py functions seem to be under development and may not have been validated.
Apart from some code which was clearly released as 'alpha' code and flagged as having untested routines, all python drivers have been tested.
The only error found thus far is in a DCC routine where the board accidentally was already in the right 'state'.
Anyone have this nut cracked with Python?
Several people have used the python routines without trouble.
There are DCC users, stepper motor users and brushed motor users.
As you report no result whatsoever: do you use Python-3? it will not work with Python-2.

w9lp
Posts: 3
Joined: Tue Mar 24, 2015 3:35 am

Re: Gertbot Control using Python Drivers

Tue Aug 18, 2015 2:57 pm

Thank-you for your prompt reply Gert. Helps to know there are others already using these drivers without issues.

I went back and confirmed that my RPi was NOT invoking Python3 during execution... obviously a problem. I'll rework my own code and try again. Many Thanks!

w9lp
Posts: 3
Joined: Tue Mar 24, 2015 3:35 am

Re: Gertbot Control using Python Drivers

Wed Aug 19, 2015 5:53 pm

Wanted to post a conclusion: Gert nailed it... explicitly invoking Python3 and refactoring my code resolved the issue. Continuing my journey with Gertbot. Thanks Gert!

User avatar
Gert van Loo
Posts: 2440
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Gertbot Control using Python Drivers

Thu Aug 20, 2015 8:24 am

Nice to hear that, thank you.
Most of the time when I give advice, I never hear anything again......

st0rmforce
Posts: 4
Joined: Wed Mar 02, 2016 11:39 am

Re: Gertbot Control using Python Drivers

Sun Mar 06, 2016 4:06 pm

After some fiddling about with the uart I've managed to get the GUI to work and spin my motors.
I then tried using the python drivers, nothing. Tried the python test code from the site, nothing. Tried downloading the updated version and making sure I'm running python 3.4.2. Nothing.

Does anybody have any idea why I can control the gertbot from the gui, but not from python?

st0rmforce
Posts: 4
Joined: Wed Mar 02, 2016 11:39 am

Re: Gertbot Control using Python Drivers

Mon Mar 07, 2016 11:06 am

I managed to fix it, although I haven't had time to work out what the problem was.
I rewrote the python driver myself, working from the control commands from the GUI log output and it works fine.
I didn't use the termios library commands that are in the enable_uart function, I just opened the tty (basically I just used the first line of enable_uart), not sure if that makes a difference.

jeanos
Posts: 1
Joined: Thu Nov 30, 2017 3:25 pm

Re: Gertbot Control using Python Drivers

Thu Nov 30, 2017 3:46 pm

Hello, i'm a user of the gertbot board and i have exactly the same problem : it doesn't work with python.
the toaste program works fine, but i really want to use my own python program even if i just start to program with it : )
I have passed few hours to understand where is the problem with the driver and try differents things but i'm novice in programming
It could be very cool if you can share your own python driver that you wrote.
thank's a lot

User avatar
Gert van Loo
Posts: 2440
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Gertbot Control using Python Drivers

Thu Nov 30, 2017 9:51 pm

I am looking into this.
What version raspberry-Pi are you using?
I assume a Pi-3? If so check if your UART settings are correct.
See here: https://www.gertbot.com/pi3.html
You might also have to add "core_freq=250" to the /boot/config.txt file.

Return to “Gertboard classic”

Who is online

Users browsing this forum: No registered users and 1 guest