Generating a non-symetrical square signal

Hi everyone,

Long story short, I intend to build a domotic system for controlling electric devices from an (audio) jack interface (of any computer). After designing the electronic system (PICs), I thought of encoding information in the form of sound pulses which would be played on the computer and read by the PIC (micro-controller).

I managed to design a symetrical, square signal thanks to audacity, but can’t find a way to make it assymetrical (where the steady values would be 0 and 1, no duty cycle). I could address this problem by using a (physical) diode to filter negative voltages but it was looking for a way to avoid this rather heavy solution.

Any Idea would be greatly appreciated !

Regards, Heisennberg

NB : Sorry for the approximate English, I’m French !

Problem solved !

For everyone who might be interested : I used the silence tools on the negative voltages (by selectionning them) to force them to zero .

Thanks for the auto-emulation anyway :smiley:

Regards, Heisennberg

Does this do what you want?

Run this code in the Nyquist Prompt.

Select part of an audio track where you want to generate the pulses, then open the Nyquist Prompt from the Effect menu.
Copy and paste this code into the Nyquist Prompt text box.

(setq hz 440)
(setq bias 0)
(setq level 0.5)

(let ((lev (* level 0.5)))
  (sum lev (mult lev (osc-pulse hz bias))))

The first three lines set the parameters used by the code. You may change the numbers to suit.

(setq hz 440) sets the pulse frequency
(setq bias 0) sets the pulse width. Must be between +/- 1. For a symmetrical square wave set to zero.
(setq level 0.5) sets the vertical height of pulse above 0. This should be between 0 and 1

1 Like

So you wanted to “delete” the negative going part of a pre-existing waveform (rectify the waveform)?
That is done very easily with the Nyquist Prompt:

(s-max s 0)
1 Like

…and here I am in 2024 needing to compose a PWM waveform! Thank you so much for this, you’re an absolute star! :star_struck: :heart: