triggering

Hello, Our project is to design an Oscilloscope using Uno so that we require uno control code for designing and using of Voltaile memory and timers to process an analog signal for triggering purposes

Your have your work cut out for you. Where do you plan to store the image data ? Do you have any idea what kind of conversion time, sampling rate or memory capacity you need for that application ?

You might like to read this.

...R

Try this to start. Only runs once, press Reset to run it again.

int x;
void setup(){
Serial.begin(115200); // or 230400  
  for (x=0; x<1000; x=x+1){
  Serial.println(analogRead(0)); // read analog channel 0 and send out
  }
}
void loop(){
}

Take 1000 sample to avoid flooding out the PC interface.
Later, add storing the samples in an array, Serial.print out the array once captured:

for (x=0; x<1000; x=x+1){
array[x] = analogRead(0);
}

x need & array need to be int, might have to limit size to avoid running out of SRAM (2048 bytes, or 1024 ints, in a 328P).

http://www.instructables.com/id/Girino-Fast-Arduino-Oscilloscope/

@Robin, Good read ! I'm going to try that first chance I get. Robert

@OP, There is also another option that is not as cool as Robin's link but still nice http://forum.arduino.cc/index.php?topic=228549.0

(see my Excel file attachments in Reply#14 and Reply#20) I didn't have a function generator available for a test signal so I had to use what was available.

I never got past reading the Instructables project.

…R

kaggalbhargava: So as my project synopsis so any improvements pls can you suggest us.

First way to help yourself is to make life easy for us by posting your code properly using code tags - read the How to sticky!

Second way to help yourself is to tell us what errors you are getting.

It looks like you don't understand how to call interrupts. You might usefully read this.

You can't have void ISR() within a function because that is how you define a function. If you want to call a function you don't precede it with void (or int, or whatever). However you shouldn't call an ISR from your code unless you really know what you are doing. ISR's get called by the interrupt independently of the course of your code - that's why they are interrupts.

You are probably going to find it difficult to get detailed advice here for the sort of program you are writing (with lots of low-level bit settings) because it is difficult to understand what is supposed to happen or whether there is an error without spending a long time studying the code. YOU need to approach your program development with plans for proving to yourself that each piece works as you progress with your the project.

FINALLY - you haven't given us any indication of what the code you have posted is supposed to to.

...R

how to write the code to calculate the Time period from the ADC conversion using the timers and interrupts? and how to trigger the wave...

CrossRoads: x need & array[] need to be int, might have to limit size to avoid running out of SRAM (2048 bytes, or 1024 ints, in a 328P).

Unless you run a bigger AVR like the 1284P that you happen to make and sell boards for. A MEGA2560 has 8K RAM and for about $25 can have multiple 56K banks of external RAM on one card added.

Or for varying costs, a SAM3X Arduino (the Due) or compatible can do the job at much higher clock rate with superior ADC. If you're handy at soldering really small and close (to me at least, with thick fingers and bad eyes) the Teensy 3.1 can be had for $17 plus shipping.

And none of that covers DSP chip solutions that to me begs the question of why not use a PC sound card?

kaggalbhargava: how to write the code to calculate the Time period from the ADC conversion using the timers and interrupts? and how to trigger the wave...

This probably makes perfect sense to you, but it's incomprehensible to me.

What do these terms mean?

"Time period", "trigger the wave".

Maybe the time period is the inverse of the data rate?

how to provide the External triggering option in the code— (A triggered sweep starts at a selected point on the signal, providing a stable display. In this way, triggering allows the display of periodic signals such as sine waves and square waves, as well as non-periodic signals such as single pulses, or pulses that do not recur at a fixed rate.)

No.... the time period is the inverse of the frequency and how to calculate that frequency from the converted signal......

how to write the code to calculate the [u]Time period[/u] from the ADC conversion

FYI, In case you are not familiar with electronics terms, the PERIOD of a frequency is simply called "the PERIOD". It is not called the "TIME PERIOD" because that is redundant. I don't know where you got that from but what you were trying to say is "How to write the code to calculate the period of the waveform ...etc.etc." You can only do that after you know the frequency. You don't capture the waveform and then calculate the frequency, you simply MEASURE the frequency in real time by sampling the time between the falling edges of the waveform (for digital) for sinewave you measure the time between zero crossings to get the half of the period.

kaggalbhargava: No.... the time period is the inverse of the frequency

Frequency of what? Sampling frequency? Triggering frequency? Something else?

I guess you want to have the incoming analog signal trigger the start of data acquisition based on some sort of level threshold, so that you can display successive data captures and get a consistent display, and know what frequency it's being triggered at. I shouldn't have to guess.