capture module

Hello everybody

How yo use capture module on Arduino Uno.
Thank you

(deleted)

I mean the input Capture pin

(deleted)

That still does not make sense.

From where did you get the words "input Capture pin"?

...R

if you have used PIC it's the ccp pin

(deleted)

See 16.6 of the you know what

Mark

excuse me i am new to arduino and i don't know what is the you know what
can you give me a link please

The datasheet, from atmel. You can typically find it by googling the part number and word datasheet, ie "atmega 328p datasheet"

The idea is you have an isr that runs when the input capture is triggered, and in that you grab the time from the timer1 registers, and that's how long the pulse was. The isr has to run fast, as always. I've never had much luck with it, though.

Robin2 - it's the pin marked ICP1 (pb0).

Spycatcher - have you not heard of input capture??? It's what they call the mode where you use a timer to accurately measure pulse lengths. Common microcontroller feature.

(deleted)

and in that you grab the time from the timer1 registers

Err no, a copy of timer is made when the event occurs. You have to make a copy of ICR1 in the interrupt handler.

Mark

holmes4:
Err no, a copy of timer is made when the event occurs. You have to make a copy of ICR1 in the interrupt handler.

Mark

I think that's the same as what I was saying? Although I guess I didn't make it clear that a copy was made, and that's what you're grabbing.

Mz409:
excuse me i am new to arduino and i don't know what is the you know what
can you give me a link please

You need to tell us in lot more detail what you are trying to do.

If you have a non-working program that you want help with you must post your code.

...R

Actually What i am trying to do is to measure a pulse duration

Mz409:
Actually What i am trying to do is to measure a pulse duration

What you are actually achieving is to make me lose interest in your problem.

I know it is a HUGE waste of your time but try to find the energy to write a 20 line explanation of the whole project so that we understand the context for your question.

We don't charge for extra words.

...R

Mz409, you need to use pulseIn

pulseIn(pin, value, timeout);

int val = pulsein(5, HIGH, 1000);
will make pin 5 wait for a HIGH. After the high is detected, it will start an internal microsecond timer and wait till pin 5 goes LOW. The int variable val will contain the number of microseconds for which pin 5 stayed HIGH. timemout is a period in microeconds, after which, pulseIn will stop looking for a HIGH.

Hope that helps... :slight_smile:

Thank you everyone

Hello everybody

I want to measure pulse widht using Capture Mode (ICR1) as I can't use pulsein().
I read the datasheet and I wrote a piece of code but I am really stuck.
Can someone help me please!
here is my code

#include <avr/io.h>
#include <avr/interrupt.h>

const int inputCapture = 8;
volatile uint16_t Capt1;
void setup(){
  sei();
  TCNT1 = 0;
  TCCR1B = (1<<ICES1);  // No prescaling
  TIFR1 = 1<<ICF1;
  TCCR1B|=(1<<ICES1);
  TIMSK1|=(1<<ICIE1)|(1<<TOIE1);
  pinMode(inputCapture, INPUT);
  Serial.begin(9600);
}

ISR(TIMER1_CAPT1_vect){
  Capt1 = ICR1;
 
  
}

void loop(){
  
  Serial.println(Capt1);
}

Hi,

What does your code do?
Why can't you use PulseIn?
What is the pulse duration you are trying to measure?

Tom.... :slight_smile: