Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

timersss..

Status
Not open for further replies.
TKS said:
can any one explain how

i could measure the time between 2 pulses..???

Walter

Detect the start of the first pulse and start counting, while counting keep checking for the start of the second pulse. When you detect the start of the second pulse stop your counter - it will hold a representation of the time between the pulses.
 
ok..

How easy would it be to

detect always the second pulse..???

or should i do that whit interupt and a flag (if it is the start action or stop action..???)

TKS
 
Re: ok..

TKS said:
How easy would it be to

detect always the second pulse..???

or should i do that whit interupt and a flag (if it is the start action or stop action..???)

TKS

It depends how fast the pulses are, for reasonable speed pulses you don't need interrupts - unless your program needs to do something else in the meantime?.
 
mhh

well..

we want to measure horsepower..!!

what you the need to do is register the time a engine needs for rising in revs unther load..

we use a 45holes round sheet.

directly connected to the engine.

a optocoupler is gona give us the pulses..

i want to calc the time between 2 pulses..

and that val i send to the comport....

then my laptop is gona register

the time between the 2 measurements etc..

TKS
 
Anything an internal combustion engine does is slow, they work in revolutions per minute - PIC's work in millions of instructions per second.

Software timing would be fine for that application - it's not far off counting on your fingers :lol:
 
ejejeje

:lol: :lol: :lol:


don't forget...

that...if it was a motorbike engine we where talking about the double rpm/min (12.500)

and for me couting my fingers @ double speed is as 4 as difficult.

TKS
 
Re: ejejeje

TKS said:
:lol: :lol: :lol:


don't forget...

that...if it was a motorbike engine we where talking about the double rpm/min (12.500)

and for me couting my fingers @ double speed is as 4 as difficult.

TKS

That's still relatively slow, 12500RPM would be around 200Hz. A pic running at 4Mhz would have 5000 instructions time between 2 pulses.
 
Clear calculation here

12500RPM = 125000 x 45 pulse per minute (you have 45 pulse per revolution)

= 125000 x 45/ 60 pulse per second

= 125000 x 45 / 60 / 1,000,000 pulse per us

= 250/3000 pulse per us

about 10 us you may get a pulse.

And if you use 20MHz, each 40 cycles you may get a pulse.

So it's posible to use interrupt.

Is this right?

Why don't you use capture with only one interrupt per pulse, and each time to go to interrupt, you lost at least 10 instruction here.

you get 30 remains to do with 1 period.

How to do so?

Connect CCP1 and CCP2 together. Use CCP1 at fall edge mode, and CCP2 at rising egde mode. Each CCP2 interrupt, you can compute CCP2 - CCP 1 to get the value you want.

Is this what you need to do?
 
wrong

Look..

first if i don't use a smittrigger it wouldn't work because it will fall.

and rise in the don't know piece..of the pic..

Then your calculation is wrong..

12500*45=562500 pulses per min.
9375 pulses a sec ( / 60 )
9,375 pulses per milisecond (/1000)
0,009375 pulses per micro second (/1000)

so to capture every pulse i have to be faster as 106,6667 uS

soow thats the time i have to start the timer and send the values out of the serial port...

but in fact wy should i need 45 measurements per round of the engine.???

that are 4500 calculations a second..

i only need 35 i thing..and then i'm on the max...wy i need more to..??

TKS
 
we use a 45holes round sheet.

You said you had 45 holes in a ring?

Oki, anyways, you got about 100 instructions to do other stuffs.

With RS232 communication, you write in ASM, you lost only few instructions.

With those instructions remained, you can do many stuffs. You know tiny bootloader? the full burning program is only 100 words.

I don't know what you intend to do, pls write clearlier.
 
On most pic's you can set timer0 to count pulses on RA4. This way you could count pulses with almost no overhead at all...

and falleafd, 100 instructions between 2 pulses wouldn't be enough to transmit them over RS232. RS232 goes very slow, the transmission would probabely not be complete when the new pulse arrives...
 
falleafd said:
OH, I thought we only need to send a byte to buffer? and the hardware will do transmission?

It will, if you have a PIC with a hardware UART (like a 16F628), for any time critical applications it would be a good idea to choose such a PIC.

However, you could always do it in software, and ignore any pulses missed while sending the serial data - it wouldn't make any difference for this application - even at 9600baud you could still read almost 1000 samples per second (ignoring the reading time).
 
falleafd said:
OH, I thought we only need to send a byte to buffer? and the hardware will do transmission?

Yes, but if you put bytes in the buffer faster then they are transmitted by the hardware then it will eventually overflow
 
No, the fact that we do not need to send continuously. For example, the sampling time should be hold by timer2, and when timer2 overflow, we send only 1 byte.

In my codes, I usually do some computation in PIC before send it out. I call it basic processing. For example, you would like to know the velocity, you can compute it with the given sampling time, and get the value of velocity in several of those 106us, and then send it out with only 1 byte result.

digital control always need sampling time, you cannot do it continously. Normally, the sampling time should be about 0.01s for motor control. And I see no problem with this aim.

Each 106us, we only have to write to buffer, and we have about 90 - 100 instruction to do other stuff. We wait for several of 106s (samplingtime) and do xmits.

I don't know clearly about TKS project, so I cannot determine if we can do this or not. But with upthere posts, I think we can.
 
Status
Not open for further replies.

Similar threads

Latest threads

New Articles From Microcontroller Tips

Back
Top