Documentation for Digital r/w Analog r/w PWM and Interrupts

  • I am quite impressed with what might be possible on this platform but befuddled navigating for some basic functionality. Having only spent a weekend dabbling in getting started, I've not been able to locate the specific function reference documentaion pertaining to writing and reading pulses.

    I did locate a reference using PWM

    L112 // ***** PWM HANDLING *****
    L115 let signalNanoSecs = 10000000; // 100 Hz

    This seems to validate the default frequency, but knowing the acceptable range limits is needed.

    I uncovered a few basic GPIO module functions along with I2C

    but not able to locate detail on creating a digital/analog pulse in duration and frequency, then reading a digital/analog input with Interrupt handling.

    Would appreciate links for further reading. Thanks. . . .

  • Hi!

    Regarding PWM
    Right now the GPIO class allows to set a common PWM frequency for all pins, see setFrequency at
    With setValue you can then set the % the PWM should be on.

    This is not designed for clock exact control. If you need that, low.js currently cannot offer that.

    Regarding getting analog/digital input via interrupt handling

    The pin class of gpio supports on('rise', ..) and on('fall', ...). This is of course only for digitial. I am not sure how analog input via interrupt should work, normally ADC is not interrupt based AFAIK.

    What do you need exactly?



  • Hi Thomas and thank you for responding.

    re: PWM

    Ahh, knowing what functions are called, certainly assists in locating the relavant documentation. Thanks for the link.

    The default frequency is listed at 100Hz. But what is needed is the range of what might be the slowest frequncy and a resonable expectation of the fastest. Allowing for clock timing overhead etc., I expect to learn the range might be something like from 0.1Hz (10 sec) to 800KHz (0.00000125sec or 1.25usec). What is that range? The datasheet won't correspond to the delays with lowsync etc.

    re: 'What do you need exactly?'

    While the docs do indicate the resolution is in milliseconds, my concern is 'how few' milliseconds. What would be nice is the range to expect. For instance, if one is only able to trap a 'fall' event say every 50 milliseconds. What is the shortest duration one might reliably stack up several events in succession, and how many such events would be resonable? And why only in milliseconds? Surely resolution could go down to the microsecond range? (Timer in nanoseconds)

    re: 'Interrupts'

    Just seeking documentation on what Interrupt handling is available.

    re: 'Digital r/w'

    Just attempting to determine if I'm able to create a user defined pulse train, say a 1usec pulse every 120msec followed by a wait duration of say 1.5sec, somewhat emulating the CE pulse followed by a known data sequence. Attempting to manually control GPIO similar to how SPI I2C UART TxRx functions.

  • Hi Robin,

    after thinking about this for a long time, I think I have to tell you that for your use case, low.js will not work currently. I do see your point that it would be great to have hard guarantees for PWM settings - it is a microcontroller after all - but most use cases for low.js do not need it. I guess this will only change if some company needs this feature and is willing to sponsor the development.


Log in to reply