Square waveform generator


I am doing a project to control a stepper motor (FEZ mini). I need to have a pulse train of 25kHz, which can be implemented with PWM easily. My problem is that I want to specify the amount of pulses to generate in stead of a continuous pulsetrain. Any suggestions would be welcome.


Erik (big fan of FEZ Panda and mini)

Check OutputCompare class in the documentation.


Seems to be exactly what I was looking for! Thanks!!!

You are welcome!

One thing to be aware of when using OutputCompare with Gadgeteer. OutputCompare is a part of GHI’s premium libraries, and the only available Gadgeteer mainboard that supports this feature (currently, at least) is the FEZ Spider. I use OutputCompare to generate a carrier frequency for my IR LED Array module, and it makes the code very simple, but the downside is that the module won’t work on Hydra or Cerberus/Cerbuino Bee/Cerb40.

Ok, so I won’t be able to use this on FEZ mini? Could a combination of counter/PWM work? Something like generating a PWM and let a hardware counter generate an interrupt at the desired amount of pulses?


FEZ Mini/Panda/Domino/PandaII/Rhino/Cobra will work fine. :smiley:

1 Like

@ Architect - Yes, I just tried it and it is just what I needed!

@ erikhaverkamp - Architect is correct. To be clear, I was speaking particularly of .NET Gadgeteer mainboards. Since this forum is Gadgeteer-specific, I wanted to make sure you were aware of that.

@ devhammer - thanks, could you explain to me why FEZ is not gadgeteer? I seem to miss this concept, I am sorry…

@ erikhaverkamp -

Check these two pages:


thanks, getting more clear now… next time I will post in FEZ