Page 1 of 1

Request for Assistance in Accurately Calculating PWM Pulse Width in Flowcode v10

Posted: Thu Jun 06, 2024 8:37 am
by bilal
Hello everyone,

I hope you are all doing well. I need your help in solving a technical challenge I am currently facing in my project. I am working on reading the pulse width coming from a PWM signal and displaying it accurately on the serial monitor using Flowcode software. However, I have been unable to achieve high accuracy because the timer division gives 62500 Hz per second, and this is the highest frequency available on the Arduino Uno board.

I would like to share the problem with you in the hope that it will stimulate your ideas and contribute to finding a solution. Unfortunately, I cannot provide an attached file for the Flowcode project, but I will share a simple code that I want to formulate on Flowcode.

Code: Select all

// Reading the pulse width and displaying it on the serial monitor

void setup() {
  Serial.begin(9600);
}

void loop() {
  unsigned long pulseWidth = pulseIn(PWM_PIN, HIGH); // Reading the pulse width
  Serial.print("Width of PWM pulse: ");
  Serial.print(pulseWidth);
  Serial.println(" microseconds");
  delay(1000);
}


I hope this is sufficient for understanding the problem. If you are able to improve the code or provide a solution, I would be grateful for your contribution.

Thank you very much for your continuous cooperation and support.

Best regards,
bilal