Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

function of "signal" in VHDL code.

Status
Not open for further replies.

soloktanjung

Full Member level 6
Joined
Nov 20, 2006
Messages
364
Helped
51
Reputation
100
Reaction score
43
Trophy points
1,308
Location
nowhere
Activity points
3,194
guys,

can anyone explain to me the function of the signal count_motor in this code. is it equivalent to the state (state machine)? this code i got from a book. i need to understand this code because it is part of my design project.


LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_ARITH.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;

ENTITY MOTOR_CONTROL IS
PORT ( clk_1khz : IN STD_LOGIC;
lmotor_dir, rmotor_dir : IN STD_LOGIC;
lmotor_speed, rmotor_speed : IN STD_LOGIC;
lmotor, rmotor : OUT STD_LOGIC):
END MOTOR_CONTROL;

ARCHITECTURE BEHAVIOR OF MOTOR_CONTROL IS
SIGNAL count_motor : STD_LOGIC_VECTOR (4 DOWNTO 0);
BEGIN
PROCESS
BEGIN
WAIT UNTIL clk_1khz’EVENT AND clk_1khz = ‘1’;

IF count_motor /=19 THEN
count_motor <= count_motor+1;
ELSE
Count_motor=”00000”;
END IF;

IF count_motor=17 THEN
--don’t generate any pulse
IF lmotor_speed = ‘0’ THEN
lmotor<=’0’;
ELSE
lmotor<=’1’;
END IF;

IF rmotor_speed = ‘0’ THEN
rmotor<=’0’;
ELSE
rmotor<=’1’;
END IF;

ELSEIF count_motor=18 THEN
IF lmotor_speed=’1’ THEN
CASE lmotor_dir IS
--FORWARD
WHEN ‘0’=>
lmotor<=’1’;
--reverse
WHEN ‘1’=>
lmotor<=’0’;
WHEN OTHERS=> NULL;
END CASE;
ELSE
Lmotor<=’0’;
END IF;

IF rmotor_speed=’1’ THEN
CASE rmotor_dir IS
--FORWARD
WHEN ‘0’=>
rmotor<=’0’;
--reverse
WHEN ‘1’=>
rmotor<=’1’;
WHEN OTHERS=> NULL;
END CASE;
ELSE
Lmotor<=’0’;
END IF;

ELSE
Lmotor<=’0’;
Rmotor<=’0’;
END IF;

END PROCESS;
END BEHAVIOR;


thanks in advance.

regards,
hairo
 

Hello!
Signal count_motor from your code is a counter.
 

The signal count_motor is a counter which is used to control the direction of the Lmotor and Rmotor.

When it reaches 17, the inputs "lmotor_speed" and "rmotor_speed" are checked; if these signals are 0 then the motors are allowed to run in their initial direction (reverse), else their direction is changed.

When it reaches 18, the inputs "lmotor_speed" and "rmotor_speed" are checked again; if these signals are 1 then the corresponding direction inputs are checked and the direction of the two motors are controlled accordingly.

When it reaches to 19, it is reset to 0, and the whole cycle starts again.
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top