# generating analogue signals using Hamster's book

## Recommended Posts

Hi all,

I am using papilio one + megawing in order to learn VHDL and logic design, in my free time.

My question is about chapter 16's challenges, I don't think I fully understand the theory in the third line on page 74:

"If you connect the two high address bits on RAM to switches you can have four different waveforms, each with 256 samples per cycle, possibly allow you to generate Square, Saw, Ramp and Sine waves from one project."

I want to add that I am familiar with signal processing but I don't understand the method here.

In my code I am using 8bit ROM with 1024 samples. values are of a full cycle of sine wave (so the first and the last equals 128, but values are between 28 and 228).

If I will connect the two high address bits to switches I will only sweep on a quarter of a cycle for each switches combination, how's that giving me a square? or a saw?

I tried it, even though I did'nt understand it, but for all the switches configuration the signal sounds the same...

I will appreciate some help here

Thanks:)

##### Share on other sites

I think the idea is that instead of using 10 bits for a 1024 sample waveform, you could instead have four different 256-sample waveforms, which you select with a switch.

But you have to regenerate the waveforms for a 256 length and pack four of them into the 1024-length memory.

BTW, if you're working accurately, the first and last sample should not be equal for a sinewave. It's a common mistake, you have one excess sample. Use (1:(n-1))/n*2*pi  for the phase.

##### Share on other sites

so you are saying that in order to generate the signals requested(sin, square, saw, ramp) I should artificially create them and wrap them all in a 1024 rows ROM?

I was hoping that signals should be a result of some DSP operation on the sine wave...

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.