Hello
I'm a complete novice writing codes to create a software based pwm, that has a sweep function. that means it will produce square waves, and has the ability to sweep from 0Hz to 0.5kHz. Im planning on using the analog pins and not the pwm hardwired function on the UNO.
Any tips, advice, codes, or directions would be really helpful.
Yeah, I think what is being requested is a Direct Digital Synthesis variant.
Before I try to describe the algorithm, which involves at regular (rapid) intervals adding a phase increment to an accumulator and making the output positive if it is greater than half its roll-over value, it would be appropriate to know in what fashion this is required to "sweep" and under what control?
Mind you searching on "Direct Digital Synthesis Square Wave" might be more profitable.
I studied Computer software courses such as python and dr.Racket. But not visual basics. writting codes in C is new to me.
As for the Phase lock loop misunderstanding;
I need to make a PWM that has a sweep function, and also has the ability to stop the sweep at certain points or in some circumstances. this is very similar to phase lock loops of car radios where the SCAN button on a car radio will search through the frequencies until it finds a radio station clear enough.
In my case the PWM will sweep from 0 to 0.5khz and will try and find the resonate frequency of an LC circuit. Once the resonant frequency has been found, the sweep function should turn off, and the frequency of the PWM should remain constant.
The hard wired PWM of the arduino is constant and can not incrementally be raised or lowered (1 Hz at a time). so im left with writing a software that can do that.
You need to redefine your project specification and use correct terminology.
It is not necessary to describe technical details - just what you trying to accomplish.
I am sure Andruino can be convinced to do whatever you can code!.
Pulse width modulation is used in digital processors to simulate analog output.
Phase lock loop is a electronics feedback method to stabilize the desired output by comparing the phase of the reference.
Neither one will be easily adopted to scanning function you desire.
I am really not sure why you need a square wave, can you explain that, please.
Cheers
Vaclav
looks like i have to become more organized and try to convey my idea's more coherently. for now i'll inform myself with the available stuff online. thanks everyone.
It is apparently the case that the frequency generation you require will need to be performed in software.
The concern about a square wave is that it is rich in odd-numbered harmonics, so will tend to excite a tuned circuit apparently at all odd sub-harmonic frequencies as well as the fundamental.
And of course, using this "GDO" principle, you have to tune through and past the resonant frequency, if not over the whole range nyway, in order to accurately determine that resonance without spurious responses.
I would suggest that the project could be a lot simpler and capable if you use a little hardware help in the form of a Analog Devices DDS module. It can output both a digital and analog frequency over a wide frequency range and is pretty simple to control in software. Here is a check out project. http://www.ad7c.com/projects/ad9850-dds-vfo/
These modules are pretty affordable from Asian sellers on E-bay.