Regarding emergency stop.

Jacobsen

New Member
Regarding emergency stop.
I´m looking for a way to instruct my IC to make an emergency shut down, and thereafter beeing able to switch the system on again using the very same button.
Does any one here knows a smart way to do so i.e coding example or perhaps a link to such a code.

Best regards
Monie
 

Brietech

Senior Member
You could hook a button up to one of the input pins, and then use the "interrupt" feature. Have the code set a "flag" so that it enters into a suspend state, and then returns. This is pseudo code, since I don't remember how to set up an interrupt, but it is in the manual:


symbol disabled_flag = b0

main:
if disabled_flag == 1 then main
[your code goes here]

interrupt:
if disabled_flag = 0 then turn_off
else
disabled_flag = 1
return

turn_off:
disabled_flag = 0
return
 

moxhamj

New Member
' b0=0 = off and 1 = on
' in psuedo code - syntax may not be quite right
main: if pin 1 = low then ' read input
goto main
endif
' got here so button must have been pushed
if b0=0 then
b0=1
high 2' make output high
else
b0=0
low 2' make output low
endif
pause 1000' or whatever - debounces the button
goto main
 

leftyretro

New Member
Well if it's a real 'emergency' type shitdown and needs to work no matter what your software program might or might not be doing correctly, you might consider wiring the switch to hold the chip into a reset condition. Turning the reset switch off would then allow your chip to start it's normal sequence.

Lefty
 

Rookie

Member
Or maybe you can use the button to remove the power to Picaxe
maybe with one N/c switch or relay... (hard reset)
 

Jacobsen

New Member
Still not functioning

Dear freinds.
I´m using the 1.5.1 version of the Picaxe editor.
No matter what type of ´else´ comand I try to use
it seems to disfuntion.
I´ve even tried to copy/paste your comands directly into my own
editor, still not funtioning!
Quote: Yes you can, View>Options>Editor>Enhanced Mode (have been checked and recheked)
Does any one knows what seems to be the main problem here and how to come arround it.

Best regards

Monie
 

KMoffett

Senior Member
This program was used with a 08M to have a Push-to-Start, Push-to-Stop, or Program-to-Stop function. It was used with the attached circuit : 08Mswt.jpg
Pushing the switch powers up the 08M which turns on Q2 and Q1, latching on the power. If Kill is periodically checked, pressing the switch again will kill the power. The program can also goto Terminate based on any other criteria.

Code:
'Picaxe....08M Push-ON/Push-OFF/Program-OFF Power Switch
'Use with 08Mswt.jpg circuit

Start:'Pin 0 high to latch power on
	High 0	

'Operational program here with gosub Kill or goto Terminate to shut off power

Kill: 'Push-OFF to kill power
	If pin2 = 1 then Terminate
	Return

Terminate:'Pin 0 low to kill power
	Low 0				
	END
Ken
 

Attachments

Jacobsen

New Member
reply to KMoffet
Thanks for your imidiate and constructive reply.
We have now tested your method in more than one setup, but the button does not terminate the power.

PS. our specific model is the Picaxe 28X. If that changes anything in your comment.

Do you have the know how to alter our codes in order to make it work, we are a bit lost here (please).

'Picaxe....08M Push-ON/Push-OFF/Program-OFF Power Switch
'Use with 08Mswt.jpg circuit

SYMBOL Speed = w0

Start:'Pin 0 high to latch power on
High 0

readadc 1,Speed
pwmout 1 , 65, Speed
debug Speed
Pause 100

Kill: 'Push-OFF to kill power
If pin2 = 1 then Terminate
Return

Terminate:'Pin 0 low to kill power
Low 0
END

Many Learning whises for the furture.

Monie
 

KMoffett

Senior Member
reply to KMoffet
Thanks for your imidiate and constructive reply.
We have now tested your method in more than one setup, but the button does not terminate the power.

PS. our specific model is the Picaxe 28X. If that changes anything in your comment.

Do you have the know how to alter our codes in order to make it work, we are a bit lost here (please).

'Picaxe....08M Push-ON/Push-OFF/Program-OFF Power Switch
'Use with 08Mswt.jpg circuit

SYMBOL Speed = w0

Start:'Pin 0 high to latch power on
High 0

readadc 1,Speed
pwmout 1 , 65, Speed
debug Speed
Pause 100

