Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 00:26 12 Nov 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Counting on a non-count input

Author Message
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 2171
Posted: 07:54am 02 Oct 2018
Copy link to clipboard 
Print this post

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

Edited by CaptainBoing 2018-10-03
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10572
Posted: 08:50am 02 Oct 2018
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 10572
Posted: 09:28am 02 Oct 2018
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 2171
Posted: 09:41am 02 Oct 2018
Copy link to clipboard 
Print this post

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

Edited by CaptainBoing 2018-10-03
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10572
Posted: 11:38am 02 Oct 2018
Copy link to clipboard 
Print this post

See the new thread for a solutionEdited by matherp 2018-10-03
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 2171
Posted: 12:04pm 02 Oct 2018
Copy link to clipboard 
Print this post

Amazing!

thanks so much!
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025