TMR1 Counter - PIC16F1615

Discussion on both general simulation and Proteus VSM microcontroller simulation.
Post Reply
Aussie Barry
Professional User
Posts: 20
Joined: Sat 2018-01-06 1:40

TMR1 Counter - PIC16F1615

Post by Aussie Barry »

Hi All,

I am working on a project which will use TMR1 of PIC16F1615 in counter mode to count the number of pulses received in one second.
TMR3 is set up as the one second time base.
Ultimately, this circuit will be used to count the pulses derived from an encoder mounted on a motor shaft but for now I am simulating the source using a clock generator.
The number of pulses is displayed on the LCD screen and is broken down into TMR1L, TMR1H and a variable PulseCount (PCNT).
As a sanity check, I have used a counter timer which shows the incrementing count until it is reset during the one second ISR.
All is functioning as expected except for the fact that the PulseCount displayed on the LCD is three times larger than expected.
Setting the clock source to 50Hz, the counter timer resets at 50 every second (as expected) however the PulseCount displayed on the LCD reads 150.

I am at a loss to explain why this is happening and I would appreciate a fresh set of eyes to help determine what is going wrong.

The full project is attached for evaluation.

I look forward to any comments and/or suggestions on where this is going wrong.

Cheers
Barry
Attachments
TMR1_Test_16F1615.pdsprj
(37.97 KiB) Downloaded 4 times
Ettore
Labcenter Staff
Posts: 2932
Joined: Fri 2006-03-03 11:56
Location: Milan
Contact:

Re: TMR1 Counter - PIC16F1615

Post by Ettore »

Hi Barry,
Please use the DCLOCK - digital clock - rather than PULSE (which is an analogue generator). In alternative, you may try to use the PULSE generator, by editing the Rise and Fall Time to 1ns or less (1us is the default). I suggest, however, to use DCLOCK.
Kind regards,
Ettore Arena - Labcenter Electronics.
Aussie Barry
Professional User
Posts: 20
Joined: Sat 2018-01-06 1:40

Re: TMR1 Counter - PIC16F1615

Post by Aussie Barry »

Hi Ettore,

Thank you for the quick reply.
The DCLOCK solution worked perfectly.
I will try to remember this for future reference.

Cheers
Barry
Post Reply