Bolverk
Posts: 5
Joined: Fri Apr 25, 2014 2:28 pm

Two python RPIO questions.

Sat Apr 26, 2014 9:43 am

Hello!
I'm coding DC motor controller using RPIO PWM library. There are two problems I have.
First: When my code runs this line:

Code: Select all

PWM.add_channel_pulse(0,17,0,PwmValue)
PWM works fine, but in terminal it echoes this:

Code: Select all

add_channel_pulse: channel=0, gpio=17, start=0, width=700
Is it possible to remove this echo in terminal? It messes up with other output.

Second question - more tough. I have code that slowly ramps PWM. Simple example code:

Code: Select all

PwmCount=100
while (PwmCount<1700):
       PWM.add_channel_pulse(0,17,0,PwmCount)
       time.sleep(0.05)
       PwmCount+=10
It works BUT sometimes PWM does not slowly ramp up, it starts to ramp, then for cycle (maybe few cycles) it's on like 100%, continues to ramp and it may fail few more times until code stops increasing its value and PWM becomes stable. Does anyone have similar problem and is there any workaround on this? I do not own DSO, so at the moment I can not provide more detailed report on this.
Thanks!

Bolverk
Posts: 5
Joined: Fri Apr 25, 2014 2:28 pm

Re: Two python RPIO questions.

Sat Apr 26, 2014 10:40 am

OK, I got rid of the messages using:

Code: Select all

PWM.set_loglevel(1)
But problem with unstable PWM ramp is much more frustrating...

User avatar
joan
Posts: 14935
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Two python RPIO questions.

Sat Apr 26, 2014 10:53 am

if you can't sort the ramp problems give the pigpio Python module a try.

ghp
Posts: 1498
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: Two python RPIO questions.

Sat Apr 26, 2014 6:51 pm

Hello,

when I need stable pulse widths, I use RPIO-Library. It has DMA-driven PWM-code. Do not use DMA-channel 0, as this is used by recent raspbian dma-driven x-optimizations.
Regards,
Gerhard

Bolverk
Posts: 5
Joined: Fri Apr 25, 2014 2:28 pm

Re: Two python RPIO questions.

Sun Apr 27, 2014 2:37 pm

Joan thanks for suggestion but I hope to find problem with RPIO. Thanks, ghp, I'm using RPIO with DMA channel 0, I'll try to switch channel and will post if it helps.
BTW, my project is RPi controlled mechanics for some old tower clock. I have L298 board driving DC motor and relays and optical position sensor. I'm using DS3231 RTC. Controlling software written on python.
Image

First succesful test:
https://www.youtube.com/watch?v=5NbBGTVW7_k

ghp
Posts: 1498
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: Two python RPIO questions.

Sun Apr 27, 2014 6:00 pm

Hello,

cool project, but I did not notice that you already use RPIO (reading is a high level art). So DMA channel 1 is correct, but will not correct the switchover timings. Think there is some time needed to rewrite the dma data structures, and during this time strange things happen.
Possibly hardware solutions like guzunty or a slave controller (atmel 328) with well defined switchover timing will cure the problem.
Regards,
Gerhard

User avatar
joan
Posts: 14935
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Two python RPIO questions.

Sun Apr 27, 2014 6:02 pm

ghp wrote:Hello,

cool project, but I did not notice that you already use RPIO (reading is a high level art). So DMA channel 1 is correct, but will not correct the switchover timings. Think there is some time needed to rewrite the dma data structures, and during this time strange things happen.
Possibly hardware solutions like guzunty or a slave controller (atmel 328) with well defined switchover timing will cure the problem.
Regards,
Gerhard
Using pigpio will probably also cure the problem.

Return to “Python”