![]() |
Forum Index : Microcontroller and PC projects : Picomite Counting Pin
Author | Message | ||||
palcal![]() Guru ![]() Joined: 12/10/2011 Location: AustraliaPosts: 1993 |
With a pin set to CIN is it possible to start the count at a certain value. I want to save the count and be able to reinstate it later. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
Mixtel90![]() Guru ![]() Joined: 05/10/2019 Location: United KingdomPosts: 7938 |
Have you tried PIN(countpin)=n? I haven't. :) Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
palcal![]() Guru ![]() Joined: 12/10/2011 Location: AustraliaPosts: 1993 |
Setpin (GP9), CIN Pin(GP9) = 10 Error: Pin(GP9) is not an input although technically it is an input, a counting input "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
phil99![]() Guru ![]() Joined: 11/02/2018 Location: AustraliaPosts: 2642 |
Yes, that works. > setpin gp6,cin > ? pin(gp6) 0 > pin(gp6)=55 > ? pin(gp6) 55 >-------------------------------give it a few pulses > ? pin(gp6) 66 > Edit Could that pin be configured for something else? OPTION LIST Edited 2023-01-28 17:58 by phil99 |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10315 |
This is incorrect syntax. By using brackets you are making GP9 a variable and it will have the value 0 SETPIN GP9,CIN PIN(GP9)=10 works perfectly and does what you want In the absence of a signal PRINT PIN(GP() will then return 10 |
||||
palcal![]() Guru ![]() Joined: 12/10/2011 Location: AustraliaPosts: 1993 |
Thanks for that I was very confused obviously. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10315 |
OPTION EXPLICIT would have found it ![]() Edited 2023-01-28 18:12 by matherp |
||||
palcal![]() Guru ![]() Joined: 12/10/2011 Location: AustraliaPosts: 1993 |
Yes Peter I must use it, it was old micromite code. New problem, I bought a new rain sensor (tipping bucket) that used a reed switch, I modified the old sensor to use a photo interrupt. I did not want to modify the new one but the reed switch is bouncing, is there an easy fix for this. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
disco4now![]() Guru ![]() Joined: 18/12/2014 Location: AustraliaPosts: 1003 |
Here is what I used for the tipping bucket to de-bounce it. I probably got it from TBS somewhere. DIM INTEGER RainPin=15,rain_count,rain_last Setpin RainPin, Intl,rainguageClick,Pullup . . 'rainguage sensor interrupt Sub rainguageClick local thistime thistime=Timer-rain_last rain_last=Timer If thistime>10 Then rain_count=rain_count+1 Print "Rain click "+str$(rain_count) End If End Sub Latest F4 Latest H7 FotS |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
I put a 100nF capacitor on the input. It also helps stop nasties getting in. With the capacitor, I don't need any software debounce, but it all helps. Jim VK7JH MMedit |
||||
palcal![]() Guru ![]() Joined: 12/10/2011 Location: AustraliaPosts: 1993 |
Thanks @disco4now but it was easier to try Jim's solution first and it works perfectly Thanks Jim "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
Mixtel90![]() Guru ![]() Joined: 05/10/2019 Location: United KingdomPosts: 7938 |
If you are using a cap for debounce on a reed switch it's probably a good idea to put some sort of resistance in series with it. The contacts on a reed are often tiny and discharging even 100nF directly through them isn't good. If you add about 100R in series with the cap it should preserve the life of the contact somewhat. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
I usually start with something like this: ![]() Jim VK7JH MMedit |
||||
Mixtel90![]() Guru ![]() Joined: 05/10/2019 Location: United KingdomPosts: 7938 |
That's the general idea. :) Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
palcal![]() Guru ![]() Joined: 12/10/2011 Location: AustraliaPosts: 1993 |
Thanks I will incorporate in my hardware. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |