963 Hz Square Wave Generator

Thread Starter

sab201

Joined Nov 18, 2023
297
You really don't need PWM which is typically used to mimic an analogue output on a digital pin. If you are happy with a square wave you can toggle a pin high and low at any audio frequency and higher by putting microsecond delays with between each step, the delay being half the period of the square wave.
That seems like a good idea to toggle pins ON and OFF. I will try that also. Thanks.
 

MrChips

Joined Oct 2, 2009
34,820
You can generate 50 MHz with an MCU. What you gain in high frequency you lose in resolution.
For example, you can generate 25 MHz but you cannot generate 26 MHz from a basic 20 ns clock pulse.

Another option is to use a PLL (phase locked loop) but that is a different topic all together.
 

Ian0

Joined Aug 7, 2020
13,132
If you have the Arduino with the Renesas RA4M1, it has eight counters which can generate squarewave outputs at any frequency equal to 48MHz/n where n is a 16-bit or 32-bit number (six 16-bit counters, two 32-bit counters)

48MHz divided by 49844 is 963.0046Hz
 
I think that if you want an accurate and stable RC based analog oscillator this is the way to go. I would use an LM339 or similar.

https://www.ti.com/lit/ab/snoa998/s...66788&ref_url=https%3A%2F%2Fwww.google.com%2F

The capacitor should ideally be NP0 ceramic, but the frequency is sort of low and the capacitor value will be relatively large for that sort of ceramic capacitor. Using the right type of capacitor is critical. Do not use Z5U or X7R for example.
 

Thread Starter

sab201

Joined Nov 18, 2023
297
T
I think that if you want an accurate and stable RC based analog oscillator this is the way to go. I would use an LM339 or similar.

https://www.ti.com/lit/ab/snoa998/snoa998.pdf?ts=1720991366788&ref_url=https%3A%2F%2Fwww.google.com%2F

The capacitor should ideally be NP0 ceramic, but the frequency is sort of low and the capacitor value will be relatively large for that sort of ceramic capacitor. Using the right type of capacitor is critical. Do not use Z5U or X7R for example.
That seems to be a quicker and easier way to do it before I go into MCU s.
sketch-1721019496515.jpg
I can use a 15 k resistor with two 100 Ohm resistors in parallel so a total of 15050 Ohms for R1 and a 0.1uF capacitor for C1.

1/f = 0.69R1C1

I can get only electrolytic capacitor in that range. The ceramic capacitors I get here are low quality and possibly not multi layered and cannot be used for such precision applications.

How accurate would the frequency be with electrolytic capacitors.
 
Last edited:

Ian0

Joined Aug 7, 2020
13,132
T

That seems to be a quicker and easier way to do it before I go into MCU s.
View attachment 326966
I can use a 15 k resistor with two 100 Ohm resistors in parallel so a total of 15050 Ohms for R1 and a 0.1uF capacitor for C1.

1/f = 0.69R1C1

I can get only electrolytic capacitor in that range. The ceramic capacitors I get here are low quality and possibly not multi layered and cannot be used for such precision applications.
Make sure that you get a comparator with push-pull outputs. Most are open collector.
 

Thread Starter

sab201

Joined Nov 18, 2023
297
Make sure that you get a comparator with push-pull outputs. Most are open collector.
Edit: only LM339 and similar are available in my place. Those TLV IC s with push-pull outputs are not available
 
Last edited:

Ian0

Joined Aug 7, 2020
13,132
Could you give me the IC number for example. Thanks.
Edit: only LM339 and similar are available in my place.
TLV3201
LM339 and similar are all open-collector.
You can use an open-collector device with a pullup resistor, but the timing is less accurate and the mark-space ratio is no longer 50%
 

Thread Starter

sab201

Joined Nov 18, 2023
297
TLV3201
LM339 and similar are all open-collector.
You can use an open-collector device with a pullup resistor, but the timing is less accurate and the mark-space ratio is no longer 50%
Ok then each method has its own limitations and I couldnt get the necessary components even if the suggested method is feasible. So considering all this MCU seems to be the ideal option.

Thanks to all for helping out.
 
Top