10-04-2013 09:28 AM
Bobby,
You might recall we were working on a program starting with the Exercise 8-1 from the RT1 course. I am still lost. The attached code is what you last sent me. I don't work well with generalities. I need to be shown exactly what to do. I don't understand the last example you sent me.
The classroom Exercise controls the Fan and has PID Gains and Setpoint for it based upon fan control in response to the temperature. How do I get PID Gains and Setpoint in/out of PID.vi and Bundle by Name when there's more than one device shown in the attached sketch?
10-07-2013
10:29 AM
- last edited on
04-15-2025
09:00 AM
by
Content Cleaner
Hi Russ,
You already have the PID Gains and the Setpoint set as Network Published Shared Variables. You need to have these values in order to set them into the PID.vi. They are set in another portion of the code. Looking at the classroom example, the PID gains are initialized (or set) in initialize.vi.
In regards to bundling by name, if you look at the sketch, there is a type def (cluster) that is wired into the top of "Bundle by Name", that controls what can be written in that cluster. You can create any sort of control by right clicking on a constant on the block diagram and selecting "make type def". More info here: https://www.ni.com/docs/en-US/bundle/labview/page/creating-type-definitions-and-strict-type-definiti...
In the example I sent you, add some name labels to the cluster marked "some cluster" (right click the string or numeric > visible items > Label , then change the label name... repeat this process for the other item in the cluster). Then replace the "bundle" VI with a "bundle by name VI". You should see the item names as options in the "bundle by name" VI inputs.
Did I clarify things for you?
Regards,
10-07-2013 01:28 PM
Bobby,
Actually, now I am more lost. I don't know how what has been suggeted is helping the goal.
In the classroom example, there's just the fan and temperature sensor; possibly the lamp that's being sensed/controlled. Addition to fan, I need to add Widget x and Widget y that will be controlled in response to the sensors, which could be temperature, Sensor x and Sensor y. (Please refer to the sketch I uploaded). Please keep in mind my sketch may not be an accurate representation because I am not sure the benchmark (classroom exercise 8-1) can be modified to do this.
Let's please forget the example you sent me and start from scratch. I don't understand it.
I am familiar with make type def. but don't know how that helps for the goal. Are you suggesting making Target Data.ctl type def? I don't know how that helps. Maybe it's better to scratch this too if it only confuses the goal below:
Basically what I am looking for is modifying the classroom example to add more controlled devices that respond to sensor devices. How do I do that in a nice clean code? Please include pictures and sketches.
10-08-2013
09:35 AM
- last edited on
04-15-2025
09:01 AM
by
Content Cleaner
Hi Russ,
I would suggest looking into utilizing some our Alliance Partners for your project as I can pretty much only offer abstract architecture advice for this sort of question from my end.
They can be found here, https://www.ni.com/en/partners.html
Regards,
10-10-2013 10:08 PM
Bobby,
We will not be using Alliance Partners. It's not in our policy. Jeremy Backer guaranteed assistance through this forum. I don't think it gets more abstract demonstrating how to add additional indicators and controls to existing code from the class.
-Russ
10-11-2013 06:52 AM
10-11-2013
03:02 PM
- last edited on
04-15-2025
09:02 AM
by
Content Cleaner
Russ,
While we can recommend overall programming architectures to use, we cannot write application specific code. However, I can provide you with lower level functional support if you have a specific question about the following walkthrough. With that in mind, lets break down the classroom example and I'll reference some learning materials that you'll need to review in order to properly implement what you're suggesting into your own code.
In the classroom example, there's only 1 sensor in the system and that's the temperature sensor. Let’s say we want to add another one and we'll use the names that you mentioned already, X and Y. We want these sensors to control widgets A and B. Lets also say that we want these other 2 control loops places in the same while loop because we want them to run at the same rate. Note: Sensor X is paired with Widget A and Sensor Y with Widget B.
On the cRIO, we're going to use the same basic configuration as the first PID VI. This means you're going to need to make new network shared variables for this new PID. So it would probably be in your best interest to rename all of the variables in the project to relate to the PID they are associate with. For example, "PID Gains 2", "Setpoint 2", etc. If you notice, the values for the temperature (same for sensor X, Y) and the Lamp (same for widget A, B) are drag and drop I/O variables from the modules listed in the chassis from the project view. You will explicitly name these items from the project. So if you physically wire your sensor into a thermocouple module, you will name the associated input channel to "Thermocouple Sensor X" or whatever other sensor you put in. Does this make sense?
The next step to adjust the data you're sending to your host VI. If you notice, the "Target Data.ctl" is only set to pass on the information from the 1st PID. We want to add the next 2 PID controls to it so the host VI knows what happening on the target cRIO. To do this, we need to modify the Target Data.ctl file to include the items associated with the 2 other PIDs. They are probably going to be "Setpoint 2", "Sensor X", "Widget A", "Setpoint 3", "Sensor Y", "Widget B". You will use these items on your Host VI to display relevant user information.
That coveres the cRIO. On the user end of things, you'll notice controls are already set for a "Setpoint" and "PID Gains", you'll add the controls for the 2 new PID and setpoints we configured earlier. After that, you'll configure your widget outputs and the graph to display the information you feel is relevant to the user.
Here are some relevant links for you to utilize while you go through this.
General network shared variable info: https://www.ni.com/en/support/documentation/supplemental/06/using-the-labview-shared-variable.html#s... , section 1 will show you how to create them.
Instructions on modifying the typedef: https://www.ni.com/docs/en-US/bundle/labview/page/creating-type-definitions-and-strict-type-definiti...
With that plan in mind, do you have any questions regarding specific areas of this walkthrough?
10-14-2013 10:23 PM
JB,
It is my understanding that for sbRIO, RT targets, best practices should include only one while loop, or in this case, timed loop. Anyone is welcome to join in on the discussion if I am wrong about that.
-R
10-14-2013
11:01 PM
- last edited on
04-15-2025
09:06 AM
by
Content Cleaner
Russ,
I have not heard that, and would not have thought it to be true. Here's an article on timing structures, including timed loops. I glanced through, and didn't see anything.
https://www.ni.com/docs/en-US/bundle/labview-real-time-module/page/timing-deterministic-applications...
I say try it, and see if it causes any problems. If not, use it. Someone else may weigh in with more educated information.
Jeremy
10-14-2013 11:16 PM
While we can recommend overall programming architectures to use, we cannot write application specific code. However, I can provide you with lower level functional support if you have a specific question about the following walkthrough. With that in mind, lets break down the classroom example and I'll reference some learning materials that you'll need to review in order to properly implement what you're suggesting into your own code. I am not seeing where writing generic example code is the same as application specific code. To me it’s demonstrating two or three expansions on the RT class. It’s my understanding that questions expanding on the class are highly welcome.
In the classroom example, there's only 1 sensor in the system and that's the temperature sensor. Let’s say we want to add another one and we'll use the names that you mentioned already, X and Y. We want these sensors to control widgets A and B. Lets also say that we want these other 2 control loops places in the same while loop because we want them to run at the same rate. Note: Sensor X is paired with Widget A and Sensor Y with Widget B.
On the cRIO, we're going to use the same basic configuration as the first PID VI. This means you're going to need to make new network shared variables for this new PID. So it would probably be in your best interest to rename all of the variables in the project to relate to the PID they are associate with. For example, "PID Gains 2", "Setpoint 2", etc. Check, I have unique network shared variables for my “PID Gains 2” and “Setpoint 2” prior to the discussion. Are you suggesting each will have their own PID VI?
If you notice, the values for the temperature (same for sensor X, Y) and the Lamp (same for widget A, B) are drag and drop I/O variables from the modules listed in the chassis from the project view. You will explicitly name these items from the project. So if you physically wire your sensor into a thermocouple module, you will name the associated input channel to "Thermocouple Sensor X" or whatever other sensor you put in. Does this make sense? Yes, I understand this. That’s not the issue I am experiencing. Also I am assuming these I/O variables can be embedded in sub-VIs, and those sub-VI’s substituted in place of the RIO variables. But we’ll stick to the fundamental idea for now.
The next step to adjust the data you're sending to your host VI. If you notice, the "Target Data.ctl" is only set to pass on the information from the 1st PID. We want to add the next 2 PID controls to it so the host VI knows what happening on the target cRIO. To do this, we need to modify the Target Data.ctl file to include the items associated with the 2 other PIDs. They are probably going to be "Setpoint 2", "Sensor X", "Widget A", "Setpoint 3", "Sensor Y", "Widget B". You will use these items on your Host VI to display relevant user information. Check, I already did this prior to the discussion. However, I am thinking this would be condensed with arrays. I just don’t know how to do that. Is there only one PID.vi allowed per Timed Loop or While Loop?
That covers the cRIO. On the user end of things, you'll notice controls are already set for a "Setpoint" and "PID Gains", you'll add the controls for the 2 new PID and setpoints we configured earlier. After that, you'll configure your widget outputs and the graph to display the information you feel is relevant to the user. This is where the waters get murky. Is there a PID.vi and Bundle by Name for each, in the same Timed Loop, or is it all jammed through the same PID.vi? I think this is where I got lost in the discussion because of references of putting the PID.vi in a “For Loop” via an array. Please be assured I exhausted different combinations of arrays within my knowledge before posting.
I am just looking for the best practice to enhance my programming skills. For that reason, I have no forward plans to use Alliance Partners.
I am sure there’s more than one way to do this.
Just like
4 x 3 = 12
3 x 4 = 12
2 x 2 x 3 = 12
2 x 6 = 12
1 x 12 = 12
I just don’t want big spaghetti code when small code will due. And I don’t want to write code that does not work at all. I just don’t have anyone to bounce this off of except this forum. Thanks for understanding.
If anyone else out there wants to contribute along with Bobby, please feel free to jump in.