PDA

View Full Version : pulsin question



schu4647
- 28th May 2006, 16:05
Question about the pulsin command. Lets sayd I do Pulsin portb.0,1,var. Does it have to see a low to high transition before it starts counting, and then it stops counting when it sees a high to low transition? Or does it start measuring as soon as it sees the pin is high until the high to low transition. I am just curious if I need something in my program to filter that out. Maybe put the pulsin comman in an if statement. something like:

If Portb.0=0 then
pulsin portb.0,1,var
end if

This way I only start the pulsin comman when my signal is at 0 assuring that I will capture the entire high signal. Any help would be appreciated. The manual doesn't seem to explain this well.

Travin77
- 28th May 2006, 21:15
What type of pulse are you measuring?

schu4647
- 28th May 2006, 22:52
It is a PWM signal 0 to 5 volts. Rather than setup an RC circuit to get an analog voltage I am measuring the low time and high time and then finding the duty cycle from there. Just curious if the command waits for a transition to start the timer, or if it starts whenever the pin is in the desired state even if it has been there for some time. It actually works very well. I just wanted to understand the command a little better. The manual says that it turns off on a transition, but it doesn't say if the timer turns on on a transition.

Travin77
- 28th May 2006, 23:52
I have no clue. Sounds like a Melanie or Bruce question. I think that it starts at the zero axis and stops on the turn down or turn up, but I am not for sure.

Sorry,

Travin

mister_e
- 29th May 2006, 14:00
Never test it but i hope it wait for a rising or falling edge. Usually i prefer to use the internal Timer or the PIC CCP module.

As it works.. you may stick to PULSIN or read the CCP tips and trick document of microchip bellow.
http://ww1.microchip.com/downloads/en/DeviceDoc/41214a.pdf

schu4647
- 29th May 2006, 20:46
It actually works great. I put two of the same pulsin commands next to eachother. That way if the first one only catches part of the pulse, the second one will get the whole one. Not very efficient, but I am not making anything real complicated and I have the resources to spare. I will keep it that way until I know for sure how the command works. When I compare my calculated duty signal to a DVM, the two are the same.