Coerce units in expressions

In my expressions, I often wish to refer to constant values, such as 3A, or -1.5V. In the past, to obtain values with particular units, I have placed a 1V source (Vunit) and a 1A source (Iunit) on the schematic, and in my expressions I refer to them in the following way:


Also, sometimes I want to refer to a resistance on the schematic in my expressions, so that when the resistance value is modified I don't have to edit expressions to reflect the change. I have not found a way to do this. Currently, the only way I know to achieve this is is to invoke Ohm's law on parameters that are available, like this:


I would have thought that an expression like R1.R should evaluate to the resistance of element R1, as used in the DC sweep "parameter" argument, but this does not work in expressions.

One big reason for requiring values with correct units, is to force expressions to evaluate with appropriate units, enabling them to share the same graph space as other plots of the same units.

Ideally, something like a function volts(-1.5), or ohms(100) would be great. Does anyone know of such coercion functions, or other techniques to accomplish this?

by Cabwood
September 08, 2022

Post a Reply

Please sign in or create an account to comment.

Go Ad-Free. Activate your CircuitLab membership. No more ads. Save unlimited circuits. Run unlimited simulations.

About CircuitLab

CircuitLab is an in-browser schematic capture and circuit simulation software tool to help you rapidly design and analyze analog and digital electronics systems.