STS-Pi & Explorer Hat Pro - PWM issues using Flask

Hi, I’m using Flask to host a web page that can control the STS-Pi. I have got as far as the controls with out the web cam, but…
The problem I have is that the motors already don’t run smoothly or consistently…from the research I’ve done, I am fairly certain it is because of the “software PWM” not operating correctly due to the PI3 B+ not being fast enough for the load
Does anyone have any suggestions on how I can solve this problem (note: I am not an expert). I think there are a few options which might work, but I’m not sure how to achieve them yet
1) change to hardware PMW, I have seen some info on this in relation to “pigpio” but it looks complicated
2) turn off the PMW and just have full speed and stop
3) use something other than Flask as the server (as long as it is simple)

How are the motors wired to the Pi?
What are you using for a motor controller?
I ask because you should have an H Bridge or something between the motors and the GPIO pins. And its not obvious, to me anyway, how your doing it from what you posted.

The explorer Hat Pro is being used as the motor controller (it is built into it)

Ok, on the product page its show as “other things that could come in handy” so I figured I better double check if you had it.
I have a couple of two wheel rovers built around the explorer phat and a Pi Zero. Start stop is fine for me, using the Pimoroni explorer phat python code. I only run into issues when trying to run a motor at reduced speed for slow turns etc. Anything above half speed seems OK, below that sometimes a motor will stall and stop.

Yes, it works fine if I take Flask out of the picture and just run a python program to control the motors…I think using Flask / a web server is creating to much load on the pi and it is not able to keep up with the software driven PWM for the motor speed?

Sounds plausible. I’ve only ever used a wireless keyboard to control my rovers remotely.

I don’t think that will reach Australia from the UK 😁

Did a bit more looking it to this and found this on the RPi.GPIO library which is used by the Explorer Hat Pro…ouch!! maybe I can hack the explorerhat code to use pigpio instead?

Thats for sure above my skill level. I do hope you figure out a working solution. I’m thinking your going to have delays no matter how you do it, if through the Internet.

If anyone is interested in this, the solution is effectively outlined here: