Go Down

Topic: 125k frequency sq wave on the mega2560 (Read 1 time) previous topic - next topic


I am trying to use the arduino mega2560 to drive a h-bridge at a 125kHz frequency. To do this I need two square wave outputs that are at 125kHz. Is this frequency achievable because I have tried looking on line to see examples, but even the examples I have seen on line have not worked correctly for me. I am testing these straight from the arduino to an ocilloscope. I keep ending up with up with a square wave at around 79kHz with low resolution. I am also later going to put a mppt for a solar panel on the arduino and adjust the duty cycle of one of the square waves. That is later though right now I would really just like to figure out how to adjust the frequency. Does all of this sound possible, and if so is there some example of code out there that will adjust my frequency correctly. Thanks in advance for any advice.


You should be using an analog write instead of a digital write to create a PWM signal.  Look here for an example.


Sounds like an RFID reader to me. Yes you can get the PWM to go at that rate.


Thanks for the quick replies. I really appreciate it. I have now been able to find a pwm library and have a working square wave that I can adjust the duty cycle from 0 to 50 percent on. This is exactly what I need. Now I just need to build my sensing circuit and see if I can get the mppt to work with a little peturb and observe. Again you all rock, Thanks.

Go Up