Chat freely about anything...

User avatar
By dubbear
#32691 Hey!
setting the pwm duty cycle to 65535 does not make it 100% on only 95% on
and there is a spike in the middle of the 0 cycle.


http://pastebin.com/ALdaqLBs
Code: Select allimport socket
__author__ = 'dubbear'
import sys
import telnetlib
from random import randint
from time import sleep
from colors import ColorWheel
from colors import ColorWheel
wheel = ColorWheel()
HOST = "192.168.1.87"

def get_gpio( gpio ):
   "get's status of a gpio"
   Esp01.send("gm " + str(gpio) + "\r\n")
   return_string = Esp01.recv(4096)
   return return_string

def set_gpio( gpio , duty ):
   "set status of a gpio only pwm for now"
   Esp01.send("gs " + str(gpio) + " " + str(duty) + "\r\n")
   return_string = Esp01.recv(4096)
   return return_string


Esp01 = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
Esp01.connect((HOST ,24))

print get_gpio(12)


count = 0
while (count < 65535):

    set_gpio( 12,count )
    set_gpio( 13,count )
    set_gpio( 14,count ),
    count = count + 10

    print count

  #  sleep(0.1)

# while (count < 65535):
#     red,green,blue = wheel.next().rgb
#     set_gpio( 12,red*255 )
#     set_gpio( 13,green*255 )
#     set_gpio( 14,blue*255 ),
#     count = count + 100
#     sleep(0.2)


Esp01.close()




Image
User avatar
By eriksl
#32726 Yes, it's a known limitation of the Espressif PWM implementation. It may not be suitable for driving motors.

There would be a workaround and that is changing the GPIO to output temporarily and then set it to "on", but you'd need a reboot for that ;)

If I implement it in the code, that won't be an issue.

Added to "to-do" list ;) Set GPIO to simple output temperarily if duty cycle == 0 or duty cycle == full. I can't promise it will work though, we'll have to see.
User avatar
By dubbear
#32827 Oh ic =)

You might consider dropping the pwm to 12 bit and getting a higher frequency.
There is now a visual flicker when you drive a large rgb led strip.
when you move your eyes fast or move your hand fast. :geek:
User avatar
By eriksl
#32841
dubbear wrote:Oh ic =)

You might consider dropping the pwm to 12 bit and getting a higher frequency.
There is now a visual flicker when you drive a large rgb led strip.
when you move your eyes fast or move your hand fast. :geek:

I chose this frequency/resolution because I need to be able to dim led strips to almost invisible. With 12 bits resolution you won't succeed. The frequency now is 330 Hz, which should be sufficient to not flicker. But I recognise the effect you describe. I had it at even much higher frequencies, so simply increasing the frequency won't fix it, I am afraid.

If you can't have any flicker, you might want to step to analogue driving, by adding an RC filter. If you're using mosfets for the driving, it may become a bit complex then, a darlington power bipolar transistor (like TIP120) may be better up to the job in that case.