0

I am trying to generate a sawtooth waveform from the GPIO, the frequency is high, 20 Khz. is pigpio library my best option?

New contributor
engahmedtg is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • 2
    since gpio can be only in one of two states (high, low) ... how do you propose to generate a sawtooth? – Jaromanda X Feb 11 at 2:56
  • I wasn't planning to do it directly. May be use the resistor ladder or a CoTS DAC, thanks. – engahmedtg Feb 11 at 13:37
  • Still interested in this? Would you consider adding an external op amp? What about external Resistor and Capacitor? {Here are the basics for the RC approach](electronics-tutorials.ws/rc/rc_3.html); let us know if you need help. – Seamus Feb 12 at 1:45
1

All the Raspberry's GPIO are binary, thus you can not directly generate a sawtooth wave.

With that being said, as the laconic @jsotola's comment suggested, you may use a resistor ladder to create a Digital to Analog circuit and connect it with your GPIO pins. You will then be able to use the GPIO pins like a counter to generate a staircase waveform, which may be sawtooth-like enough depending on you application, but this will demand an even higher GPIO write frequency with every additional GPIO pin you use.

  • Thanks, I think this is the best way to go. For time constraint, I am think to use a CoTs DAC. Do you recommend something? – engahmedtg Feb 11 at 13:41
  • No, sorry, but there are many arduino DAC boards that should be compatible with the raspberry. I would worry about meeting the frequency requirement (depends on the language and library you will use to control the GPIO). – GramThanos Feb 11 at 18:42

Your Answer

engahmedtg is a new contributor. Be nice, and check out our Code of Conduct.

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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