S
server
Guest
Hello,
I\'m working on a project using a CPLD. All the functions of my code are working, but the overcurrent detection (OCD).
It\'s been long time since I used VHDL. So I\'m a bit rusted. I would apreciate it , if someone could have a look at my problem.
The function is not so complicated. When I receive the OCD signal (DOI4, active low), I need to raise a flag as an output (OCD_FLAG) set to \'1\' for say 1 sec, then to \'0\' for another 1 sec. During the period when the signal OCD_FLAG is set to \'1\', the load will be disconnected so the circuitry will not report an OCD anymore (even if it is still present) so the signal DOI(4) should be 1 (deactivated).
The idea is to cut off the load of the circuit when an overcurrent is detected, let some time for the component to lower their temperature, then reactivate the load during 1 sec and after that period check if the overcurrent is still here.
here is the signal declared earlier in the code:
-- inputs
DOI :in std_logic_vector(10 DOWNTO 1); (my inputs signals: DOI(4) is used for the overcurrent
CPLD_CLK :in std_logic;
CLOSE_OUT :in std_logic;
-- outputs
OCD_FLAG
ut std_logic;
--internal signals
RST :in std_logic;
signal OCD_CNT : std_logic_vector(20 downto 0) := \"000000000000000000000\";
here is a bit of my code:
HICCUP: process (RST,CLOSE_OUT,CPLD_CLK)
begin
elsif (rising_edge(CPLD_CLK)) then
-- deactivation
if DOI(4) = \'0\' then
if OCD_CNT(20) = \'0\' then
OCD_CNT <= OCD_CNT + 1;
end if;
else
OCD_CNT <= \'0\' & OCD_CNT(20 downto 1);
end if;
-- shotdown duration
if OCD_CNT(20) = \'1\' then
OCD_CNT <= OCD_CNT + 1;
end if;
end if;
end process;
OCD_FLAG <= OCD_CNT(20);
the problem I have is that the OCD_FLAG never change its state. always \'1\'.
I try a solution using while....loop but I\'m not sure I can use this command in a process.
If there is a simple way I\'m interested in any information that can help me to progress.
Thank you,
Pierre
I\'m working on a project using a CPLD. All the functions of my code are working, but the overcurrent detection (OCD).
It\'s been long time since I used VHDL. So I\'m a bit rusted. I would apreciate it , if someone could have a look at my problem.
The function is not so complicated. When I receive the OCD signal (DOI4, active low), I need to raise a flag as an output (OCD_FLAG) set to \'1\' for say 1 sec, then to \'0\' for another 1 sec. During the period when the signal OCD_FLAG is set to \'1\', the load will be disconnected so the circuitry will not report an OCD anymore (even if it is still present) so the signal DOI(4) should be 1 (deactivated).
The idea is to cut off the load of the circuit when an overcurrent is detected, let some time for the component to lower their temperature, then reactivate the load during 1 sec and after that period check if the overcurrent is still here.
here is the signal declared earlier in the code:
-- inputs
DOI :in std_logic_vector(10 DOWNTO 1); (my inputs signals: DOI(4) is used for the overcurrent
CPLD_CLK :in std_logic;
CLOSE_OUT :in std_logic;
-- outputs
OCD_FLAG
--internal signals
RST :in std_logic;
signal OCD_CNT : std_logic_vector(20 downto 0) := \"000000000000000000000\";
here is a bit of my code:
HICCUP: process (RST,CLOSE_OUT,CPLD_CLK)
begin
elsif (rising_edge(CPLD_CLK)) then
-- deactivation
if DOI(4) = \'0\' then
if OCD_CNT(20) = \'0\' then
OCD_CNT <= OCD_CNT + 1;
end if;
else
OCD_CNT <= \'0\' & OCD_CNT(20 downto 1);
end if;
-- shotdown duration
if OCD_CNT(20) = \'1\' then
OCD_CNT <= OCD_CNT + 1;
end if;
end if;
end process;
OCD_FLAG <= OCD_CNT(20);
the problem I have is that the OCD_FLAG never change its state. always \'1\'.
I try a solution using while....loop but I\'m not sure I can use this command in a process.
If there is a simple way I\'m interested in any information that can help me to progress.
Thank you,
Pierre