{"id":190147,"date":"2025-02-11T07:37:28","date_gmt":"2025-02-11T07:37:28","guid":{"rendered":"https:\/\/learnexams.com\/blog\/?p=190147"},"modified":"2025-02-11T07:37:30","modified_gmt":"2025-02-11T07:37:30","slug":"modify-the-traffic-light-controller-fsm","status":"publish","type":"post","link":"https:\/\/www.learnexams.com\/blog\/2025\/02\/11\/modify-the-traffic-light-controller-fsm\/","title":{"rendered":"Modify the traffic light controller FSM"},"content":{"rendered":"\n<p>Finite State Machines. Modify the traffic light controller FSM of Table 14.4 so that it takes an additional input, carns, that indicates when there is a car waiting in the north-south direction. Change the logic so that once the light changes to east-west, it stays with east-west green until a car is detected waiting in the north-south direction. Show a state table and state diagram for your new FSM.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/learnexams.com\/blog\/wp-content\/uploads\/2025\/02\/image-311.png\" alt=\"\" class=\"wp-image-190148\"\/><\/figure>\n\n\n\n<p><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-ast-global-color-6-color\"><strong>The Correct Answer and Explanation is :<\/strong><\/mark><\/p>\n\n\n\n<p>To modify the traffic light controller FSM as described in your request, we need to consider how the new input, <code>carns<\/code>, (indicating if a car is waiting in the north-south direction) will affect the system. The original FSM alternates between east-west and north-south traffic lights, but now, we want to keep the east-west direction green until a car is detected waiting in the north-south direction.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Modified FSM Behavior<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>State Definitions<\/strong>:<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>NS Green (S0)<\/strong>: North-South direction has green, East-West direction has red.<\/li>\n\n\n\n<li><strong>EW Green (S1)<\/strong>: East-West direction has green, North-South direction has red.<\/li>\n\n\n\n<li><strong>EW Red (S2)<\/strong>: East-West direction is red, but the FSM will stay here unless a car is detected waiting in the north-south direction.<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Inputs<\/strong>:<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>carns<\/code>: This input tells the FSM whether a car is waiting in the north-south direction. It will be a binary input, where <code>1<\/code> indicates that a car is waiting, and <code>0<\/code> means no car is waiting.<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Transition Logic<\/strong>:<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>In state <code>S1<\/code> (east-west green), if <code>carns = 1<\/code> (there\u2019s a car waiting in the north-south direction), the FSM will switch to state <code>S0<\/code> (north-south green).<\/li>\n\n\n\n<li>Once the FSM is in state <code>S0<\/code>, it will stay there until <code>carns<\/code> is <code>0<\/code>, indicating there are no cars waiting in the north-south direction, at which point it can return to state <code>S1<\/code> (east-west green).<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">State Table<\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Current State<\/th><th>carns<\/th><th>Next State<\/th><\/tr><\/thead><tbody><tr><td>S0 (NS Green)<\/td><td>0<\/td><td>S1 (EW Green)<\/td><\/tr><tr><td>S0 (NS Green)<\/td><td>1<\/td><td>S0 (NS Green)<\/td><\/tr><tr><td>S1 (EW Green)<\/td><td>0<\/td><td>S1 (EW Green)<\/td><\/tr><tr><td>S1 (EW Green)<\/td><td>1<\/td><td>S0 (NS Green)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">State Diagram<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;S0] --(carns=0)--&gt; &#91;S1] --(carns=1)--&gt; &#91;S0]\n ^                           |\n |---------------------------|<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Explanation:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>State S0 (NS Green)<\/strong>: This is the state where the north-south traffic is green. The FSM stays in this state if a car is detected in the north-south direction (i.e., <code>carns = 1<\/code>). Once no car is waiting, it transitions to <code>S1<\/code>.<\/li>\n\n\n\n<li><strong>State S1 (EW Green)<\/strong>: In this state, east-west traffic is green. The FSM remains in this state unless a car is detected waiting in the north-south direction (<code>carns = 1<\/code>), which triggers a transition back to state <code>S0<\/code>.<\/li>\n<\/ul>\n\n\n\n<p>This modification ensures that once the light turns green for east-west traffic, it stays green until there is a car waiting for north-south traffic. This is more efficient because it avoids switching between states unnecessarily and gives priority to the direction with the car waiting.<\/p>\n\n\n\n<p>The behavior is implemented by tracking the <code>carns<\/code> input, making the system adaptive to the presence of waiting vehicles in the north-south direction.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Finite State Machines. Modify the traffic light controller FSM of Table 14.4 so that it takes an additional input, carns, that indicates when there is a car waiting in the north-south direction. Change the logic so that once the light changes to east-west, it stays with east-west green until a car is detected waiting in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[25],"tags":[],"class_list":["post-190147","post","type-post","status-publish","format-standard","hentry","category-exams-certification"],"_links":{"self":[{"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/posts\/190147","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/comments?post=190147"}],"version-history":[{"count":0,"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/posts\/190147\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/media?parent=190147"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/categories?post=190147"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/tags?post=190147"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}