Skip to content

Fast Pulse #19

@pacmac

Description

@pacmac

Hi;

Using a scope to monitor the pin, I seem to be unable to get a pulse faster than 10ms using the following code, but I really need the pulse width to be in microseconds rather than milliseconds, hence the setTimeout value of 0, which I was hoping would last a few clock cycles. Even if I remove the SetTimeout() function, the pulse width is still 10ms.

there is a 1K pullup on gpio.4.

The following code is intended to pull gpio4 low for 500us, then release it and then read whether the connected device has pulled the line low (presence) and log the result to the console, however I am unable to get a pulse width less than 10ms, any ideas why ??

var dq;
function dqinit(cb){
    dq = gpio.export(4, {
       ready: function() {
          dq.set(0);
          setTimeout(function() {
            dq.set();
            dq = gpio.export(4, {
               direction: "in",
               ready: function() {
                    cb(dq.value); 
               }
            });         
          },0);
       }
    }); 
}

dqinit(function(val){
    console.log(val);
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions