PDA

View Full Version : PortA.2 on a 16F676



ardhuru
- 10th April 2007, 11:54
Hi,

I have a circuit designed around a 16F676. Basically, I am feeding the mains sine wave (after the transformer, thru' a 22K resistor) to PortA.2. I did a pulsin to measure the width of the positive cycle, and got a reading of around 120 (12 ms).

Since I am feeding a sine wave, I dont expect to get a precise reading, as I realise the clipping would happen somewhere on the rising and falling edges. This would be allright. (Actually for 50 Hz, I would have expected the reading to be *less* than 100, or 10ms for a half cycle, but like I said I dont need absolute values)

But, the problem is this; the same signal fed to any other PortA pin gives a much higher value (175 or thereabouts).

I could of course shift the input to the other pin(s), but my PCB is designed.

What could be causing this? What is different about PortA.2 from say A.0,A.1 or A.5?

BTW, I have configured the PIC for all digital, comparators disabled and weak pullups disabled.

Any help would be appreciated!

Regards,

Anand

Acetronics2
- 10th April 2007, 13:04
Hi,

A look at the datasheet shows A.2 is a schmitt trigger input ... not so good for such measurements.
Measurement differences with other ports come from here ...

The only way to keep your board as-is would be to raise the voltage from your trafo ... the trigger levels occur on the "very low" ( read closest to zero crossing) part of the sine.

no real hope of saving your board ...

Alain

ardhuru
- 10th April 2007, 13:17
Hi,

A look at the datasheet shows A.2 is a schmitt trigger input ... not so good for such measurements.
Measurement differences with other ports come from here ...

Alain

oh, missed that.

Thank you so much; fortunately I do have a spare pin I could use.

I still dont understand why the pulsin should not be 10ms (50 Hz, positive half cycle) or *less*, rather than the roughly 17 ms that I'm getting?

Regards,

Anand

Acetronics2
- 10th April 2007, 13:59
Just look at your sine w/the scope ...

some surprises guaranteed !!!

Alain