Adding square wave signals

21 Feb 2013

Good Day All

Is their a function to add square wave signals through mbed?

I would like to add two square wave signals contain simple 0 & 1 value

This what I am looking for:

/media/uploads/Fairaq/added_signal.png thanks in advance Majed

21 Feb 2013

Hi Majed,

you say 0 / 1 but then have drawn something different ?

Do you really mean 0 / 1

If so, then this is simply a DigitalOut pin that you can switch between on and off.

The standard "new program" produces a square wave, being output on LED1 on your mbed.

#include "mbed.h"

DigitalOut myled(LED1);

int main() {
    while(1) {
        myled = 1;
        wait(0.2);
        myled = 0;
        wait(0.2);
    }
}
21 Feb 2013

Hi Dave

Sorry, my question might be confusing you, but what I need is a program to add two square wave signals.

In my project I need to feed in two square signals, then add them together. After that, output the result to one of the output ports.

I hope it is clear this time

21 Feb 2013

Then have a look at AnalogOut, then you can simply add two DigitalIns, divide that by two (since analogout needs it between 0 and 1), and put that on the AnalogOut. Then you got the two DigitalIn square waves added.

22 Feb 2013

Apologies for my earlier misunderstanding, that's a good idea above from Erik. They always are !

22 Feb 2013

Thanks for both of you

I will try what Erik said and hope it do my task