PDA

View Full Version : Reading and storing pulses from 8 bit port



daan.joubert
- 19th October 2016, 12:58
Hi Group,

My plan is to read incoming pulses on the 8 input lines of a port, store/totalize in a long variable and transmitted when requested.
The pulses are generated by 8 electricity meters, issuing 1000 pulses per kWh. (1 meter per port input)
In order to read a maximum of 10 kWh the pulses from each meter will appear at approx 2.5 seconds interval.
The possibility do exist that pulses from 2 or 3 meters will arrive simultaneously.
To overcome the problem of simultaneous pulses I thought of using interrupts but I am not sure if interrupts can be done on 8 input pins.
Also the operation of reading/totalizing/storing of the pulse data should not be affected by the montly request for down load.

Unfortunately I do not have a try-ed program to attach as I am still trying to figure out what to do.

Has any-one perhaps got some info or a suggestion other than PicBasicPro for this type of operation.
Any support will be appreciated.

Thank you all in advance

daan.joubert
- 19th October 2016, 13:35
Hi group,

Just after I have submitted a question on PicBasicPro I saw the message from Sticky.
I am sorry if my post went to the wrong section.
Can moderator fix the placing?

HenrikOlsson
- 19th October 2016, 13:43
I'm pretty sure there are PICs with a full 8-bit port worth of IOC capable pins and some devices lets you set it up so it only triggers on rising or falling (and not both).

But since this is still a fairly low frequency input I guess you could just poll the port, periodically (like 10 times per second) and XOR the port with the result from the previous poll. Any bits set in the result have changed. Increment your 8 counters based on state of each bit. This has the drawback of incrementing the counter twice for each pulse but there are ways around that too of course.

/Henrik.

daan.joubert
- 20th October 2016, 07:32
Henrik,

Thank you for the prompt info.
I will have a look at the Pics available and try experimenting.

/Danie

Demon
- 20th October 2016, 17:23
Look for IOC feature. I remember seeing PICs that would monitor all of port B for a change.

PIC18(L)F2X/4XK22:


RBIE: Port B Interrupt-On-Change (IOCx) Interrupt Enable bit

daan.joubert
- 27th October 2016, 21:50
Thanks Demon. I will do a search