PDA

View Full Version : Solved Basic Stamp & DS1302 Time Chip & In-Put Switches & remember the last State with power



sam_sam_sam
02-16-2012, 12:14 AM
Here are the part that I am going to use

Basic Stamp
DS1302 Time Chip
In-Put Switches

I want to remember the last State the switch is in with power lost and when power is restored the state of that switch is returned

Here is why where I work there was an in another facility with a over head crane

Here is what happen the person was going up with a load and the crane hoisted hits the upper limit switch which is what should happen
but the hoist motor is suppose to STOP how ever the contact-or contacts welded together and motor kept running and the cable broke and the hook fell to the ground

NO ONE was hurt in this accident

Our facility was told to set up our crane to where if the hoist goes past the first limit and hits the second limit switch that power it is shut OFF to the hoist
and not allow to restart until the crane has been work on to see why it when to the second limit switch

The second limit switch is being add to all of our crane

From what I understand there is NO off the shelf add on to do this So my thought is to have it where when this happen
when hook block hit the second limit switch the power is shut OFF to UP DOWN contact-or until maintenance person climb up on to the crane to trouble shoot what happen

sam_sam_sam
02-16-2012, 01:35 AM
I know how to write and read to DS1302 time chip

How ever I not sure how to save the last state of an input to the DS1302 time chip and if the power is lost how to read the state of the input from memory from the DS1302 time chip
To keep the output of the Basic Stamp is LOCK OUT until a INPUT switch is pushed to clear the input FLAG






' {$STAMP BS2}
' {$PBASIC 2.5}
'DS1302_Ram_Save_Demo
DataIO PIN 1 ' DS1302.6
Clock PIN 0 ' DS1302.7
CS1302 PIN 2 ' DS1302.5
LED PIN 4 ' Led to see if INSwitch is open
chg_S PIN 8 ' Switch to REset ALL Data
Chg_P PIN 9 ' Switch to REset Product Data used for a Job
InSwitch PIN 10 ' INPUT From Dead Man Switch
LCD PIN 15
' -----[ LCD Constants ]-------------------------------------------------------
DispLightOn CON $11
DispLightOFF CON $12
LineOne0 CON $80
LineOne1 CON $81
LineTwo0 CON $94
LineTwo1 CON $95
LineTwo4 CON $98
ClearScreen CON $0C
Baud CON 32 ' baudmode constant for LCD Display

P VAR Word
S VAR Word
reg VAR Byte
S_Reg VAR Byte
cntr_S VAR Byte
cntr_P VAR Byte

'GOSUB resetData
SEROUT LCD, Baud, [Clearscreen]
PAUSE 200
Clear:
cntr_S = cntr_S + 1 * Chg_S ' This line is to check if state of pin 8
IF (cntr_S = 6 ) THEN GOSUB resetData ' The ReSet button has to be press to clear Data
cntr_P = cntr_P + 1 * Chg_P ' This line is to check if state of pin 9
IF (cntr_P = 6 ) THEN GOSUB P_resetData ' The ReSet button has to be press to clear Data
DO WHILE INSwitch = 1
GOSUB RdRam
p = p + 1
s = s + 1
GOSUB WrRam
SEROUT LCD, Baud, [LineOne0, " Prod ", DEC5 P, CR]
SEROUT LCD, Baud, [LineTwo0, " Silo ", DEC5 S]
LOOP
GOTO Clear
WrRam:
reg = $FE
HIGH CS1302
SHIFTOUT DataIO, Clock,LSBFIRST, [reg]
SHIFTOUT DataIO, Clock, LSBFIRST, [P.HIGHBYTE,P.LOWBYTE,S.HIGHBYTE,S.LOWBYTE]
LOW CS1302
RETURN
RdRam:
reg = $FF
HIGH CS1302
SHIFTOUT DataIO, Clock, LSBFIRST, [reg]
SHIFTIN DataIO, Clock, LSBPRE, [P.HIGHBYTE,P.LOWBYTE,S.HIGHBYTE,S.LOWBYTE]
LOW CS1302
DEBUG HOME, "Product = ",DEC2 P," S ",DEC5 S, CR
SEROUT LCD, Baud, [LineOne0," S ", DEC S, " P ", DEC P , CR]
RETURN
resetData:
GOSUB WrRam
P.HIGHBYTE = 00000
P.LOWBYTE = 00000
S.HIGHBYTE = 00000
S.LOWBYTE = 00000
RETURN
P_resetData:
GOSUB WrRam
P.HIGHBYTE = 00000
P.LOWBYTE = 00000
RETURN

kwinn
02-16-2012, 02:00 AM
Here are the part that I am going to use

Basic Stamp
DS1302 Time Chip
In-Put Switches

I want to remember the last State the switch is in with power lost and when power is restored the state of that switch is returned

Here is why where I work there was an in in another facility with a over head crane

Here is what happen the person was going up with a load and the crane hoisted hits the upper limit switch which is what should happen
but the hoist motor is suppose to STOP how ever the contact-or contacts welded together and motor kept running and the cable broke and the hook fell to the ground

NO ONE was hurt in this accident

Our facility was told to set up our crane to where if the hoist goes past the first limit and hits the second limit switch that power it is shut OFF to the hoist
and not allow to restart until the crane has been work on to see why it when to the second limit switch

The second limit switch is being add to all of our crane

From what I understand there is NO off the shelf add on to do this So my thought is to have it where when this happen
when hook block hit the second limit switch the power is shut OFF to UP DOWN contact-or until maintenance person climb up on to the crane to trouble shoot what happen

