PDA

View Full Version : Pulsin problem?



Skylar
- 23rd May 2009, 12:10
Hi,
I'm using pulsin to measure the high time of a squarewave created by the engine control unit to drive the tachometer. I'm using a 16F877a with a 20MHz osc.

At 1000 rpm or 16.667Hz, my LCD screen shows 950-1050 (hightime is around 1500counts). All is well, I thought.
So I rev the engine to 2000rpm, my screen only shows 1333, and 1500 at 3000rpm. hightime is around 1079 at 3000rpm, it should be 750.

Checking the same wire with the frequency function on my multimeter, it reads 32-33Hz at 1000rpm and 66Hz at 2000rpm. This wire should have a squarewave at the engine speed. So my multimeter is reading twice this rate but it at least proves that the output is linear.

I think the problem is with pulsin. I was previously using count to measure the number of rising edges in 500ms and multiplying this by 60. This worked but it was slow to update and the resolution wasn't as good as I wanted it.

Any thoughts on why the PIC isn't interpreting the wave properly?

dhouston
- 23rd May 2009, 13:38
How square are the pulses?

Acetronics2
- 23rd May 2009, 14:19
Hi,

here, you are supposing your ECU Outputs a perfectly square wave ... is it real ???



At 1000 rpm or 16.667Hz, my LCD screen shows 950-1050 (hightime is around 1500counts)


??? 1500 counts are 3 ms @ 20 Mhz ... 6ms ( square wave ) per rev is ... 10 000 rpm !!! ... not 1000.

you have a calculation error somewhere !!!

let's say 15000 counts ...

60 000 000 / 2 / 2 / 15000 = 1000

60 000 000 is 60 Million µs in a minute
2 is for square wave ( you measure half duration )
2 is for 2 pulses per rev ( matches your DVM result ... hé,hé )
15000 is Pulsin result.

also see DIV32 for 60 E6 ( or 15 E6 ! ) value use ...


You'd better use " interrupts on edge " that would measure the full cycle ( High + Low parts of the signal ) regardless of the duty factor of your pulse ...

see " DT Instant interrupts " for that ... works great ++ aboard my Honda lawn tractor ( lol )

Alain

Skylar
- 27th May 2009, 15:40
Yeah, I have no idea how the pulses look nor do I have equipment to see it.

Acetronics, you are right about the hightime, it is 15000, I forgot I was looking at the number divided by ten on screen.

I'll try using interrupts, it will work that way but it'll take me a while to get my head around it.

Thanks. :)