12-15-2009 06:05 PM
When opening the examples that ship with NI SoftMotion, generally there are two loops. The main loop and a loop that has the following message:
"Reading the position and plotting would normally be done on the host by reading data published by the target. This is done in this example for simplicity."
Then you are advised on the front panel to go to ni.com/info and enter info code nismex for information about using this example in an actual motion system.
My question might seem obvious, but how do I "Read the position on the host by reading the data published by the target"?
I tried using the NI SoftMotion Read function block inside a VI on the host, of course, this does not work, because the resource is on the target.
Should I leave the second loop inside the VI running at the cRIO system and just not plot, but subscribe to a shared variable? I see that you can right click on the function block and select if you want an output to be a shared variable. Or is that second loop supposed to be removed from the VI running on the RT Target? How would I read the position then?
To see an example of what I am referring to, open this example: C:\Program Files\National Instruments\LabVIEW 2009\examples\Motion\FunctionBlocks\Axis Straight Line Move\Axis Straight Line.lvproj
Thanks,
Fabiola
Solved! Go to Solution.
12-16-2009 04:46 AM
Hi Fabiola,
as you have already experienced, you can't use the function blocks on the Windows system to communicate to the motion control application on the cRIO. The most simple solution is of course using Shared Variables. Shared Variables are good for simple tasks, but if you need better performance, lossless data streaming and better scalability, please refer to the concepts that are explained in the Simple Machine Control Reference Application tutorial.
Here you can find more examples about this topic.
I hope that helps,
Jochen Klier
National Instruments
12-16-2009 11:06 AM
Jochen,
Thank you for your prompt response.
The tutorial and examples are going to be very useful once I get more into developing the full blown application.
For now, I just want to understand how I could transform one of the shipping examples into a host-target example. I don't understand what would be the best practices applied to the use of the NI SoftMotion Read functional block for example.
I am attaching (zip file and image) my attempt to converting the Axis Straight Line shipping example into a host-target project. I added a cRIO target with a chassis and a NI 9512. Configured my axis and moved the VI there. Then I right-clicked on the Read SoftMotion functional block>>properties and then made the position a Network published variable. Then I created a host vi that reads that variable and plots it on the host vi.
What are the disadvantages of doing it this way? Should I make the main loop a timed loop sync with the Scan Engine and with a higher priority than the lower loop?
12-17-2009 04:34 PM
Hi,
Getting the system on to a "real" motion system should be relativetly simple, just follow the steps at this link:
Moving NI Motion Examples to Motion Hardware
The examples, while they are not always exactly what your application is, are generally optimized already, but if you run into issues we can always look into altering them.
Cheers,
12-18-2009 03:11 AM
As said, for simple monitoring tasks, your approach works fine and there are no significant disadvantages. Things change, if you need to transfer data to the host at higher rates and with deterministic timing. In this case you should refer to the concepts, that are explained in the examles, that I have linked in my last post.
To answer your question about the main loop: Indeed you have to use a timed loop that is synchronized to the scan engine. NI SoftMotion function blocks rely strongly on this synchronization and timing, so I'm a bit surprised, that you have been able to run your application with a normal while loop.
Regards and merry Christmas,
Jochen
12-18-2009 06:36 AM
Jochen,
Thank you very much for your time. You are right, I was surprised that the shipping example came with a regular loop too.
I got to be infront of the hardware yesterday and it worked fine with the examples and with my modified examples. I will study more the concepts you recommended earlier for the final application.
Marti,
FYI. The link you suggested is the same page you get to by going to ni.com/info and entering info code nismex (I mentioned I did that in my first post).
Thanks,
Fabiola
12-31-2009 11:58 AM
Regarding the priority and timing of calling the motion function blocks:
The NI SoftMotion engine for cRIO uses a background "driver" that executes in synch to the scan engine on the CompactRIO system. This provides the required timing and synch for motion to execute properly. The motion function blocks simply send asynchronous commands to this "driver". You can think of these as a command API to the motion control engine. You are not required to synchronize the motion function blocks to the scan engine or even to run them at a high priority. However you likely will choose to run these at a higher priority or in a timed loop for execution prioritization reasons. For more details on the NI SoftMotion architecture and recommendations on how to build motion systems on CompactRIO check out the CompactRIO Developers Guide (http://www.ni.com/compactriodevguide/). It was updated in December of 2009 and chapter 5 now has a large section on motion control on CompactRIO complete with example projects.
01-05-2010 05:18 PM
Hokie,
Thank you very much!! it seems that the guide is going to clarify some of my doubts.
Thanks