ΣSigmaStudio Ask AI Русский Log in

LEDs pwm gpio

SigmaDSP & SigmaStudio bruce Jul 29, 2010 00:00 6 replies Original on forum ↗
Thread Summary

Thread Summary

The user inquired about implementing PWM for blinking LEDs on GPIO pins using SigmaStudio. The solution involves using a sawtooth wave and a logic cell (AB in CD out conditional cell) to control the duty cycle and frequency of the PWM signal. The GPIO pin updates once per audio frame, limiting the minimum pulse width to about 21 us at a 48 kHz sampling rate. Another user reported PWM noise at the audio output, suggesting the use of a capacitor or filtering across the LED to mitigate this issue.
AI Generated Content
Subscribe
bruce Question
Jul 29, 2010 00:00

I have a status LED on two of the GPIO pins.

Is there a way to pulse width modulate the blinking of the LEDs?

I can turn them on and off ok. And I think I was successful in getting the LED to blink with one of the signal generators (maybe the square wave).

But for let's say a 1Hz blink:

I would like to maybe have the LED go 100ms on, 900ms off, for one type of error; and maybe 100ms on, 100ms off, 100ms on, 700ms off, for another type of error....etc...

Is there a way to do this?

Thanks,

Bruce

Audio Signal Processors

led

SigmaDSP Audio Processors

gpio

pwm

adau1701

Show More

ADIApproved Reply
Aug 4, 2010 00:00

An easy way to implement PWM is to use a sawtooth wave and a comparator. Since we don't have a comparator cell in SigmaStudio, you can simply use a logic cell... More specifically, the AB in CD out conditional cell.

Here's the signal flow:

The output of the logic cell would connect to your GPIO.

When the sawtooth wave, which goes from 1 to -1, crosses the zero line, the output will toggle from low to high. You can set the duty cycle number to 0.5 to get a 75% duty cycle, or -0.5 to get a 25% duty cycle, or any other number between -1 and 1 to get your required duty cycle. You can change the sawtooth frequency to change the overall frequency of the PWM signal.

Here is an example showing the sawtooth (blue), the duty cycle threshold level (red), and the resulting output (green).

Here are other examples.

Duty cycle control set to 0:

Duty cycle control set to 0.5:

Duty cycle control set to -0.5:

Duty cycle control set to -0.9:

The test project is attached.

278376f610c4b9f562da8cbab12af84a.jpg
278376f610c4b9f562da8cbab12af84a.jpg
278376f610c4b9f562da8cbab12af84a.jpg-349x355.jpg
278376f610c4b9f562da8cbab12af84a.jpg-349x355.jpg
470d7fca9578123a4206433044f3e788.jpg
470d7fca9578123a4206433044f3e788.jpg
470d7fca9578123a4206433044f3e788.jpg-450x288.jpg
470d7fca9578123a4206433044f3e788.jpg-450x288.jpg
c5de2e06c5e29066210c75ebd38ad7b4.jpg
c5de2e06c5e29066210c75ebd38ad7b4.jpg
c5de2e06c5e29066210c75ebd38ad7b4.jpg-450x225.jpg
c5de2e06c5e29066210c75ebd38ad7b4.jpg-450x225.jpg
b58dacd9c4ac89e8f8c32f1d0366e32d.jpg
b58dacd9c4ac89e8f8c32f1d0366e32d.jpg
b58dacd9c4ac89e8f8c32f1d0366e32d.jpg-450x222.jpg
b58dacd9c4ac89e8f8c32f1d0366e32d.jpg-450x222.jpg
88ee015d7ab35ee16cb0248d123d2426.jpg
88ee015d7ab35ee16cb0248d123d2426.jpg
88ee015d7ab35ee16cb0248d123d2426.jpg-450x227.jpg
88ee015d7ab35ee16cb0248d123d2426.jpg-450x227.jpg
e4f49b891ee1e4b230ce238ce7e9f622.jpg
e4f49b891ee1e4b230ce238ce7e9f622.jpg
e4f49b891ee1e4b230ce238ce7e9f622.jpg-450x226.jpg
e4f49b891ee1e4b230ce238ce7e9f622.jpg-450x226.jpg
ADIApproved Reply
Aug 5, 2010 00:00

Hi Bruce,

The plots were made using an internal debug tool that is currently only available for our software development team. You will see that many of the algorithms described in the software help file contain similar plots - for example, see the "Pulse Counter" description in the help file. Currently, that tool is not polished and can lead to some issues such as crashes, so we are not making it available in the public release. It is possible that it could be included in SigmaStudio in the future.

bruce Reply
Aug 5, 2010 00:00

Thanks BrettG.

I will try it out as soon as I have something to program. Both of the development cards I bought are being used for demos. The prototypes are being assembled and I should be able to try it out on them late next week.

Just looking at your solution has me pining for an in-line C complier Cell....

The plot outputs look great, how did you get them? Is that possible within Sigma Studio?

Thanks,

Bruce

ADIApproved Reply
Aug 6, 2010 00:00

One thing to keep in mind with this solution is that the outputs of the GPIO pins are updated once per audio frame. For a typical sampling rate of 48 kHz, this means that your minimum pulse width will be about 21 us (1/48000), so the maximum square wave frequency you could output from this pin is 24 kHz (21 us high, 21 us low, for a 42 us period).

beou Reply
Sep 19, 2016 00:00

Hello to all!!

I have managed to controll the illumination of an LED in a freeDSP board with success!!

The LED smoothlly illuminates from minimum to maximum brightness periodically as a stand by indicator.

The problem is that PWM noise is present at audio output!

Any suggestions? I think that a cap or some filtering is needed across the LED.

EZAdministrator Reply
Aug 2, 2018 00:00

This question has been assumed as answered either offline via email or with a multi-part answer. This question has now been closed out. If you have an inquiry related to this topic please post a new question in the applicable product forum.

Thank you,
EZ Admin