Trying to use 4 timers for PWM and fifth for Irq

Questions and discussion about The WiPy 1.0 board and CC3200 boards.
Target audience: Users with a WiPy 1.0 or CC3200 board.
Post Reply
windy54
Posts: 14
Joined: Thu May 28, 2015 8:01 pm

Trying to use 4 timers for PWM and fifth for Irq

Post by windy54 » Sat May 16, 2020 8:21 am

Hi,
During this Covid 19 lockdown I have been trying to finish my I completed projects.
When I first received my WIPY I tried building a bob the biped robot but never completed it.

So, I have resurrected my WIPY and updated to the latest firmware.
I found some great Arduino code and decided to use that as a basis for a python version.

I need to control 4 servos using PWM and use a fifth timer to determine when to move.

The timer IRQ works, I can write a script that will move the two feet or hip servos.
When I write a script controlling all four servos one of them does not move.
If I run the script controlling two servos they work.

At the moment I do not know whether I have got a faulty servo or wiring, so I was thinking of hooking the robot up to an Arduino.

Am I running out of memory on the WIPY, I need to investigate how to check this.

I am using a servo library I found on GitHub.


So my general question is has anyone managed to do something similar? I can post more details on timers I am using or code if it helps.


Sent from my iPad using Tapatalk

windy54
Posts: 14
Joined: Thu May 28, 2015 8:01 pm

Re: Trying to use 4 timers for PWM and fifth for Iraq

Post by windy54 » Sat May 16, 2020 8:54 am

I hate auto correct, IRQ not Iraq !


Sent from my iPad using Tapatalk

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: Trying to use 4 timers for PWM and fifth for Iraq

Post by OutoftheBOTS_ » Sat May 16, 2020 8:59 am

1 timer can control 4 servos as they will all be on the same freq just different duty width.

You shouldn't really need a timer callback to time the freq of moving the robot as you should just be able to take the time when entering your loop then next time around you wait till the time is what you need.

windy54
Posts: 14
Joined: Thu May 28, 2015 8:01 pm

Re: Trying to use 4 timers for PWM and fifth for Iraq

Post by windy54 » Tue May 19, 2020 6:03 pm

Thanks for response.

I agree one timer could generate the 50Hz, how is the duty cycle generated, in software?

The documentation is recommending the use of timers so it is all handled for you in hardware.
When the channel is in PWM mode, the corresponding pin is assigned automatically, therefore there’s no need to assign the alternate function of the pin via the Pin class. The pins which support PWM functionality are the following:
GP24 on Timer 0 channel A.
GP25 on Timer 1 channel A.
GP9 on Timer 2 channel B.
GP10 on Timer 3 channel A.
GP11 on Timer 3 channel B.
I am using GP 24, 9, 10 and 11, hence the four timers.

Agreed I could use a "While True:" loop, read time at start and end of my processing, calculate how long to wait and then wait.

I prefer the IRQ and callback which increments a counter. There is still a"while True:" loop and the counter determines what to do.

I got the robot walking using an Arduino but had to use a better power supply due to intermittent faults, that maybe my problem with the WIPY so I am going to try it again.

Post Reply