PDA

View Full Version : Hpulsin



Tobias
- 30th January 2012, 07:17
I have a pretty good handle on getting CCP pins to work right measuring incoming signals high and low times. PBP has HWPM and its pretty handy to use. Would it be hard to make a HPULSIN command? Instead of having to learn configs for the beginner that can be quite a pain in the ass and sometimes counterintuitive, I think a nice addition to the code library would be to have a HPulseIn routine where the user sets the max frequency and then when the routine is ran, a high and low time is sent to a variable.

This would be nice so it is running in the background and when the routine is called all it does is move the CCP times into variables.

longpole001
- 31st March 2012, 11:50
i agree , if i read this correct , i had a need to measure using pulsin the low to high then high to low , pulsin will measure the low pulse but not the immediate high to low to high duration

not all PICS have Hardware PWM . so the abilty to measure 2 pulse lengths at the same time would be VERY good

something like this command

pulsin1 pin , state , varable1 , varable2

pin = input port
State = If State is zero, the width of a low pulse is measured into varable 1, the duration of the following high pulse is held in varable2
If State is One, the width of a High pulse is measured into varable 1, the duration of the following Low pulse is held in varable2
If the pulse edge never happens or the width of the pulse is too great to measure, Var1 and var2 is set to zero.

Varable 1 , Varable 2

If an 8-bit variable is used, only the LSB of the 16-bit measurement is used. Pin may be a constant, 0 - 15, or a variable that contains a number 0 - 15 (e.g. B0) or a pin name (e.g. PORTA.0). The resolution of PULSIN1 is dependent upon the oscillator frequency. If a 4MHz oscillator is used, the pulse width is returned in 10us increments. If a 20MHz oscillator is used, the pulse width will have a 2us resolution. Defining an OSC value has no effect on PULSIN1. The resolution always changes with the actual oscillator speed

Also note chances are that you want to measure the next pulse as well and command would allow for use of pulsin looking for one state change not 2 directly preceding the above pulsin1 command



Possible ????????????????????

regards

Sheldon.

Acetronics2
- 1st April 2012, 11:43
Hi, Sheldon

Do you really think adding a new library function for 3 poor PBP commands is worth the effort ??? :wink-new:

Alain

mister_e
- 1st April 2012, 12:31
PBP 3 allows you to add User Command... do it and share :)

Tobias
- 2nd April 2012, 03:08
Maybe I didn't explain it well enough. In case I didn't. What I am thinking is the HPulsin would only work on CCP pins. It would be just a quick clean intuitive way for people to measure frequency, duty cycle etc. I have no idea how Pulsin works behind the scenes and why it isn't as good as using the CCP technique.

Instead of having to set up timers, prescaling, dealing with reseting overflows etc, HPulsin would have a couple defines like Max and Min Frequency (this would set up the prescaling) Then the HPulsin would have a couple parameters like measuring hi or low, where to store the data and then the data stored is converted to real time numbers. It would work in the background and not tie up code execution speed like Pulsin either.

Look at it this way, HPulsin would free up alot of bandwidth on this forum that is used to explain how to use CCP pins too :)

longpole001
- 2nd April 2012, 07:42
probably not , so many more import ones that can be added and needed