News:

PROTON pic BASIC Compilers for PIC, PIC24, dsPIC33

Main Menu

pulsein timeout !

Started by hitronics, Dec 03, 2022, 01:42 PM

Previous topic - Next topic

hitronics

Hi, Guys
I want to know what is timeout of pulsin command?

Pepe

if in 0.65535 seconds there is no pulse on the selected input, pulsein returns 0 and the program continues with the next instruction as the manual says

hitronics

how to set timeout as 40ms to 50ms of pulsein command?
655ms is long time

Pepe

#3
It cannot be modified, the only way would be to alter the library created by Les that the compiler generates, or by creating your own. With F2 you can see the source in assembler and change the waiting time, but for that you must have sufficient knowledge.In addition, if you modify the waiting time to 50 ms, you will not be able to measure pulses with times greater than 50 ms.

Pepe

#4
The waiting time can be decreased by increasing the frequency of the pic, for the maximum 12f508 is 4mhz, but if you use another pic with frequency of 20mhz you would have a waiting time 5 times less, approx 130ms, only with 48mhz you would have approx 60ms of waiting or as Joesaliba says, declare the maximum waiting time with Declare Pulsin_Maximum 5000

hitronics

#5
how to alter pulsein library?
please give me steps

keytapper

What is your MCU? Without any specifications we just shoot in the dark, Montecarlo method? :)
In most of the cases you need to study the MCU capability, then you can configure your results.
Ignorance comes with a cost

joesaliba

Actually there is a Pulsin timeout, but I do not think it is in the manual: -

Declare Pulsin_Maximum = 5000
Used it before and it works!

Regards

Joe

Pepe

There is only one reference on page 554 as a reserved word, it should be included in the description of the Pulsein function

Yasin

"Pulsin_Maximum" does not have this declaration in the new manual. The entire new manual is 478 pages. Would it be better to use WDT?

Best regards.

Pepe

Yes, it is only listed in the proton manual

hitronics


Pepe

No, it is the maximum value that is given as a limit while waiting for a pulse, if it is exceeded it returns zero and continues with the next instruction of the program and it depends on the operating frequency of the pic, it is a value that represents the number of iterations which performs the pulsein function.

joesaliba

#13
Quote from: hitronics on Dec 04, 2022, 10:19 PM@joesaliba

Quote from: joesaliba on Dec 04, 2022, 07:39 AMDeclare Pulsin_Maximum = 5000

Declare in mircoseconds?

Yes! But depends on frequency as Pepe said.

I remember Les saying that this was an `experimental' but, I have been using this command more than 10 years ago.

Joe