0
\$\begingroup\$

There are two type pwm signals, one pwm with 2.5khz 50% duty, second type 5khz 50% duty. I am looking solution how to detect 2.5khz as digital 1 and 5khz as 0, or 2.5khz-0, 5khz-1. The signal will be detect using arduino, but I don't want to use pulsein or other solution which detect length of signal.

incorrect sample deleted

sample1sample2

\$\endgroup\$
6
  • 1
    \$\begingroup\$ Your description DOES NOT match your picture. It looks like 75% duty followed by 25% duty. \$\endgroup\$ – Andy aka Apr 24 '18 at 13:27
  • \$\begingroup\$ The new picture looks more in line with the text. \$\endgroup\$ – Dampmaskin Apr 24 '18 at 13:56
  • \$\begingroup\$ Yes, removed, added real samples \$\endgroup\$ – Alex Ross Apr 24 '18 at 13:57
  • \$\begingroup\$ So does it need to be realized in hardware or what exactly does it mean you don't wanna use a solution which detects signal length? \$\endgroup\$ – po.pe Apr 24 '18 at 14:00
  • \$\begingroup\$ yes , only hardware. \$\endgroup\$ – Alex Ross Apr 24 '18 at 14:04
2
\$\begingroup\$

What you describe is not PWM, it's BFSK.

It can be solved with an edge interrupt: Count the number of rising or falling edges in a timeframe. The number you get will tell you whether it's a 0 or a 1.

If you want a hardware-only solution, you could build an analog low-pass filter that suppresses everything above 2.5 kHz. If you get a signal you know it's the 2.5 kHz one (or DC), and if you don't, it's either the 5 kHz signal (or no signal). If you want to distinguish between 5 kHz and no signal, you need to build two filters.

There are probably many more ways to skin this cat, but there you have two of them.

\$\endgroup\$
2
  • \$\begingroup\$ It is PWM but with variable duty cycle if the diagram is to be believed. \$\endgroup\$ – Andy aka Apr 24 '18 at 13:27
  • \$\begingroup\$ You're right. I went by the textual description, but the illustration clearly doesn't match it. \$\endgroup\$ – Dampmaskin Apr 24 '18 at 13:34
0
\$\begingroup\$

Different approach: Load a capacitor via the high level of your input signal, and let it discharge via another resistor.

Choose the values for R1, R2 and C1 appropriately. Then for frequency above a certain threshold, the input signal of your controller will always see "1" and below it will see an alternating signal, which can be detected by using an interrupt input. It might be difficult to match the designed threshold to the input characteristics of your MCU inputs due to the "little" difference between the two frequencies. If that's the case you can add a comparator to make sure you have a proper discrimination between both signals.

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.