Logical circuit

Thread Starter

Eason Mu

Joined Dec 7, 2024
9
Here is some code for Matlab, I want to achieve the function using ltspice. But I don't know how to build it.
u is sine.
1741203298196.png
 

DennisC_HI

Joined Sep 7, 2022
9
Separate the conditions for each output signal and then simplify the expressions to get expressions for each output signal. I assume you need expressions for behavioral voltage sources and that U is a voltage signal at node U. Logical expressions produce outputs of 1 (true) or 0 (false).

B1 node1 node2 V=V(U) >= 0
B2 node3 node4 V=(V(U) < -1) | ((V(U) >= 0) & (V(U) < 1))
B3 node5 node6 V= if(V(U) < -1, 2-V(U), if(V(U) < 0, V(U)+1, if(V(U)<1, V(U), V(U)-1)))

HTH
 

DennisC_HI

Joined Sep 7, 2022
9
If you want nodes D1, D2, and D3 with voltages relative to GND then this can be simplified to:

B1 D1 0 V=V(U) >= 0
B2 D2 0 V=(V(U) < -1) | ((V(U) >= 0) & (V(U) < 1))
B3 D3 0 V=if(V(U) < -1, 2 - V(U), if(V(U) < 0, V(U) + 1, if(V(U) < 1, V(U), V(U) - 1)))
 

Thread Starter

Eason Mu

Joined Dec 7, 2024
9
Separate the conditions for each output signal and then simplify the expressions to get expressions for each output signal. I assume you need expressions for behavioral voltage sources and that U is a voltage signal at node U. Logical expressions produce outputs of 1 (true) or 0 (false).
I need to build the logical circuit using PSIM, do you know how to build it?
 
Top