1

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?

2 (edited by mlrtime99 17-07-2021 23:45:36)

Re: More Elegant latch

The section in orange is the best I could do.  I used a PWM to pulse a "reset" to the flip-flop when input A=0

Post's attachments

Attachment icon latch.png 136.72 kb, 96 downloads since 2021-07-17 

3

Re: More Elegant latch

Please see attachment with another variant of possible solution.

Also, it is highly possible that only single of a couple of bits of the register D5:D4 is responsible for the state of this switch button, not all 16 bits of D5:D4. If so, you better find this bit. Since other bites in D5:D4 may be influenced by the state of other buttons or vehicle systems the diagram may stops working in a different buttons or vehicle systems state.

Post's attachments

Attachment icon switch.cfd 1.54 kb, 199 downloads since 2021-07-22