Kill: 'Push-OFF to kill power
If pin2 = 1 then Terminate
Return

Terminate:'Pin 0 low to kill power
Low 0
END

Many Learning whises for the furture.

Monie
Monie,

I went back and breadboarded the circuit and took a look at my original program. I changed the value of R5 in the circuit to 100k (from 33K) to improve pull-up. I wrote a couple of sample trial programs that I tested and work.

The first one repeatedly looks at Pin 2 inside a loop that does something...blinks an LED in my case:

Code:
'Checking for terminate call inside of loops.

Start:'Pin 0 high to latch power ON and wait for open Pushbutton switch
	High 0
	If pin2 = 1 then Start		'Check if Pushbutton is still closed
	
Flash: 'The operational program must repeatedly check Pin 2				

	Toggle 4				'Turn output on and off. (ie a LED/resistor on pin 4)
	Pause 100				'Pause 100 mS
	If pin2 = 1 then Terminate	'Check for high on P2 and Terminate if true
	goto Flash

Terminate:
	'Insert steps here to stop all operational functions before pushbutton
	'is open, because holding down on the pushbutton will maintain power.
	'Outputs will maintain their last state and background functions,
	'like PWM, will continue until the PB is open.
	Low 0					'Pin 0 low to kill power
	stop

The second one uses an Interrupt to detect the pushbutton and terminate:

Code:
'Checking for terminate call with an Interrupt

Start:'Pin 0 high to latch power ON and wait for open Push Button switch
	High 0
	If pin2 = 1 then Start		'Check if Push Button is still down
	setint %00000100,%00000100
	
Flash: 'This the operational part of the program				

	Toggle 4				'Turn output on and off. (ie a LED/resistor on pin 4)
	Pause 100				'Pause 100 mS
	goto Flash

Interrupt:
	goto Terminate
	
Terminate:
	'Insert steps here to stop all operational functions before pushbutton
	'is open, Holding down on the pushbutton will maintain power.
	'Outputs will maintain their last state and background functions,
	'like PWM, will continue until the PB is open.
	Low 0					'Pin 0 low to kill power
	stop
I hope this helps.

Ken
 

Attachments

moxhamj

New Member
Did you download the latest version? You say you are running version 1.5.1. The latest version is 5.1.5. Is your version number a typographical error or is this the actual version you are running? The If..Then...Else is now becoming the standard way of writing code so it would help greatly if you had this working.
 

Jacobsen

New Member
Now it works!
Hi Guys, we´ve been working hard in order to make this happen, the coding works flawlessly both in syntax / simulation as well as on the board, thanks for your constructive help.
BUT if some of you would like to evaluate and comment on it, I´l be more than thanksfull

Codes:

Symbol Speed = w2

main:
if pin0 = 0 then ' Hvis PortC pin0 = 0
if pin0 = 0 and b0 = 1 then button 'if PortC pin 0 = 0 og b0 = 1
pwmout 1 OFF
goto main
endif

' got here so button must have been pushed
if b0=0 then
b0=1
high 2' make output high

else
b0=0
low 2' make output low
' readadc 1,Speed
' pwmout 1 , 65, Speed


endif
pause 200' or whatever - debounces the button
goto main


button:
readadc 1,Speed
pwmout 1 , 65, Speed
goto main

Thanks
Monie
 

Jacobsen

New Member
Hi Dr. Acula

Yes my fault, offcourse I´m running the 5.1.5 version! Thanks any way.
And now I have learned a lot about using the And If Else codes.

Monie
 

Jacobsen

New Member
Hi KM Offet
How would you surggest that we insert theese lines in your program?

readadc 1,Speed
pwmout 1 , 65, Speed

These lines should go in the section where we manage the pwm controller! so that we can activate and deactivate it with a push/push button.

Anyway this is a link to my schematic´s.
www.sunwind.dk/projekt/Diagram.jpg

Monie
 

KMoffett

Senior Member
Monie

The I/O pins have been changed from my original schematic to accommodate the 08M's ADC and PWM pins.

Code:
'Checking for terminate call with an Interrupt
Symbol Speed = b0
setint %00001000,%00001000

Start:	'Pin 0 high to latch power ON and wait for open Push Button switch
	High 0				'Latch power on.
	If pin3 = 1 then Start		'Check if pushbutton is still down
	
