Electronics-Workshawp / WaveCraft

WaveCraft is an Arduino library to make generating sine waves easier. It has a constructor that takes in initial values for frequency, amplitude, and phase, and provides methods for setting and getting these values.
1 stars 1 forks source link

wavecraft generate square wave insted sine wave #1

Open iw2evk opened 1 year ago

iw2evk commented 1 year ago

Hi,

i've created this simple sketch for generate a sine wave of 71.9 hz on pin 13 of arduino nano

include //carico libreria

WaveCraft wave1(1, 100);

// inizializzo la seriale e setto i baud di trasmissione void setup() { Serial.begin(500000); pinMode(13, OUTPUT); // setto il pin di uscita }

void loop() {

wave1.setFrequency(71.9); //carico la frequenza in Hz wave1.setLow(0); // carico il valore minimo wave1.setPhase(0); // carico la fase wave1.setHigh(255); // carico il valore massimo

Serial.print(wave1.getValue()); //plotto su seriale l'uscita per test Serial.print(" "); Serial.print(255); Serial.print(" "); Serial.print(0); Serial.print(" "); Serial.println(" "); int wave = wave1.getIntValue(); analogWrite(13, wave); }

running i plot the wave with integrated IDE arduino plotter like sine wave, but on pin13 hecked with oscilloscope it's presenta square wave! This library it's intende only for plotter sine wave on ide plotter or for generate true sine wave on pin ?

Thanks

Roberto

Electronics-Workshawp commented 1 year ago

This library generates the values needed to make a sine wave. To actually see a sine wave on a scope, you would need to send those values to a DAC.

iw2evk commented 1 year ago

I've used the pwm internal to Arduino but the sampling frequency It's too low for sagomate with a R/c filter Amy suggestioni?

Il sab 23 set 2023, 02:41 Electronics-Workshawp @.***> ha scritto:

This library generates the values needed to make a sine wave. To actually see a sine wave on a scope, you would need to send those values to a DAC.

— Reply to this email directly, view it on GitHub https://github.com/Electronics-Workshawp/WaveCraft/issues/1#issuecomment-1732150886, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADKPWRGJIL47VGXSNAFUQWLX3YV3TANCNFSM6AAAAAA32C2LZU . You are receiving this because you authored the thread.Message ID: @.***>