Zerout23 Posted June 18, 2021 Share Posted June 18, 2021 I have a variable value component that displays a channel's value (input register). I set the variable value component's units to Volts. What I want to accomplish is have an edit box where a user can enter a numeric value (in this case it would be a resistance value) and I want to read that value and use it to update the Variable value to it's new converted value with the units changed as well (Amps). 1. Variable value component (V) example: 12.00 V 2. User enters numeric data (ohms) into edit box read entered data calculate new variable value ( I = V/R) example: user enters 100 ohms; calculate 12/100 = 0.12 3. update variable value component to display new converted value (A) example: 12.00 V ---> 0.12 A Hopefully this makes sense and I would think it would be something simple to accomplish but I just can't figure it out yet. Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted June 18, 2021 Share Posted June 18, 2021 OK, first just to be clear the "Units" field in the variable value component is just a label. To do what you want you need a global variable to hold the ohms. So: 1) create a new Sequence. Call it "StartUp" and check the box "Auto-Start" at the top so it runs on boot. The script would be simply: global ohms = 1 2) Apply then run the sequence 3) create a new variable value component. Select the "Analog Out" button under Quick in its properties and enter Ohms. Feel free to edit the caption and units afterwards. This will display the ohms value and when you click on the variable value control it will prompt for a new value 4) create another variable value component, Caption of "Amps". Expression will be: "volts / ohms" (without the quotes) where volts is the name of the channel holding your volts. Ohms is that global variable we created. Quote Link to comment Share on other sites More sharing options...
Zerout23 Posted June 18, 2021 Author Share Posted June 18, 2021 Thanks! this can work. One thing that I didn't mention was that if the user does not enter resistance data I would still want to display the voltage value of the channel. So using your example I now have 3 variable value components rather than 2. is it possible to have the one switch from Volts to Amps? Thank you again! Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted June 21, 2021 Share Posted June 21, 2021 Just set the ohms to 1 to get volts from volts. Quote Link to comment Share on other sites More sharing options...
Zerout23 Posted June 21, 2021 Author Share Posted June 21, 2021 That would make the value change to volts but the units label does not change from Amps to Volts that's more what i would want to do. i guess if they enter 1 as the ohms (or default as 1) the units will show as volts but when they put a value other than 1 I would want it to change to Amps. Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted June 23, 2021 Share Posted June 23, 2021 There are lots of ways to do this. The easiest is to create two variable value controls, one showing amps and one showing volts. Then set the Visibile expression to ohms == 1 for the one that displays volts, and ohms != 1 for the one that displays amps. This will cause DAQFactory to only display one or the other. The Visible expression is on the Size tab of the component's properties. Quote Link to comment Share on other sites More sharing options...
Zerout23 Posted June 24, 2021 Author Share Posted June 24, 2021 oh ok cool. I'm trying to keep them at the same x,y postions so i will have 1 variable value component (A) on top of the other (V). do you recommend I do it this way? only reason is because i'm limited in space. When in edit mode is there a way to make the invisible components appear (in case if i forget they're invisible in the future)? I really appreciate all the help you've given Quote Link to comment Share on other sites More sharing options...
AzeoTech Posted July 6, 2021 Share Posted July 6, 2021 Yes, you can just put them on top of each other. There is no built in way to make them visible. You can, of course, just create a global variable called, say "showAllComponents" and then change your visible expressions to: (ohms == 1) || showAllComponents and (ohms != 1) || showAllComponents Then set showAllComponents to 0 for normal operation, and 1 to show everything. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.