![]() |
![]() |
![]() |
|
|
|||||||
| Electronic Projects Design/Ideas/Reviews Are you building an electronic project or want to? Maybe you need some assistance? Come and submit your electronic questions here and let our experienced members find a solution. |
|
|
Thread Tools | Display Modes |
|
|
(permalink) |
|
Any Thoughts on how to do this?
I need to find a way to make an electronic interlock? system that does the following: Sound an alarm IF PORTS B1 AND B2 are HIGH AND the power (ignition switch) is turned OFF, BEFORE the pushbutton (input port on chip) has been pressed, The alarm can be either an external circuit, or as simple as a port output driving a piezo sounder or even a siren generated internally in the chip and fed to a speaker. IF both PORTS B1 and B2 are low then the check does not need to be made . IF it helps the input of those ports, is the output of 2 X DS1620 in thermostat mode only supplying a high signal when the required temperature has been reached. and the check ONLY has to be made if these are still high when power is removed. I had thought about maybe using some sort of capacitor system to keep the pic alive for a few seconds which would activate if the main power was removed. but somehow the PIC has to know if the button has been removed, and ONLY if the button has NOT been pressed then sound the alarm A Possible way of doing this may be to put a delay internally in the PIC program, first check for port B inputs and if they are high then carry on with the rest of the program which would be simple enough to do, but there is no way I can see for the PIC to know if the pushbutton had previously been pressed before it was powered down last. IF it helps, the circuitry has 2 power rails, one from the ignition switch in the car (+12V) and one 5Vfrom a 7805 chip BUT I'd like no external switches other than the one pushbutton already in the system Im stuck! other than using relays and a 2nd power supply (main car battery) which means another on/off switch and is going to look pretty messy and rely on someone remembering to turn the switch on or the circuit will never get turned on. and I NEED it to activate every time the ignition switch is turned on. Last edited by karenhornby; 4th March 2008 at 03:47 PM. |
|
|
|
|
|
|
(permalink) |
|
Supercap and sleep mode will run a PIC for awhile sans power. You should really take the time to understand the PIC I/O before you proceed. Depending on the PIC there are plenty of internal devices that would make your design work better.
PORTB on change (RB4-RB7) can wake a PIC up from sleep, so can many other things. Using a more modern version of the 16F877A would also offer some advantages such as an internal oscillator 16F887 |
|
|
|
|
|
|
(permalink) |
|
I did think of using the sleep mode in the PIC but I still cant see how this can work, If i turn the ignition off then the pic loses power and when the circuit is turned on again the program inside the chip starts as normal.
I had already thought about the possibility of keeping the PIC alive in sleep mode but the problem is how do I tell the PIC power has been removed? but still leave enough power in the circuit for the pic to run through some routines and sound that alarm for a few seconds? I had already thought about using a supercap(not sure if these are available here yet or not or how to use them) But how could I tell the PIC that power has been removed, keeping enough "power" in the circuitry to power the PIC and piezo sounder Thanks for the input Bill, I always take what you say with interest, but as you know, a week ago i knew nothing about PIC programming and at the moment there are probably hundreds of commands I dont know about yet which is why I've stuck with one kind of PIC, at the moment I've got it working doing several things on certain ports and driving external relays and solenoids and considering I've learnt that all in a week I'm pretty happy at the moment, and IF need be I'll just use a master on/off switch, OR maybe I'll use sleep mode and use the same pushbutton to wake the circuit again? I'd rather not have to do that as it means if the button ISN'T pressed then the circuit wont work. Put simply I need some way to keep the circuit alive for a few seconds once power has been removed Last edited by karenhornby; 4th March 2008 at 04:23 PM. |
|
|
|
|
|
|
(permalink) |
|
Supercaps are very small but very large caps, often 1F.
A properly designed circuit and a sleeping Nanowatt (modern) PIC will draw almost nothing. |
|
|
|
|
|
|
(permalink) |
|
WOULD this work?
What if I powered the pic from the 5V rail as normal but had some kind of capacitor on the rail storing a charge, but also have a HIGH input to the PIC from this rail say via a 1K resistor, then have this code in the PIC? Code:
DEVICE = 16F877 ' We'll use a PIC16F877 PICmicro
XTAL = 4 ' With a 4MHz crystal
' Define LCD pins
Define LCD_DREG PORTD
Define LCD_DBIT 4
Define LCD_RSREG PORTE
Define LCD_RSBIT 0
Define LCD_EREG PORTE
Define LCD_EBIT 1
' Alias pins
RST var PORTC.0 ' Reset pin
DQ var PORTC.1 ' Data pin
CLK var PORTC.3 ' Clock pin
' Allocate variables
temp var word ' Storage for temperature
Low RST ' Reset the device
ADCON1 = 7 ' Set PORTA and PORTE to digital
Low PORTE.2 ' LCD R/W line low (W)
Pause 100 ' Wait for LCD to start
Lcdout $fe,1, "DIESEL"
Lcdout $fe,$C0, "Temp in degrees C" ' Display sign-on message
input PORTB.1 'Input from DS1620 in Thermostat mode (only HIGH or LOW)
output PORTB.2 'OUTPUT to Solenoid 1 FUEL SUPPLY
input PORTB.4 ' Input from DS1620 in Thermostat mode (only HIGH or LOW)
output PORTB.5 'OUTPUT to Solenoid 2 FUEL RETURN
input PORTB.6 'INPUT from Pushbutton Switch
output PORTC.2 ' Output to Transistor to control LCD Power on
input PORTD.0 'input to check MAIN power to circuit still alive
output PORTD.1 'Output to Piezo sounder
MAIN:
high PORTB.0 'toggle the clock pin.
Pause 10 'the conversion will be complete
Low PORTB.0 'before the inputs are read further down.
' Temploop to read the temperature and display on LCD
TempLoop:
RST = 1 ' Enable device
Shiftout DQ, CLK, LSBFIRST, [$ee] ' Start conversion
RST = 0
Pause 1000 ' Wait 1 second for conversion to complete
RST = 1
Shiftout DQ, CLK, LSBFIRST, [$aa] ' Send read command
Shiftin DQ, CLK, LSBPRE, [temp\9] ' Read 9 bit temperature
RST = 0
' Display the decimal temperature
Lcdout $fe,$C0, dec (temp >> 1), ".", dec (temp.0 * 5), " degrees C"
IF PORTB.1 = 1 AND PORTB.4 = 1 THEN
IF PORTB.6 = 0 AND PORTD.1 = 0 THEN
LOW PORTB.2 'switch fuel to diesel
HIGH PORTB.5 'fuel return goes to diesel tank
HIGH PORTD.2 'SOUND ALARM SIGNAL
Lcdout $fe,2, "PRESS THE BUTTON"
else
IF PORTB.6 = 0 AND PORTD.1 = 1 THEN
HIGH PORTB.2 'fuel switches to veg oil
HIGH PORTB.5 'fuel return goes to veg oil tank
Lcdout $fe,2, "Veg-Oil"
else
HIGH PORTB.2 'switch fuel to Diesel
LOW PORTB.5 'keep fueel return to OIL tank
Lcdout $fe,2, "FLUSHING" ;clears Injection pump of Veg-Oil
Pause 10000 'PAUSES for TEN SECONDS then (HOPEFULLY) SETS OUTPUTS B2 and B5 LOW
Lcdout $fe,2, "Diesel"
LOW PORTB.5 'switch car to Diesel Fuel
LOW PORTB.2 'switch fuel return to Diesel Fuel
While PORTB.6=0 'wait for button to be pressed again
WEND
endif 'this is short for while end
endif
endif
Goto MAIN ' Do it forever
Will the code in RED work to check if the main power has been removed and sound the alarm if the button on PORTB.6 has NOT been pressed? Last edited by karenhornby; 4th March 2008 at 10:33 PM. |
|
|
|
|
|
|
(permalink) | |
|
Quote:
Places such as Rapid electronics or Farnell would have them but you would have to buy some other stuff at the same time to meet their minimum order requirements. http://www.rapidonline.com/Electroni.../Memory-Backup I don't know if they would be any good for powering your sounder, I think they are just intended for very low current use. |
||
|
|
|
|
|
(permalink) |
|
Could I use something like this? http://www.maplin.co.uk/module.aspx?...y=4m3#overview
along with a diode to block the battery being charged by the circuit, as all it needs to do is power the PIC for a few seconds and play a warning sound either through a piezo sounder or probably better a transistor/speaker and the battery would be used rarely its only a backup Also does anyone know how to implement the SOUND command to play a warning beep, or a siren or even more ambitious the star trek warning sound or anything similar again using picbasic or picbasic pro. Last edited by karenhornby; 4th March 2008 at 07:22 PM. |
|
|
|
|
|
|
(permalink) |
|
A 1F supercap is common and not expensive. You'll need diodes like the 1N5817 to keep it from discharging back into the supply.
|
|
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Latest |
| Hello, I'm new to Electronic circuits, how do I get info. on electronic tach for m.c. | pwotoole | General Electronics Chat | 17 | 16th May 2007 05:33 AM |
| A basic electronic interlock circuit | CTR | General Electronics Chat | 13 | 9th April 2006 07:26 PM |
| Inviting Entries to Electronic Design Contest | wasuwathp | General Electronics Chat | 0 | 23rd October 2004 03:01 AM |
| frequency-voltage don't work with electronic ignition. | Screech | General Electronics Chat | 7 | 16th March 2004 12:28 AM |
| Safety interlock module | wilfredmike | Electronic Projects Design/Ideas/Reviews | 6 | 2nd November 2003 08:41 PM |