Control:	'The operational program will terminate on interrupt.				
	Readadc 1,Speed			'Read 8-bit voltage on Pin 1 into b0
	PWMOUT 2,65,Speed			'PWM ON to Pin 2...output proportional to Pin 1 voltage.
	Pause 100				'Pause 100 mS, or however often you need to update ADC/PWM.
	goto Control

Interrupt:
	goto Terminate
	
Terminate:
	PWMOUT 2,0,0			'PWM OFF to Pin 2
	Low 0					'Pin 0 low to kill power
	stop
Ken Moffett
 

Jacobsen

New Member
which changes PWMOUT ON or OFF

To Kmoffet

A part of your codes:

Terminate:
PWMOUT 2,0,0 'PWM OFF to Pin 2
Low 0 'Pin 0 low to kill power
stop

It can´t stop here, but has to wait for a new Push, which changes PWMOUT ON or OFF. (or opposite depending on where it started).
The program is therefore continueing in an ongoing loop.
It´s these commandos as setint %00001000,%00001000 and Interrupt: that I would like to know how to use. Will you try to put this loop for either Push ON or Push OFF in your codes?

Best regards
Monie
 

KMoffett

Senior Member
Monie,

I think my circuit and program are differing from yours a lot at this point. My circuit/program was written for a one-time operation with a complete power shut-down at the end.

If you're just toggling the operation of the PWM on and off, you may just want to loop with if-then statements while looking at the switch.

Code:
Start:
symbol Speed = b0

PWMoff: 
	PWMOUT 2,0,0			'Turn off PWM
	If pin3 = 1 then PWMon		'Check pushbutton for turn on
	goto PWMoff				'continue PWMoff loop

PWMon:
	Readadc 1,Speed			'Read 8-bit voltage on Pin 1 into b0
	PWMOUT 2,65,Speed			'PWM on to Pin 2...output proportional to Pin 1 voltage.
	If pin3 = 0 then PWoff		'Check pushbutton for turn off
	Pause 100				'Pause 100 mS, or however often you need to update ADC/PWM.
	goto PWMon				'continue PWMon loop
	end
Review the Basic Commands Manual for "setint" for more info on that.

Ken
 
Last edited:

KMoffett

Senior Member
Monie,

After my previous program ran through my head a few times today I realized it didn't allow enough time to release the pushbutton between turning the PWM on or off. So here's another try:

Code:
Start:
symbol Speed = b0
goto PWMoff					'Start with PWM off

PWMoff: 
	PWMOUT 2,0,0			'Turn off PWM
	If pin3 = 0 then PWMoff		'Check if pushbutton pushed or continue PWMoff
	gosub SWTon				'Pushbutton was pushed, check for release
	goto PWMon				'Turn on PWM
	
PWMon:
	Readadc 1,Speed			'Read 8-bit voltage on Pin 1 into b0
	PWMOUT 2,65,Speed			'PWM on to Pin 2...output proportional to Pin 1 voltage.
	Pause 100				'Set period between ADC>PWM updates 
	If pin3 = 0 then PWMon		'Check if pushbutton pushed or continue PWMon
	gosub SWTon				'Pushbutton was pushed, check for release
	goto PWMoff				'Turn off PWM
	
SWTon:
	Pause 200				'Pause for debounce
	If pin3 = 1 then SWTon		'Check if pushbutton is still pushed
	return				'Pushbutton was released
It worked on the simulator.

Ken
 

KMoffett

Senior Member
Monie,

I hope you don't mind me messing with this, but it's just been a fun little exercise. I added some lines (* in comments) to make the PWM turn on or off as soon as the buttoned is pressed, and not wait for it to be released. The status of the button will not be checked again and PWM cannot be adjusted until the button is released...for better or worse.

Ken

Code:
Start:
symbol Speed = b0
goto PWMoff					'Start with PWM off

PWMoff: 
	PWMOUT 2,0,0			'Turn off PWM
	If pin3 = 0 then PWMoff		'Check if pushbutton pushed or continue PWMoff
	Readadc 1,Speed			'*Read 8-bit voltage on Pin 1 into b0
	PWMOUT 2,65,Speed			'*PWM on to Pin 2...output proportional to Pin 1 voltage.
	gosub SWTon				'Pushbutton was pushed, check for release
	goto PWMon				'Turn on PWM
	