Two limit switches are fairly common on mechanical systems. The first limit switch goes to the control electronics which commands it to stop. The second switch is usually a normally closed contact in series with the coil of the main power relay. When this switch opens it removes all power from the equipment. In many cases there is also a latching relay or mechanical latch that must be manually reset before power can be restored to the system.

sam_sam_sam
02-16-2012, 02:32 AM
kwinn

Thank you for your reply

I would like to do this with a Basic Stamp

Here is why we have one crane that at least 25 to 30 years old it dose not have a lower limit switch

What I want to is IF some one hold the down button on the remote for longer than what it take for the hosit hook block to go from the top limit switch to the ground then it would stop the motor until the up switch is push for so many seconds

I know that this not fool proof but it is better than nothing

kwinn
02-16-2012, 03:37 AM
For this you could use a latching relay as the memory element and to activate the relay/circuit that controls the crane motor. A latching relay remains in whatever state it is in when the power is removed. It needs power to turn it on and power to turn it off.

sam_sam_sam
02-16-2012, 07:06 AM
kwinn

Thank you for your reply

Could you post a web link to the type of latching relay that you are talking about I have never use one Thanks for all of your help

Loopy Byteloose
02-16-2012, 10:10 AM
Remembering the position of a switch when ALL power is lost and allowing it to be reinstated when power returns.........

A latching relay is likely the best solution for that. After all, what happens to the BS when power is lost, it wipes its memory.

Moskog
02-16-2012, 04:49 PM
After all, what happens to the BS when power is lost, it wipes its memory.

Yes, but it's last action was to write it's state to the time-chip's memory.

tonyp12
02-16-2012, 05:46 PM
As long the RTC ic have battery backup you can program the state in it's 31byte ram.

But they make 2 and 4pin remember-state ICs
3V 1.27mm SOIC http://www.mouser.com/ProductDetail/Ramtron/FM1106-GA/?qs=sGAEpiMZZMtsPi73Z94q0CkDToGtzUA7WawxTTmnW5I%3d

5V small 0.65mm SOT http://www.mouser.com/ProductDetail/Ramtron/FM1105/?qs=sGAEpiMZZMtsPi73Z94q0KcM%252bBSzTxqK2Vl%252bDr W9N6I%3d
better have good sight to put it on a smt-board, other sites may have soic version of this 5v

Loopy Byteloose
02-17-2012, 06:55 AM
Yes indeed, you can program state data into RTC memory buffers - BUT when the BS is reset in a power down, you still will have a momentary reset of all I/O pins and that may NOT be acceptable.

There are workarounds for this problem, but none are quite as good as a latching relay.

kwinn
02-18-2012, 11:59 PM
Lots of latching relays available. Here are a couple that Digi-Key carries:

http://parts.digikey.com/1/parts/374592-plc-relay-spdt-24vdc-2966171.html
http://parts.digikey.com/1/parts/374593-plc-relay-spdt-24vac-dc-2966184.html

In typical safety circuits these are in series with the coil of the relay that provides power to the motors or equipment so the exact relay you use will depend on the rating of that coil. Normally such equipment would have a manual reset button but a microcontroller could also do that. Since the micro does not need to remember the state of the switch no RTC chip is needed. A timing loop running on the micro when the up button is pressed is all that is required. In fact a 555 timer could probably do that.

OOPS - Scratch the 555 timer. Forgot about timing how long the down button was pressed.

BTW the down time count should probably be cumulative so it tracks the total amount of down travel even if the button is released from time to time.

sam_sam_sam
02-19-2012, 01:47 AM
This is a dual coil latching relay

Here is what I am looking forhttp://media.digikey.com/photos/Panasonic Elect Works Photos/SP2-L2- SERIES_sml.jpg (http://media.digikey.com/photos/Panasonic Elect Works Photos/SP2-L2- SERIES.jpg)http://search.digikey.com/us/en/products/SP2-L2-DC24V/255-2839-ND/649193

After it was all said and done my boss decide not to go with a microcontroller and do it with a relay instead
I want to thank all of you that replied to this post

I will to build a 24 volt power supply to to use this relay

When I am on the other laptop computer I will post the code that wrote to do this there is a 100 th of a second where it powers up that pin but that may have work any way

sam_sam_sam
02-19-2012, 02:10 AM
. Since the micro does not need to remember the state of the switch no RTC chip is need.

In a way it dose because if you base your code on what state of the input is before the power is lost and when it is restored you might be able to restart the hoist motor again

The way I wrote the code was when you turn on the power and the input was low the contractor would be ON if the input went high then it would turn OFF and stay OFF until a second input went high to reset the first input but you would a second switch to disabled the first input

But i might be making this harder than it need to be

I do want to thank you for all of your help in this matter

kwinn
02-19-2012, 04:28 AM
If the power supply is only powering the relay it can be pretty simple. The relay coils only draw 12.5mA so a small 24V transformer a bridge rectifier, and capacitor are really all you need.

As for making this harder than it has to be, yes you probably were. A safety circuit needs to be reliable so the simpler you make it the better. You do not want hoists starting up by themselves when the power comes back on.

BTW how are you going to do the timing of the down movement without a micro?

sam_sam_sam
02-20-2012, 09:34 PM
[QUOTE=kwinn;1075667 BTW how are you going to do the timing of the down movement without a micro?[/QUOTE]

I was going add this on one of the hoist if I was using a micro controller