Timer

Lamtron

Member
I have a project that requires designing an adjustable timer for head trauma patients.
The timer will have adjustability from 0 to 60 secs. The patient starts the timer by pressing a rehab switch which is connected to the picaxe and then cycles down the program. If the patient continues to hold the start switch down which happens do to head trauma I need the timer to finish out the selected time without retriggering. I could do it in hardware but that can get messy. So it would be non-retriggerable. I found examples of adjustable timer using the picaxe but just need some help in steering me in the right direction or picaxe command.
Thanks
 

hippy

Technical Support
Staff member
Something like ... where 60000 ms = 60 seconds ...

Code:
w1 = 60000
Do : Loop Until pinX.Y = 1
For w0 = 0 To w1
  If pinX.Y <> 1 Then ButtonPrematurelyReleased
  Pause 1
Next
Goto ButtonHeldForTimePeriod
You might have to explain further what the 'without retriggering' amounts to, what should happen when the button is prematurely released.
 

techElder

Well-known member
A bit off topic (OT), but still pertinent to a design process, I was working on a rehab project last year for my brother in rehab.

The solution was there, but I couldn't get past the regulatory environment. The PT techs couldn't legally even use a rubber band on a patient unless it came through traceable channels.

Just because we say, "Oh, its just a 9 volt battery", doesn't relieve them of this requirement.
 

Lamtron

Member
The department that I work for allows me to be creative without the regulatory constraints. I have designed many devices and adapted many commercial devices that just don't fit the patients needs. The Pt and Ot therapist are great they come to me for ideas. So this project will be used for communication devices. But as you know some of patients are very challenging.
 

Lamtron

Member
Sorry about that what I need is once the trigger is pushed to have the timer start but if the patient activates the switch before it times out I need to have the program ignore the switch until it times out. Or in another case the patient may trigger the timer but continued to press or hold down the switch which I also need to ignore. So once the picaxe senses the trigger it should ignore all other things happening to the input until it completes it time delay for 0 to 60 sec adjustable.
 

hippy

Technical Support
Staff member
So, in both cases, once activated it continue to completion ...

Code:
w1 = 60000                    ; or whatever millisecond delay
Do : Loop Until pinX.Y = 1
Pause w1
Goto Done
 

AllyCat

Senior Member
Hi,

the patient may trigger the timer but continued to press or hold down the switch which I also need to ignore.
So you probably also want a Do : Loop Until pinX.Y = 0 after the PAUSE to check when it's released?.

Cheers, Alan.
 

hippy

Technical Support
Staff member
So you probably also want a Do : Loop Until pinX.Y = 0 after the PAUSE to check when it's released?.
Possibly after the 'done' routine to ensure that whatever needs to be done gets done.

And that's probably best achieved by putting it at the start, so that the button has to be released before it can be activated.
 

Lamtron

Member
Thanks I will need to do some investigation on how to use and setup Do: Loops until condition's are met.
 

Lamtron

Member
Did some investigation and not having much success in finding Code Examples for the DO:Loop until command any suggestions. Looked at pic site but I need to see examples for me to better understand .
 

hippy

Technical Support
Staff member
DO-LOOP simply means keep doing something while or until a condition is met ...

Do : w0 = w0 + 1 : Loop Until w0 > 100

Do : w0 = w0 + 1 : Loop While w0 <= 99

Do : Loop Until pinC.0 = 0

I think you are going to have to help describe what help you need, what part of DO-LOOP you are having trouble getting to grips with, because its use is probably too self-evident for me to be able to explain it as you would like.
 

Lamtron

Member
Ok kind of new to this but I need to have a non retriggerable timer. It seems that the do loop will continue or timer will continue until the switch is release. Once the timer is triggered the output will go high and any other inputs to the trigger input will be ignored until the timer has timed out.
 
Top