Shop OBEX P1 Docs P2 Docs Learn Events
audio wave generation — Parallax Forums

audio wave generation

SpencoidSpencoid Posts: 2
edited 2011-05-22 11:25 in BASIC Stamp
I am trying to convert simple digital data, just pulses from an encoder into a format that can be recorded on standard audio recorders such as in wav files. the goal is to be able to recored the output of rotary encoder (steps but I also need to embed direction information) in an audio format and them play it back as the same digital pulses originally used. i have succeeded at making an encoder and decoder that when tested in a loopback test does exactly what i want. the problem is that my simple circuits (comparators op amps etc) does not produce symmetrical enough sine waves and there is DC drift that messes up the recording. I am testing with a PC running Audiology to record from the audio input. I only need to record sine waves or cosine waves, single full waveforms. a cosine(360 degrees) represents a step in one direction and a cosine a step in the other direction. Again, the decoder works fine in the loopback test. i can get the stepper motor to do just what i want with no errors.

i am hoping that the Stamp can be programmed to produce a stepped approximation of a sine wave and a cosine wave separated by a 0 level and that it can also do the decoding back into step and direction signals. my decoder works fine so i can always use that but as i said, i can not record the sloppy sort of smoothed off triangle waves that my encoder makes. the important thing is that there is no DC bias to each of the waveforms.

i do not see any way to do this with the standard audio functions. i am willing to use the Stamp to control other circuits if that is necessary, such as D to A converters etc. I do not have any development kit purchased yet and would also like to know what I should buy to start this project. I am completely new to mocrocontrollers.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-05-21 21:51
    A Stamp is not going to be able to do this for you. It's really not that fast and there are limited facilities for handling audio (like FREQOUT). With external hardware to handle the details of waveform synthesis, it's a different story.

    How about starting with the actual problem ... you want to take encoder information (how many bits? how fast are changes?), include direction information, and represent this as something that can be recorded with an audio recorder. You're talking about a modem. How about using a standard modem chip and supplying the encoder/direction information as a serial data stream?
  • SpencoidSpencoid Posts: 2
    edited 2011-05-22 11:25
    Mike,

    good to hear from you. i have been a member of the forum for just a little while but have noticed many useful postings from you, totally devoid of bull and getting right to the point.

    i thought about using a modem but have no idea how. maybe it will help to use a stamp for interfacing. i am totally new to micros. i am an old fart used to logic chips etc and might have a difficult time changing but want to give it a try.

    my data is very simple. i have a servo controller made by Gecko that "emulates" a stepper motor. You give it a pulse for each step desired and and hold or pulse the direction line for the intended direction just as if it were a stepper drive using step and direction signals.

    I have a quadrature encoder connected to an LS7184 which is a clever chip that converts quad signals to step and direction. I can control the motor directly with the LS7184 connected to the Gecko but added limit switches that interrupt the step pulses. I also built an encoder that converts the step and direction into a stream of sine and cosine (sort of) waveforms. The LS chip can be set to produce pulses of a wide range of durations and I picked something that can fit nicely at the desired rate into the range of an audio card. My encoder uses an op amp and some logic to produce square waves which are then smoothed at the corners with an RC filter to produce something that the sound card likes more than a square wave. Also had to make sure there are no DC levels but this is probably not perfect and the reason for the problem recording.

    I would love to know how to use a modem to produce a sound card compatible audio signal from the LS7184 and to decode to get the pulses back again after recording as audio. If a stamp would make this easier to interface to the encoder and gecko, great, i'll learn how to do it? Any ideas and or links for information would be greatly appreciated. I could probably figure out how to convert the simple step pulses into data packets that contained step and direction information. i could probably also include a delta time value but then it gets complicated. hopefully there is some simple way to fake the data into something a modem likes.
Sign In or Register to comment.