Car Sensor A car sensor circuit is modeled as a “toggle” switch. A toggle switch
ID: 3818869 • Letter: C
Question
Car Sensor A car sensor circuit is modeled as a “toggle” switch. A toggle switch is a simple on-off switch that is either in an on or off state. The toggle switch remains in its on or off state until the operator “toggles” the switch (i.e. flips the switch to change its state). A toggle switch that is on indicates the arrival of one or more cars at the intersection. A toggle switch that is off indicates no cars at the intersection. Logisim does not have a toggle switch device. Logisim does have a “push-button” device. A push-button is a “biased-based” switch. A push-button is active as long as the operator is pressing the button. To create a car sensor, you must design a toggle switch using a T flip-flop and a push-button. Each time you press the push-button, the output of the circuit toggles between the on and off states. Traffic Lights Notation: NS = North-South, EW = East-West The traffic lights are modeled as two sets of red, yellow, and green LEDs. One traffic light for the NS traffic; and one traffic light for the EW traffic. Logisim has the capability to select the color of the LED lightbulbs. Traffic Light Controller The figure below shows the traffic light system. The sensors detect cars traveling in the NS direction. There are two car sensors in the system – a sensor to detect a northbound car arriving at the intersection, and a sensor to detect a southbound car arriving at the intersection. The figure below also shows a pair of traffic signals for each direction. For this assignment implement one traffic light for the NS-direction and one traffic light for the EW-direction because each pair of NS or EW traffic lights work in the same manner. = sensor Traffic Light System 3 The traffic lights work as follows: i. The traffic light sequence is a repeating sequence of green for one or more clock cycles, yellow for two clock cycles, and red for one or more clock cycles. ii. The NS-light is initially red and the EW-light is initially green. iii. The NS-light remains red until a car traveling north-south or south-north direction is detected at the intersection (i.e. either sensor circuit outputs a logic 1). iv. When a NS-car (or SN-car) is detected, the traffic lights cycle until the NS-traffic light is green and EW-traffic light is red. The system remains in this state until no more NS-cars (or SN-cars) are detected at the intersection. The lights then cycle back to the initial state of step (ii). v. Once the traffic signal cycle is started (i.e. changing from green to yellow to red etc.) it cannot be stopped, that is, the cycle must complete. vi. To prevent accidents, the EW and NS traffic signals cannot change state at the same time. The traffic light controller will have 2 inputs for the sensors (with some savvy design you can reduce this to 1 input), and 6 outputs (red, yellow, and green lights for the NS and EW directions).
OO sensor Traffic Light SystemExplanation / Answer
package android.support.car.hardware;
import android.Manifest;
import android.os.Looper;
import android.support.annotation.RequiresPermission;
import android.support.car.Car;
import android.support.car.CarManagerBase;
import android.support.car.CarNotConnectedException;
public abstract class CarSensorManager implements CarManagerBase {
public static final int SENSOR_TYPE_COMPASS = 1;
public static final int SENSOR_TYPE_CAR_SPEED = 2;
public static final int SENSOR_TYPE_RPM = 3;
public static final int SENSOR_TYPE_ODOMETER = 4;
public static final int SENSOR_TYPE_FUEL_LEVEL = 5;
public static final int SENSOR_TYPE_PARKING_BRAKE = 6;
public static final int SENSOR_TYPE_GEAR = 7;
public static final int SENSOR_TYPE_RESERVED8 = 8;
public static final int SENSOR_TYPE_NIGHT = 9;
public static final int SENSOR_TYPE_LOCATION = 10;
public static final int SENSOR_TYPE_DRIVING_STATUS = 11;
public static final int SENSOR_TYPE_ENVIRONMENT = 12;
public static final int SENSOR_TYPE_RESERVED13 = 13;
public static final int SENSOR_TYPE_ACCELEROMETER = 14;
public static final int SENSOR_TYPE_RESERVED15 = 15;
public static final int SENSOR_TYPE_RESERVED16 = 16;
public static final int SENSOR_TYPE_GPS_SATELLITE = 17;
public static final int SENSOR_TYPE_GYROSCOPE = 18;
public static final int SENSOR_TYPE_RESERVED19 = 19;
public static final int SENSOR_TYPE_RESERVED20 = 20;
public static final int SENSOR_TYPE_RESERVED21 = 21;
private static final int SENSOR_TYPE_MAX = SENSOR_TYPE_RESERVED21;
public static final int SENSOR_TYPE_VENDOR_EXTENSION_START = 0x60000000;
public static final int SENSOR_TYPE_VENDOR_EXTENSION_END = 0x6fffffff;
public static final int SENSOR_RATE_NORMAL = 3;
public static final int SENSOR_RATE_UI = 2;
public static final int SENSOR_RATE_FAST = 1;
public static final int SENSOR_RATE_FASTEST = 0;
public interface CarSensorEventListener {
void onSensorChanged(final CarSensorEvent event);
}
public abstract int[] getSupportedSensors() throws CarNotConnectedException;
public abstract boolean isSensorSupported(int sensorType) throws CarNotConnectedException;
public static boolean isSensorSupported(int[] sensorList, int sensorType) {
for (int sensorSupported: sensorList) {
if (sensorType == sensorSupported) {
return true;
}
}
return false;
}
@RequiresPermission(anyOf={Manifest.permission.ACCESS_FINE_LOCATION, Car.PERMISSION_SPEED,
Car.PERMISSION_MILEAGE, Car.PERMISSION_FUEL}, conditional=true)
public abstract boolean registerListener(CarSensorEventListener listener, int sensorType,
int rate) throws CarNotConnectedException, IllegalArgumentException;
public abstract void unregisterListener(CarSensorEventListener listener)
throws CarNotConnectedException;
public abstract void unregisterListener(CarSensorEventListener listener, int sensorType)
throws CarNotConnectedException;
public abstract CarSensorEvent getLatestSensorEvent(int type) throws CarNotConnectedException;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.