Title: An alarm system for a car
1An alarm system for a car
Digital Design EECS 5130/7130
- Group member
- Shensheng Tang
- Zhaoxuan Wu
2Alarm system for a car
- Our system informs the public by blinking the
car's lights and siren or horn when a violation
occurs. - It can protect the automobile from getting stolen
by sending a signal that will cutoff the starter
switch. This is implemented by an AND gate in our
project. - The two inputs of an AND gate are the starter
switch output and the alarm system output. - The output of the AND gate is connected to car
starter.
Starter Switch Output
Start Car
Alarm Starter Output
AND2
3Alarm system for a car
- ASM (Algorithmic State Machine) Chart
- High level view of the alarm system
4Alarm system for a car
- ASM Chart The arm process flow chart
unlock ltL lock ltH starter ltL siren
ltH pklight ltH cntrst ltL
0001 (ARM)
unlock ltL lock ltL starter ltL siren
ltL pklight ltL cntrst ltL
0010
doordt ltH OR trunkdt ltH OR hooddt ltH
OR motiondtltH
No
yes
alarming
5Alarm system for a car
unlock ltL lock ltL starter ltL siren
ltL pklight ltL cntrst ltH
0011 (alarming)
- ASM Chart
- The alarming
- process flow
- chart
unlock ltL lock ltL starter ltL siren
ltH pklight ltH cntrst ltL
0100
unlock ltL lock ltL starter ltL siren
ltL pklight ltL cntrst ltL
0101
No
cnt6
Yes
ARM
6Alarm system for a car
unlock ltH lock ltL starter ltH siren
ltL pklight ltL cntrst ltH
0110 (disarm)
- ASM Chart
- The disarm
- process flow
- chart
unlock ltL lock ltL starter ltH siren
ltH pklight ltH cntrst ltL
0111
unlock ltL lock ltL starter ltH siren
ltL pklight ltL cntrst ltL
1000
No
cnt2
Yes
Check for Automation
7Alarm system for a car
unlock ltL lock ltL starter ltH siren
ltL pklight ltL cntrst ltL
1001 (automation)
- ASM Chart
- The automation
- checking flow
- chart
No
auto1
Yes
unlock ltL lock ltL starter ltH siren
ltL pklight ltL cntrst ltH
1010
unlock ltL lock ltL starter ltH siren
ltL pklight ltL cntrst ltL
1011
No
keyin1
Yes
8Alarm system for a car
- Counter
- Implemented by behavior VHDL code.
- The alarm system needs a counter that will keep
track of time. - The alarm only needs to know time up to 60
seconds in this project, so a six bit counter
will be sufficient. - During simulation we use cnt 6 to express 60
seconds. When its maximum count 6 is reached it
will start counting again. When reset is high it
will be set to zero. -
cntrst countout Counter clk
9VHDL code for Counter
- ENTITY counter IS
- PORT ( clk, reset IN bit
- countout buffer BIT_VECTOR(5 downto 0))
- END counter
- ARCHITECTURE behavior OF counter IS
- -- Function vec2int (converts a bit vector to an
integer) - function vec2int(vec1 bit_vector) return integer
is - variable retval integer0
- alias vec bit_vector(vec1'length-1 downto 0) is
vec1 - begin
- for i in vec'high downto 1 loop
- if (vec(i)'1') then
- retval(retval1)2
- else
- retvalretval2
- end if
- end loop
-
- if vec(0)'1' then
for i in retval'Reverse_Range loop if (N1 mod
2)1 then retval(i)'1'
else retval(i)'0' end
if N1N1/2 end loop return retval end
int2vec SIGNAL enable bit SIGNAL count
bit_vector (5 downto 0) BEGIN PROCESS (reset,
clk, enable, count) BEGIN IF (reset
'1') THEN enable lt '0' count lt
"000000" ELSIF (clk'event AND (clk '1'))
THEN enable lt NOT enable IF
(enable '1') THEN count lt
int2vec((vec2int(count) 1),6) ELSE
count lt count END IF END
IF END PROCESS countout lt count END
behavior
10Alarm system for a car
- Synchronizer
- Implemented by behavior VHDL code.
- Synchronizer is a synchronizing receiver.
- The main function is to synchronize the inputs
that will arm and disarm the system. - inputs are arm and disarm. outputs are rcv and
arm_disarm.
arm rcv
Synchronizer disarm
arm_disarm clk
11Alarm system for a car
12VHDL code for Synchronizer
- ENTITY synchronizer IS
- PORT ( clk, arm, disarm IN BIT
- rcv, arm_disarm OUT BIT)
- END synchronizer
- ARCHITECTURE behavior OF synchronizer IS
- SIGNAL clk_rcv BIT
- SIGNAL clk_arm_disarm BIT
- SIGNAL clk_arm_disarm_e BIT
- BEGIN
- PROCESS (clk, arm, disarm)
- BEGIN
- IF (clk'event AND (clk '1')) THEN
- clk_rcv lt (arm OR disarm)
- clk_arm_disarm_e lt disarm
- clk_arm_disarm lt clk_arm_disarm_e
- END IF
- END PROCESS
- rcv lt clk_rcv
- arm_disarm lt clk_arm_disarm
13Alarm system for a car
- Controller
- Implemented by behavior VHDL code.
- The controller is the most complex component. It
has 10 inputs, 6 outputs. - rcv, arm_disarm come from the Synchronizer
output Countout comes from Counter output. - Other inputs come from sensors
- Cntrst go to Counter
rcv
unlock arm_disarm doordt
lock
Controller
starter Trunkdt hooddt
siren Motiondt
prklight
clk
cntrst keyin auto countout
14VHDL code for Controller (1)
- ENTITY controller IS
- PORT (clk, rcv, arm_disarm, doordt, trunkdt,
hooddt, motiondt, keyin, - auto IN BIT
- cnt IN BIT_VECTOR(5 downto 0)
- unlock, lock, starter, siren, prklight, cntrst
OUT BIT) - END controller
- ARCHITECTURE behavior OF controller IS
- SIGNAL state BIT_VECTOR(3 downto 0)
- BEGIN
- PROCESS(clk, rcv)
- BEGIN
- IF (clk'event and (clk '1')) THEN
- IF rcv '1' THEN -- input received
- state lt "0000" -- go check
the input - unlock lt '0'
- lock lt '0'
- starter lt '0'
- siren lt '0'
- prklight lt '0'
starter lt '0' siren lt '0'
prklight lt '0' cntrst lt '0'
WHEN "0010" gt IF ( doordt '1' OR
trunkdt '1' OR hooddt '1' OR
motiondt '1 ) and keyin '0' THEN state
lt "0011" unlock lt '0'
lock lt '0' starter lt '0'
siren lt '0' prklight lt '0'
cntrst lt '1' ELSE state lt
"0010" unlock lt '0'
lock lt '0' starter lt '0'
siren lt '0' prklight lt '0'
cntrst lt '0' END IF WHEN "0011"
gt state lt "0100"
if (
keyin '0') then unlock lt '0'
lock lt '0' starter lt '0'
siren lt '1' prklight lt '1'
cntrst lt '0'
else state lt"0100"
end if WHEN "0100" gt
state lt "0101" unlock lt '0'
lock lt '0' starter lt '0'
siren lt '0' prklight lt '0'
cntrst lt '0'
15VHDL code for Controller (2)
- WHEN "0101" gt
- IF cnt B000110" THEN -- cnt reached 6
- state lt "0001" -- stop alarming go to
arm - unlock lt '0'
- lock lt '1'
- starter lt '0'
- siren lt '1'
- prklight lt '1'
- cntrst lt 0'
- ELSE
- state lt "0100" -- keep alarming
- unlock lt '0'
- lock lt '0'
- starter lt '0'
- siren lt
'1' - prklight lt '1'
- cntrst lt '0'
- END IF
- WHEN "0110" gt
ELSE
state lt "0111" -- flash again
unlock lt '0' lock lt '0'
starter lt '1' siren lt '1'
prklight lt '1' cntrst lt '0'
END IF WHEN "1001" gt IF auto '1'
THEN state lt "1010" --
continue unlock lt '0'
lock lt '0' starter lt '1'
siren lt '0' prklight lt '0'
cntrst lt '1' ELSE state lt "1001"
unlock lt '0' lock lt '0'
starter lt '1' siren lt '0'
prklight lt '0' cntrst lt
'0' END IF WHEN "1010" gt state lt
"1011" unlock lt '0' lock lt
'0' starter lt '1' siren lt
'0' prklight lt '0' cntrst lt
'0'
16VHDL code for Controller (3)
- WHEN "1011" gt
- IF cnt B"000110" THEN -- has cnt reached 60
- state lt "0001" -- go to arm
- unlock lt '0'
- lock lt '1'
- starter lt '0'
- siren lt '1'
- prklight lt '1'
- cntrst lt '1'
- ELSE
- IF keyin '1' THEN -- is the key in switch
- state lt
"1001" -- go check for automation and reset
cnt - unlock lt '0'
- lock lt '0'
- starter lt '1'
- siren lt '0'
- prklight lt '0'
- cntrst lt '0'
- ELSE
17Alarm system for a car
6
cntrst countout Counter clk
- Entire System
- Implemented by structure VHDL code.
- Three components Counter,
- Synchronizer, Controller
arm rcv disarm Synchronizer clk
arm_disarm
rcv
unlock arm_disarm
lock doordt
starter
trunkdt Controller
siren hooddt motiondt
prklight clk keyin auto
cntrst
countout
6
18VHDL code for Entire System
- ENTITY caralarmsys IS
- PORT (clk, arm, disarm, doordt, trunkdt,
hooddt, motiondt, keyin, - auto IN BIT
- unlock, lock, starter, siren, prklight OUT
BIT - countout buffer BIT_VECTOR (5 downto 0))
- END caralarmsys
- ARCHITECTURE structure OF caralarmsys IS
- COMPONENT synchronizer
- PORT ( clk, arm, disarm IN BIT
- rcv, arm_disarm OUT BIT)
- END COMPONENT
- COMPONENT counter
- PORT ( clk, reset IN BIT
- countout buffer BIT_VECTOR (5 downto 0) )
- END COMPONENT
- COMPONENT controller
- PORT (clk, rcv, arm_disarm, doordt, trunkdt,
hooddt, motiondt, keyin, - auto IN BIT
- cnt IN BIT_VECTOR(5 downto 0)
19Alarm system for a car
- Simulation Results (1.a)
- This result shows that the system arms correctly.
The doors are locked and the siren is alarming
and parking lights is flashing once. - When the door is detected to be open, the system
will also enter the alarming state ( parking
light and siren will enter high state).
Result corresponding to the car door detector
20Alarm system for a car
- Simulation Results (1.b)
- This result shows that the system arms correctly.
The doors are locked and the siren and parking
lights are flashed once. - When the door is detected to be open, and the
key is detected to be inserted (keyin 1), the
parking light and siren will not enter high
state.
Result corresponding to the car door and key
detector
21Alarm system for a car
- Simulation Results (2.a)
- This result shows that the system arms correctly.
The doors are locked and the siren and parking
lights are flashed once. - When the trunk is detected to be open, the
parking light and siren will enter high state.
Result corresponding to the car trunk detector
22Alarm system for a car
- Simulation Results (2.b)
- This result shows that the system arms correctly.
The doors are locked and the siren and parking
lights are flashed once. - When the trunk is detected to be open, and the
key is detected to be inserted (keyin 1), the
parking light and siren will not enter high
state.
Result corresponding to the car trunk and key
detector
23Alarm system for a car
- Simulation Results (3.a)
- This result shows that the system arms correctly.
The doors are locked and the siren and parking
lights are flashed once. - When the hood is detected to be open, the parking
light and siren will enter high state.
Result corresponding to the car hood detector
24Alarm system for a car
- Simulation Results (3.b)
- This result shows that the system arms correctly.
The doors are locked and the siren and parking
lights are flashed once. - When the hood is detected to be open, and the
key is detected to be inserted (keyin 1), the
parking light and siren will not enter high
state.
Result corresponding to the car hood and key
detector
25Alarm system for a car
- Simulation Results (4.a)
- This result shows that the system arms correctly.
The doors are locked and the siren and parking
lights are flashed once. - when motion signal is detected to be high, ( such
as the car is moved without permission, i.e.,
without key in ), then flashing light and
alarming siren ( parking light and siren will
enter high state).
Result corresponding to the car motion detector
26Alarm system for a car
- Simulation Results (4.b)
- This result shows that the system arms correctly.
The doors are locked and the siren and parking
lights are flashed once. - when motion signal is detected to be high, and
the key is detected to be inserted (keyin 1),
the parking light and siren will not enter
high state.
Result corresponding to the car motion and key
detector
27Alarm system for a car
- Simulation Results (5)
- This result shows that when the door is opened,
light is flashing and siren is alarming once.
Then the system will stop flashing and alarming
after inserting the key and setting auto high.
Result corresponding to the key-in state
28Alarm system for a car
- Simulation Results (6)
- This result shows the disarm state ( auto is high
). After one clock cycle, the door is unlocked
and the car is starting. Then the system flash
light and alarm siren twice.
Result in disarm state
29Alarm system for a car
- Simulation Results (7)
- This result shows that when the car goes to the
destination. After one clock cycle, the door is
locked.
Result when a car on destination
30Alarm system for a car
- Conclusions
- The project shows how useful VHDL in designing
digital systems. A very complex system can be
reduced dramatically by the use of VHDL. - In designing the alarm system we encountered a
few problems. One of the problems was the
synchronization of the asynchronous arm and
disarm inputs. For example, the lock and unlock
outputs will appear undesirably. We solved this
problem by creating a synchronizer that would
latch these inputs and synchronize them. - Future studies of this project include the
implementation of the design at a VLSI level.
31Alarm system for a car