09-30-2024, 09:42 PM
How to read pwm input with pcf8574 ?
Kc868 Read Pwm input
|
09-30-2024, 09:42 PM
How to read pwm input with pcf8574 ?
10-01-2024, 02:42 AM
PCF8574 not use for PWM.
10-01-2024, 04:45 AM
10-01-2024, 05:40 AM
you can use free GPIOs on board, define with PWM , try to use it.
10-01-2024, 07:46 AM
(This post was last modified: 10-01-2024, 07:50 AM by huntleight.)
(10-01-2024, 05:40 AM)admin Wrote: you can use free GPIOs on board, define with PWM , try to use it. I use PCF8574 to access digital input/output ports. Because pinmode(2,OUTPUT); and in loop function digitalWrite(2,LOW or HIGH) does not work . Same goes for input codes. So Q1) Can i use digital input ports for PWM? If yes how can i define those pins ? Q2) If you said no Q1 so which pins is free GPIO and how can i use it? I use serial port pins so i cannot use that pins.
10-01-2024, 08:32 AM
Q1) Can i use digital input ports for PWM? If yes how can i define those pins ? ---> can't
Q2) If you said no Q1 so which pins is free GPIO and how can i use it? I use serial port pins so i cannot use that pins. --> you need check with ESP32 datasheet, which pins can use for PWM output.
10-01-2024, 03:41 PM
(10-01-2024, 08:32 AM)admin Wrote: Q1) Can i use digital input ports for PWM? If yes how can i define those pins ? ---> can't I explained it wrong. I want to read pwm input. Which GPIO pin is free i dont know but i know i use all input and output ports and serial port for hmi. Which pin is free and how can i access it ? Can you explain with schemes if needed ?
10-01-2024, 10:20 PM
on the TOP-RIGHT photo, there label IO-1 and IO-2 you can use. they are GPIO32, GPIO33.
To read a PWM signal on a specific pin of the ESP32, you can't directly capture the PWM signal as an input in hardware. However, you can use the pulseIn() function in code to measure the high and low durations of the PWM signal, and from there, calculate the frequency and duty cycle. Method: Use pulseIn() to Capture the PWM Signal ESP32 offers the pulseIn() function, which allows you to measure the duration of a high or low pulse on a pin. By measuring both the high and low durations, you can calculate the PWM duty cycle and frequency. Example Code Here's a simple code example using pulseIn() to measure the PWM signal: Code: int pwmPin = 32; // Assume PWM input is connected to GPIO 32 pulseIn(pwmPin, HIGH): Measures the duration the pin stays HIGH in microseconds. pulseIn(pwmPin, LOW): Measures the duration the pin stays LOW. Adding both high and low durations gives the total period, from which you can calculate the frequency. The duty cycle is computed by dividing the high duration by the total period and multiplying by 100 to get a percentage. |
« Next Oldest | Next Newest »
|
Users browsing this thread: |
1 Guest(s) |