Confused about declaring digital design variables?

In summary, the conversation discusses the implementation of a car sensor system using combinational and sequential logic. The system includes variables for the door and seat belt sensors, as well as the sensor for detecting a car on a side street. The number of state elements and transitions is determined based on the number of traffic signals and desired sequencing. There are also recommendations to read up on state machines for further understanding.
  • #1
owtu
15
1
An example:
A car that senses if you have your seat belt on and the door is closed

I can declare:

D - for door
S - for seat belt

D is 1 is door is open, 0 if door is closed
S is 1 if seat belt is on, 0 if it's off

This is all very straight forward and can be implemented with combinational logic, but I'm working on something that uses sequential logic. I'll probably use a 555 timer and a 4017

If I have an intersection, the main street with a turn signal light and the main light and a side street that is rarely busy, it will only turn green when a car is present on that street.

Right off the bat I know I need a variable for the sensor that detects a car that is present on the side street

S - Sensor
S is 1 if car is present and 0 if no car is present

But I'm confused about how many variables I need for my street lights. I have a total of 9 LEDs: 3 reds, 3 yellows, and 3 greens. My plan is to have the reds and greens on for 20 seconds and the yellows for 4 seconds.
 
Engineering news on Phys.org
  • #2
Just write down the order the traffic lights are supposed to change. Then you'll see how many different states you'll need.
 
  • #3
mfb said:
Just write down the order the traffic lights are supposed to change. Then you'll see how many different states you'll need.

I'm not referring to the states though. What I'm referring to is the initial variables
 
  • #4
or are the states your variables? I'm confused, please enlighten me
 
  • #5
There are many ways to skin the cat, so to speak, but basically you need to determine how many signals there are, and how many combinations you want then to exist in. Say you had 3 signals ABC, and you wanted them to sequence "off, then A, then B, then C.". You *could* build a counter that counted 0,1,2,3, and decode the counter such that A=1 B=2 and C=3. You would then say you have 2 state elements, 3 signals, and that the nextstate = state+1.

Or, you could have 3 state elements, ABC, 1 for A, 1 for B and 1 for C . You would then say nextstate = (state ==0) ? 4 : state>>1;
This would essentially be a shifter, and could be called a 1-hot state machine. (1 state element for each state)

So, again, there are output signals, and there are states, and there are transitions between states.. The transformations between them is the design process.

If you have inputs, then your state transitions also depend on the inputs. (or maybe the outputs signals might also depend directly on the inputs).

I would recommend reading the wikipedia article on state machines.
http://en.wikipedia.org/wiki/Finite-state_machine
 

1. What is the purpose of declaring digital design variables?

Declaring digital design variables allows for the creation of data types that can hold different values, which can be used for various calculations and operations in digital design.

2. How do I declare a digital design variable?

To declare a digital design variable, you can use the syntax "data_type variable_name = initial_value;". For example, "int x = 5;" would declare an integer variable named x with an initial value of 5.

3. What are some common data types used in digital design?

Some common data types used in digital design include integers (int), floating-point numbers (float), characters (char), and Boolean values (bool).

4. Can digital design variables be changed during execution?

Yes, digital design variables can be changed during execution by reassigning a new value to the variable. For example, "x = 10;" would change the value of the variable x to 10.

5. Are there any limitations to declaring digital design variables?

There may be limitations on the size and range of values that can be stored in a digital design variable, depending on the data type and the specific hardware or software being used. It is important to consider these limitations when declaring and using variables in digital design.

Similar threads

Replies
6
Views
1K
  • Electrical Engineering
Replies
2
Views
6K
  • Electrical Engineering
Replies
7
Views
3K
Replies
1
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
23
Views
4K
  • Programming and Computer Science
Replies
4
Views
4K
  • Electrical Engineering
Replies
5
Views
5K
Replies
8
Views
2K
  • Introductory Physics Homework Help
Replies
4
Views
3K
  • Math Proof Training and Practice
2
Replies
62
Views
8K
Back
Top