How to make programming for ADC ?

Hye there.
I have been assigned to do a programming for my project which is called radioisotopes detector.

My problem here are :

  1. How i want to make a programming to measure the peak value of the output ?

  2. Can someone lead me how to start make the step for the sequence progrmming as picture attach below ?

Please read my attachment for a while for some references of my project.

i hope someone can lead me the start to do the programming.

thank you.

Sequence.pdf (187 KB)

Your PDF file is fuzzy and hard to read. Please post a clear copy.

In any case I don’t plan to spend time learning your expertise. I would prefer to give that time to other questions.

If you explain what is needed I will be happy to try to help. Even a few paragraphs to introduce the PDF would be useful.

If you are reading analog Inputs you can easily have code like this

newVal = analogRead(pin);
if (newVal < maxVal) {
   // peak has been passed
}
else {
   mavVal = newVal;
}

…R

Hye Robin2

Thank you fpr giving me a feedback.

My project is about detector.
The objective is I have to read the peak value of the voltage.

The steps :

  1. Detect the incoming Gaussian Shaped Rule (peak value)
  2. Memorise its Amplitude
  3. Tell ADC that the amplitude of the pulse is stored
  4. ADC can start the conversion
  5. ignore all incoming pulses until ADC finishes conversion
  6. Hold the memorised value during conversion
  7. Forget the memorised value after ADC finishes conversion
  8. Get ready for next Pulse.

Zero Label Detector (ZLD) : detect the pulse. if the peak value detected. it will send to SG as input.
Switch GATE (SG) : Will receive the peak value. Send to ADC to start coversion. delay of conversion need to be longing in (ms) because the T of graph is (us). it will send to SD.
Switch DUMP (SD) : will open to send the data conversion to PD.
Peak Detector (PD) : will send the data to serial to show the peak value of the voltage.

i can make a basic ADC.
but how to make it to follow the sequence above ?
i just need someone to lead me to the start.
any idea ?

I hope u can understand my explaination.
Thank You.

Farah.

You have provided a useful list

The steps :

  1. Detect the incoming Gaussian Shaped Rule (peak value)
  2. Memorise its Amplitude
  3. Tell ADC that the amplitude of the pulse is stored
  4. ADC can start the conversion
  5. ignore all incoming pulses until ADC finishes conversion
  6. Hold the memorised value during conversion
  7. Forget the memorised value after ADC finishes conversion
  8. Get ready for next Pulse.

but what, exactly, do you want help with?
Have you written some code that does not do what you want? If so post the code and explain what it should do and what it actually does.

Some of your steps are not clear to me.
For example Step 5 - how could there be other pulses that need to be ignored? An ADC conversion takes about 100 µsecs.

I suggested some simple code earlier to detect the peak value.
That may cover Steps 1 and 2
After that you just seem to want a simple analogRead() to deal with Steps 3, 4, 5 and 6
Is Step 8 really a return to Step 1 ?

The Arduino is a great system for learning-by-doing. Write a short program and see what happens.

…R

What is the length (in time) of the pulse? You'll have to be running lots of conversions over
this period to get measure a reasonably accurate peak max value.
What are your accuracy requirements?

i have write some code for this but it does not finish yet.

int zld;
int SG;
int PD;

void setup()
{
Serial.begin(9600);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(13, OUTPUT);
}

void loop()
{
// state diagram 01 (ZLD)
// t for time. using time as range to take certain wave as input to trigger SG
// using float because voltage can be in any decimal number

for (int t=0; t<=1; t++)
{
float in = analogRead(A0);
float peak = in*0.00488;

if ( zld == HIGH )
{
float Amplitude;
analogRead (Amplitude);
digitalWrite (8,HIGH); //SG at pin8
}
}

float Amplitude (int AnalogCh, int Threshold)
{
int check1;
int check2;
int check3;
int check4;

check1 = analogRead(AnalogCh);
delay(10);
check2 = analogRead(AnalogCh);
delay(10);
check3 = analogRead(AnalogCh);
delay(10);
check4 = analogRead(AnalogCh);

if(check1<check2) //check phase 1
{
compare1 = check2;
}
if(check1>check2) //check phase 2
{
compare1 = check1;
}
if(check1<check3) //check phase 3
{
compare1 = check3;
}
if(compare1>check3) //check phase 4
{
compare2 = compare1;
}
if(compare2<check4) //check phase 5
{
compare3 = check4;
}
if(compare2>check4) //check phase 6
{
compare3 = compare2;
}
else
{
while (analogRead(AnalogCh>Threshold)
{
check1 = check2;
check2 = analogRead(AnalogCh);
delay(50);
}

return 1025;

}
}
}

}

yet i dont kno it is correct or not. in this program it have put time as reference which is every 1 sec it will take the max peak from all the pulse that it has detect at zero label detector. and send to the op amp as in circuit. the op amp will compare the highes and lowest value.

     float Amplitude;
      analogRead (Amplitude);

This is all wrong.

analogRead() needs the number of the pin it is to read from. That is normally a byte value, and certainly not a float.

And, in any case, you have not given the variable Amplitude any value.

I wonder if your secondline is meant to be

Amplitude = analogRead (A0);

Because I don’t know anything about the science you are trying to implement I have no idea why you have

float peak = in*0.00488;

How could a single value be a peak, and what is achieved by multiplying by 0.00488

And please use the code button </> for your code so it looks like in Reply #1

…R