0

I have a adc module on my board. I create a sine wave on signal generator. And I give output of this generator to a adc pin. Finally I read value of this pin periodically. I try to create a sine wave on my software.

x = t,
y = Asin(wt),
A : amptitute value of the generator, 
w : 2πf, f : I set its value on my software.(difference time between two read operation)
t : time

And I don't use value of adc pin. Isn't this value important to create wave?

Laurel
  • 5,965
  • 14
  • 31
  • 57
zakjma
  • 2,030
  • 12
  • 40
  • 81
  • Is your question: "How to compute a sine wave in software?" – jeb Dec 03 '14 at 13:48
  • yes, I don't use value of adc pin. And I don't know where I put it in calculation. – zakjma Dec 03 '14 at 13:50
  • You don't need an external input for generating a sine wave - only the sine function, and the values and time variable that you've already noted in your question. Have a look at http://en.wikipedia.org/wiki/Sine_wave for more information. – sonicwave Dec 03 '14 at 14:53
  • I want to simulate signal generator's sine wave. Because DAC isn't on board, I use signal generator. – zakjma Dec 03 '14 at 15:08
  • 1
    The question makes no sense. You cannot "generate" a signal from an *input*. If you are generating a series from the sine function, why would you need to read the ADC input? The computer can *compute* a sine function. – Clifford Dec 03 '14 at 15:15
  • linux is not real time. I try to detect and show delay time linux kernel.I generate a sin wave from signal generator, and I read periodically adc.Then, I create a sin wave on my software(I don't sure how I do) to show this delay time. – zakjma Dec 03 '14 at 15:26
  • 1
    @holazollil : You are right that Linux is not real-time, but measuring latency will tell you little about that - that is not what real-time means - while real-time systems typically have low latency, more importantly they are *deterministic*. If you were to copy an input signal to an output signal without deterministic sampling, the output will be distorted as well as delayed because the sampling may be aperiodic. Besides, if you have no output what are you going to compare to determine the delay!? – Clifford Dec 03 '14 at 15:39
  • 1
    Ask a question about what you are trying to measure rather than asking a question about how to implement your solution, because it is unclear what you are trying to do or how your solution is expected to work. – Clifford Dec 03 '14 at 15:42
  • @Clifford I implement this method using both linux and xenomai(real time patch). And I compare the result that show latency.For the result of xenamoi, there are many point on plot during a time interval. – zakjma Dec 03 '14 at 16:01
  • 1
    You need to fix the question to clarify what it is you are asking - adding comments does not help. – Clifford Dec 03 '14 at 16:11

1 Answers1

1

I will try to provide you with some hints based on what I understood from your post.

The ADC is supposed to sample the analogue signal generated at a defined frequency in order to yield a digital signal. In your case, you need two information to trace your curve:

  1. Data:

data to be traced (samples) which represents the amplitude of the signal all along sampling time (at each sampling instant).

  1. Time:

you need to know the period in time at which ADC is sampling the signal then associate each data with its corresponding instant in time. Period can be deduced from the frequency at which ADC samples signal T = 1/f.

ADC stores each sampled data in a register and an interrupt would be generated to notify processor about a new coming data. Your interrupt service routine (in case you are proceeding with interrupts) must be able to extract that data before it will be replaced by the next sample. As a suggestion, you may create a buffer within your application where your interrupt routine could store data in it. Then, your application can extract data from buffer and use it to draw the curve if your system has a display output or send it to a desktop application that will do the job.

You don't need to stick to the equation in your post; it is for analogue. Rather you can think of the digitized curve as f(t) = Data(t).

As you are using linux, if you don't want to deal with interrupts you may proceed with reading data using /sysfs interface. Note that opening a file to read data for every single sample could be slow depending on your application requirements.

Aymen
  • 261
  • 2
  • 10