Use 08M as a One Shot

Reloadron

Senior Member
This I believe is my very first post and I am new to the Picaxe family of chips. I will try to explain what I am trying to do.

Here is my code so far:

Code:
main:
	if pin3 = 0 then UnLock
	goto main
UnLock:
	for b0 = 0 to 0
	if pin3 = 1 Then Exit
	high 4
	pause 200
	low 4
	pause 500
	next b0
	pause 1000
	goto main
What I am attempting to do is when pin3 = 0 (logic low) run the Unlock. I know I can use a PulseOut as well as other combinations to get a pulse out on pin4. However, I just want a single shot pulse out and not have the routine repeat over and over as long as pin3 is low. Right now I am unsure of the pulse width I will actually need but a guess would be between 200 to 500 mSec.

When pin3 again cycles from High to Low I would like things to repeat but not before pin3 has gone from a High to Low state.

I am very new to PICs but not new to electronics in general. The output pulse on pin4 will interface to a mosfet to drive a solenoid. I just can't figure out how to get the desired results.

Thank You very much for any help with this.

Ron
 

hippy

Ex-Staff (retired)
Welcome to the PICAXE forum.

I think the issue is with your FOR-NEXT loop; this will not repeat indefinitely. The solution would be to use a DO-LOOP and you can reorganise your code to make its functionality clearer -

Code:
main:
	if pin3 = 0 then UnLock
	goto main
UnLock:
	high 4
	pause 200
	low 4
 	pause 500
	Do : Loop Until pin3 = 1
	pause 1000
	goto main
 
Last edited:

Reloadron

Senior Member
Many, many thanks Hippy for pointing me in the right direction with this. I had considered just going with a 555 timer but really wanted to use a PIC. Now I have something to work with.

I won't be a stranger here either and thank you for the welcome!

Much Appreciated
Ron
 

MPep

Senior Member
Welcome to the Forum.

Here is a solution (based on Hippy's code) with a PULSOUT command
Code:
main:
    if pin3 = 0 then UnLock
    goto main
UnLock:
     pulsout 4,200
     pause 500
    Do : Loop Until pin3 = 1
    goto main
Note that I have removed the "PAUSE 1000" in case the PulseOut is needed quicker than the minimum interval of 1s.
MPep.
 
Last edited:
Top