PWMon:
	Readadc 1,Speed			'Read 8-bit voltage on Pin 1 into b0
	PWMOUT 2,65,Speed			'PWM on to Pin 2...output proportional to Pin 1 voltage.
	If pin3 = 0 then PWMon		'Check if pushbutton pushed or continue PWMon
	PWMOUT 2,0,0			'*Turn off PWM
	gosub SWTon				'Pushbutton was pushed, check for release
	goto PWMoff				'Turn off PWM
	
SWTon:
	Pause 100				'Pause for debounce
	If pin3 = 1 then SWTon		'Check if pushbutton has been released
	return				'Pushbutton was released

end
 

Jacobsen

New Member
Dear Ken and
all other users that have contributed.

Thank you very much for your interrest in this, to us, highly important project. We as well enjoy this way of working, and bennefit aswell from it.
By the way, do you know what we use theese codes and schematics for. Let me tell you, we are privately working two different projects. the first is for a solarpowered BLDC pump motor for sun heated panels.
The other is a bit more demanding, we are trying to make a Ford Scorpio v6 2,9 I station wagon to run entirely on water, this is done by splitting demineralised water into Hydrogen and Oxygen, this gas is up to 7 times more power full than gasoline vapour, and we produce app. 1840 literes of gas out of every liter of water.
In both cases we need to be able to have a push to stop, so we can shut off production imidiately.
The reason why I (Monie) write in 'we' terms is that I my self does not speak nor write a single word of any foreing language (I'm from Denmark). Mainly everything is translated by John (the guy with the Ford). We hope to work some more with you guys later on.
Follow the development of our projects on www.sunvind.dk

With Kind Regards

Monie (John)
 

BeanieBots

Moderator
EMERGENCY STOP! EMO
SAFETY DEVICE.
Not suitable for PICAXE.
In fact, as a general rule, there should not be any silicon in an emergency stop device. It should be done with drop-out SAFETY (CE Marked) relays.
 

hippy

Senior Member
I AGREE WITH BEANIE BOTS

If you need a guarantee that the system will stop when a button is pressed - and I bet you do on the Ford - you should not use a PICAXE.

The simple question is, what happens if the system does not stop when the button is pushed ?

The answer, from "nothing bad happens" to "lives will be lost", determines how safety critical the component is. The more critical, the more reliable and guaranteed to work it has to be.

I had a car once whose ignition switch burnt out shorted. Turned the car off, engine kept running. No real problem, pulled the ignition coil lead off and everything was okay. I'd hate to think though had that switch been controlling a pressure vessel building up pressure or a reactor going critical. Some IBM mainframes used to have a neat ( expensive when operated ) design that the emergency stop button ( "it's on fire !" ) activated solenoids which pushed the PSU from the power bus. The bottom line is that you need something as guaranteed to stop the fault condition as you can get.
 
Last edited:

Jacobsen

New Member
Hi Guys

Offcourse you are totally right about this matter. One af the main mistakes from our site was that we called it a Emergency stop. what we actually uses this function for is to stop production, if wanted. (mainly a language mistake) We regret if we have caused some troubled thoughts.
Also we have failed to mention that we have both a fuse as well as a manually operated cut off contact in front of the entire system.
On the production side we have several saftety devices, we have a water loop and a flame retarder/stop (if thats the right word) and a chock valve to ansure that all eventuallyties are taken care off!
But thank you very much for you concerns regardign our wellbeing!
And thank you very much for the constructive critic and mind opening conversions.

Best regards Monie
 

Jacobsen

New Member
To Hippy

Perhaps this next subject should be posted under another thread, but when i saw your reply i hope that you will keep on replying, and if you want to we can jus change thread.

Some times ago you helped me with the codes for a 4 lines display HD44780 , and that worked flawlessly.
I´ve made a solar cell – charger, but when I try to the Simulate codes, a line pops up saying:
25 (SYMBOL byte = b12 ; w6) An error as:
www.sunwind.dk/projekt/CompoleError.jpg

My codes:
www.sunwind.dk/projekt/SolarChanges.BAS

Do you have a proposal that can relieve the problem with Compile Error?
So I´m able to Simulate my codes for the solar cell -charger.


Best regards
Monie
 

hippy

Senior Member
25 (SYMBOL byte = b12 ; w6) An error
This is a simple one so may as well answer here. "byte" has become a reserved word, so just change all occurrences of "byte" to "bite" or something suitable and it should all be okay again.

PS : Thanks for clarifying "Emergency Stop".
 
Top