Pages: [1]   Go Down
Author Topic: Wavetable pulse generator?  (Read 1834 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 38
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am new to Arduino and do not have much experience with C. I am trying to generate triangle or sine pulses within a sketch. I need to produce a pulse of one full wavelength triggered by a digital input pin read in a loop or by generating an interrupt from a signal change on a pin. I have found some useful code to produce the sine or triangle waves with wavetables and PWM but can not figure out how to generate a single pulse at a precise time within a loop that is polling the input pin or when an interrupt is generated. I am sure I could find the answer if I look long enough but I have a satellite internet connection and it is unbelievably slow. I am hoping that someone can point me closer to the solution than I can get by hours and hours of searching.  I have a sketch by Adrian Freed that I can get to produce tones but can not figure out how to get it to produce single wavelength pulses. here is the link to the sketch. Maybe someone can suggest how to get this to produce the pulses that I need in response to an input pin. http://adrianfreed.com/content/arduino-sketch-high-frequency-precision-sine-wave-tone-sound-synthesis
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 538
Posts: 27073
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

"produce a pulse of one full wavelength"

How long would that be? You need like a 2.5V, 5V, 0, 2.5V signal?
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 0
Posts: 38
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I need to produce signals to be recorded on a computer sound card input. The goal is to record WAV files that are 0 centered (127 or whatever as center of an AC signal). It seems that the sound cards are very cooperative as they have a rest voltage of 2.5 volts so providing a signal that goes from 0 to 5 volts produces exactly the recording that I want. I am currently using a triangle wave generator made of op amps and comparators but want to do it with the Arduino instead so the timing of the pulses can be based on a clock instead of RC networks. I am driving the circuit with a short squarewave pulse that comes from an encoder. I need to produce a single pulse that goes from 0 to plus peak, to 0, to negative peak and back to 0 each time the encoder pulses. I actually need to produce pulses of two different wavelengths depending on the direction the encoder is turning. I am using an integrated circuit that converts the encoder quadrature signals into step and direction signals. Eventually I also want to do this with the Arduino but will tackle the quadrature decoding at a later time if I can get the pulse generation working first.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
In your brain.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi have you managed to generate the sine pulse?
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 538
Posts: 27073
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Run your signal thru a 10uF cap, will settle at +/- whatever level around 0.
I did that with 8 digital outputs from a uC into an amplified  PC sound speaker.
Didn't even bother with an op amp.


* 1284P_Piano-Organ.png (42.27 KB, 1543x779 - viewed 19 times.)
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Pages: [1]   Go Up
Jump to: