|
Forum Index : Microcontroller and PC projects : Counting on a non-count input
| Author | Message | ||||
| CaptainBoing Guru Joined: 07/09/2016 Location: United KingdomPosts: 2171 |
Hello forum. I have a project using a 28 pin '170 that requires to COUNT on a pin that is not specifically able to do it i.e. not pins 15 - 18. It's potted and the only spare pins brought out are 23 & 25 so no opportunity to adjust - I had a look through the embedded C Functions in the firmware but although there is a lot of really useful stuff to add "soft" ports and other nice stuff, count is not one of them. It's not particularly high frequency (<5KHz) Has anyone tried this before? Method? any success? I tried with the following but the best I could get is about 100Hz dim integer n,m timer=0 do if pin(23)<>m then n=n+1:m=not m loop until timer >=999 ? n,m,timer Thanks in advance for any help |
||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10572 |
Pin 25 RB14 can be used as the input clock to timer 5 or as an alternative to INT1. The simplest solution which could work is to set up pin 18 as a count input and then call a CFunction which reallocates INT1 to RB14. Then in theory COUNT would work on pin 25 - to be proven!!!!. |
||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10572 |
OK this works but it of course assumes you aren't using pin 18 for anything pwm 1,10000,50 'connect pin 4 to pin 25 for test purposes setpin 18,CIN Remap() pause 1000 ? pin(18) end CSub Remap 00000000 3C02BF81 8C43FA04 24040002 7C831804 AC43FA04 03E00008 00000000 End CSub |
||||
| CaptainBoing Guru Joined: 07/09/2016 Location: United KingdomPosts: 2171 |
Thanks Peter. I did look at the ChangePin CSub in the firmware distribution but couldn't see how to make it work to get the count onto another pin. What you show above looks really useful but sadly I am limited with what is available and the project has a RTC, so pin 18 is in use. The count pins were used fairly rapidly because of their 5V tolerance (although they have opto-isolators on their inputs also) and now a change is required after the module has been in service for a while - even so it is potted so I have no opportunity to re-jig the pins used. Here is a map of what I have available, the three spares are the only stuff available.: ![]() With some inconvenience, it would be possible to re-assign a pin, say 15 or 16 but if I can get round this with some clever software so much the better. It may be I am out of options. I thought about using the soft i2c from the embedded library, but the thing is potted so I can't get to them anyway cheers h |
||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10572 |
See the new thread for a solution |
||||
| CaptainBoing Guru Joined: 07/09/2016 Location: United KingdomPosts: 2171 |
Amazing! thanks so much! |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |