PWM led pulsating

Hello. I notice some strange behaviour, but I don’t know if it’s because of hardware (I have optoswitch in-between gpio and led). It’s visible only when led is dimmed under 20% or so.
So I am just wondering, once I do analogwrite, does the bonescript actually quickly power off the gpio, and then powers it back on with new settings?
This is really a big problem, because I can’t do smooth led dimming.

Hello. I notice some strange behaviour, but I don’t know if it’s because of hardware (I have optoswitch in-between gpio and led). It’s visible only when led is dimmed under 20% or so.
So I am just wondering, once I do analogwrite, does the bonescript actually quickly power off the gpio, and then powers it back on with new settings?
This is really a big problem, because I can’t do smooth led dimming.

It may do so. I am surprised it can be noticed. Do you have some test code I can observe the issue?

`

var b = require(‘bonescript’);

var awValue = 0.01;
var awDirection = 1;
var awPin = “P8_19”;

b.pinMode(awPin, b.ANALOG_OUTPUT);
setInterval(fade, 100);

function fade() {
b.analogWrite(awPin, awValue);
awValue = awValue + (awDirection*0.0002);
if(awValue > 0.005) { awValue = 0.005; awDirection = -1; }
else if(awValue <= 0.00001) { awValue = 0.00001; awDirection = 1; }
}

`

This code for example. I don’t know how bright the led is without optoswitch, but I get full brightness at around 0.01 at 2khz.

Dne ponedeljek, 30. december 2013 16:24:52 UTC+1 je oseba Jason Kridner napisala: