Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

best way of counting pulses from opto sensor

Status
Not open for further replies.

tictac

Full Member level 5
Joined
Oct 22, 2006
Messages
297
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,298
Location
Polland
Activity points
3,572
opto coupler slot sensor

Hi all
I use opto slot sensor to detect rpm of my dc motor.one wing that stick to the shaft move through the sensor.I use codevision for writting the code.what is a best way to measure the time of rotating the shaft for one turn??? external interrupt+timer OR capture mode of timer ?????

and the rpm of my motor is 50000.does opto slot sensor is fast enough to measure the time of rotating 1 turn of shaft??how do I know that?
please help me.
 

sensor for counting shaft turns

i think opto can do ...
 

optocoupler sensor slot

I want to do that myself

Added after 5 minutes:

I write this code to count pulses of my motor.but I think this interrupt take a lot of time of avr
interrupt [EXT_INT0] void ext_int0_isr(void)
{

if(firsttime==0)
{

TCCR0=0x02;
TCNT0=0x0;
T1=TCNT0;
tt=0;
firsttime=1;

}
else if(firsttime==1 )
{

TCCR0=0x00;
T2=TCNT0;
SUMTT=tt;
DIFF=T2-T1;
firsttime=0;
}


ELAPSEDTIME=(SUMTT*184.365)+(DIFF*0.723);
rpmget=60*1000/ ELAPSEDTIME;
rpmget=rpmget*1000;

}
interrupt [TIM0_OVF] void timer0_ovf_isr(void)
{
tt=tt+1;
TCNT0=0x0;
T1=TCNT0;
}
 

opto rpm sensor

can you describe it a little?
 

opto sensor slot +pdf

capture will not load up the CPU at high speed. Timer will be used for a low speed/long period.
 

rotation speed measurement opto led

I have a encoder that send 500 pulse per 1 rotate of motor's shaft to the micro.
I want to measure the time betwean of each pulses.and I have a large amount of code that do other works(such as send and recieve serial data).how do I measure the pulse period with out occupy micro time????
 

counting sensor motor shaft

rpm of motor is 40000
 

opto sensor calculation

tictac said:
what is a best way to measure the time of rotating the shaft for one turn??? external interrupt+timer OR capture mode of timer ?????.

Input capture is the least intensive for MCU. You just have to take value from input capture register and substract it with previous ICR value recorded before next trigger event occurs. If your program takes longer than that, use input capture interrupt to force updating of speed value.


tictac said:
and the rpm of my motor is 50000.does opto slot sensor is fast enough to measure the time of rotating 1 turn of shaft??how do I know that?

Check data sheet for your sensor. Post the part number for slot sensor so we could help you with that.
 

dspic counting pulses int0

I think using input capture pin is better.
 

main topic about opto sensor

are you using dsPICs? There is dedicated FIFO capature module on those micros for motor type application.
 

21s way of counting

I use serial interrupt for receiving data,when I use capture interrupt to calculate the period of pulse,the data of serial doesnt receive correctly.because the capture interrupt occure very fast and dont let the serial to get data correctly

Added after 18 minutes:

I use GP1A53HR for opto slot
 

ps4001 opto slot switch

Can you set up the prescaler of capture for different speed? For instance, on high speed, 16x pulse trigger one interrupt, for low speed 4x or 1x pulse trigger one interrupt.
 

avr gcc count pulses

tictac said:
rpm of my motor is 50000.does opto slot sensor is fast enough to measure the time of rotating 1 turn of shaft??how do I know that?
I use GP1A53HR for opto slot

ω=50[krpm]=833[rps]
f=ω*n

ω-rotational speed
krpm - thousand rotations per minute
rps - rotations per second
f - frequency of opto detector
n- number of light interuptions per one rotation of the shaft

Data sheet for interrupter states:
http:**broken link removed**

tr=tf= 0.5µs max. rise and fall times. It gives you 1MHz capability in worst case, but likely even higher. Just set LED current to 8mA and load resistor on collector output to 280Ω and you will be fine.

As already said, prescaler should solve your problems. Just do storing of the value at the begining, and do calculations outside of interrupt routine.
 

    tictac

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top