You are reading a single comment by @Robin and its replies. Click here to read the full conversation.
  • Maybe in this case PWM will be the solution.
    analogWrite(PIN, value, { freq : my_freq_in_hz } )

  • Mon 2021.09.13

    reply to post #6

    analogWrite(PIN, value, { freq : my_freq_in_hz } ) Maybe in this case PWM will be the solution.

    You are on the right track. I see from the code that a width of one complete pulse is around 20usec. (Is that accurate? response from post #10 needed here)

    I'll agree that trying to simulate a pulse train with Javascript might be a bit of a challenge as Espruino is using an Interpreter and isn't compiled, but I was able to get pulse widths down towards 2usec but using a technique that isn't (best I am able to determine) available on non supported boards.

    http://www.espruino.com/Other+Boards



    Read over my thread using the PPI Programmable Peripheral Interconnect that should give you some ideas on the methods used in creating pulses, timing and detection. It wont answer all your questions, but should get you on track.

    Tutorial example output anomaly using low level access PPI

    see also

    http://www.espruino.com/InlineC
    http://www.espruino.com/Assembler



    Be prepared to put in some time reading, coding and experimenting, as some concepts take a bit of getting used to, especially if you are mostly involved in the Arduino environment.

About

Avatar for Robin @Robin started