Input

coolmandan1

New Member
Hi,

I was wondering if it was possible to tell the picaxe chip that if an input is 'high for 3 seconds, then low for 1 second, then high again for 4 seconds, to then carry out a goto command only if that input has been high/low for the amount of seconds stated. If you don't understand what i am asking (becuase i am finding it difficult to put it into words), please reply to this post, or e-mail me at coolmandan1@hotmail.com

Thanks,
coolmandan1
 

MiB1986

Member
Hello,

i gather your trying to read...
a signal like:
_____________ ________
____| 3 secs |__1_sec| 2 sec |

if so use pulsin,

how fast are these signals coming?

Also what processor are you using, also whats the input, if its a fan for example to measure speed etc.. then you should check the input to the processor is NO more than 5 volts.

Kind Regards
 

hippy

Ex-Staff (retired)
The problem with PULSIN is that it waits for a transition then times to the next transition, so having read the first period ( 3 seconds ), the 1 second period has already started by the time the next PULSIN can be executed, so it could only read the subsequent period ( 2 seconds ).

That might not matter, but otherwise it will have to be done by polling and time counting, along the lines of ...<code><pre><font size=2 face='Courier'>
timeout = 0
Do
Pause 10
If pinX = 0 Then
timeout = 0
Else
timeout = timeout+1
End If
Loop until timeout &gt; 300 ' 300 x 10mS = 3 seconds </font></pre></code> The specification needs to be more accurately stated especially as to the tolerance of periods. For example, what happens if the middle period is greater than one second ? Are those periods stated minimums and are there maximums as well ?
 

MiB1986

Member
Hiya,

Hippy, could you use a software bounce system and make a loop check if input is present for 3 seconds? if so then .... only problem is, if the second press duration was smaller it would not reconise as a press etc...

Kind Regards
 

coolmandan1

New Member
hi MiB1986,

I understand that you would recomend using pulsin, but i don't understand how to use it, i have read the instruction manual and generaly do not understand. Could you or anyone else help?

Thanks,
coolmandan1
 

Michael 2727

Senior Member
<A href='http://www.rev-ed.co.uk/picaxe/forum/Topic.asp?topic_id=1901&amp;forum_id=13&amp;Topic_Title=PULSIN%2Bclarification%253F&amp;forum_title=No+new+posts+please%21+7' Target=_Blank>External Web Link</a>
http://www.rev-ed.co.uk/picaxe/forum/Topic.asp?topic_id=1901&amp;forum_id=13&amp;Topic_Title=PULSIN%2Bclarification%253F&amp;forum_title=No+new+posts+please%21+7

 

BeanieBots

Moderator
At standard clock speeds, pulsin has a timeout of 0.65 seconds so it won't be much use for measuring a 3 second period.
Hippy's method is the most realistic approach.
Test the input.
Wait a while
Increment a counter
Test the counter and a make decision based on what value the counter has reached.
 

Dippy

Moderator
Hippy's suggestion seems most realistic I agree - note he shows an example for one section of your time check, you'll need three - with the appropriate changes test-if-high test-if-low you get the idea.

MiB: If I understand your question, that is near-as-dammit what hippy's suggestion does. There is no simple magic debounce in software.

I must admit for that longish duration of button pressing I'd consider a bit of capacitance in there, if you are using cheap wobbley switches.
 
Top