Topic: More Elegant latch
I'm very new to FBD and while I'm able to achieve the results I want I feel like my program is far from optimized.
I have two inputs:
Input A has a value of 0/1
Input B has a value of 0/1
Input A is a user operated switch (1 = Switch ON)
Input B will fluctuate between 0/1 based on the speed of the vehicle (if > 40kmh, B=1)
What I'd like:
Scenario 1) A=0 and B=0 output=0
Scenario 2) A=0 and B=1 output=0
Scenario 3) A=1 and B=0 output=0
Scenario 4) A=1 and B=1 output=1 and output will stay 1 regardless of the state of B until A=0.
These seems like an ideal fit for a latch and D flip-flop satisfies scenarios 1, 2, 3, and half of 4. When B becomes 1, A will be forwarded to the output which becomes 1, it will however not set the output to 0 when A=0 and B becomes 0.
I'm currently building a nested logical and relational operators loop but feel like there has to be a better way. Any suggestions?