Motion Control and Motor Drives

cancel
Showing results for 
Search instead for 
Did you mean: 

SoftMotion cRIO - how to read position from a host starting from a shipping example?

Solved!
Go to solution

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 

For an opportunity to learn from experienced developers / entrepeneurs (Steve, Joerg, and Brian amongst them):
Check out DSH Pragmatic Software Development Workshop!

DQMH Lead Architect * DQMH Trusted Advisor * Certified LabVIEW Architect * Certified LabVIEW Embedded Developer * Certified Professional Instructor * LabVIEW Champion * Code Janitor

Have you been nice to future you?
0 Kudos
Message 1 of 8
(6,061 Views)

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

Message 2 of 8
(6,051 Views)

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?  

 

Axis Straight Line-modified project.jpg

 

For an opportunity to learn from experienced developers / entrepeneurs (Steve, Joerg, and Brian amongst them):
Check out DSH Pragmatic Software Development Workshop!

DQMH Lead Architect * DQMH Trusted Advisor * Certified LabVIEW Architect * Certified LabVIEW Embedded Developer * Certified Professional Instructor * LabVIEW Champion * Code Janitor

Have you been nice to future you?
0 Kudos
Message 3 of 8
(6,042 Views)

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, 

Marti C
Applications Engineer
National Instruments
NI Medical
0 Kudos
Message 4 of 8
(6,020 Views)

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

Message 5 of 8
(6,008 Views)

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 

 

For an opportunity to learn from experienced developers / entrepeneurs (Steve, Joerg, and Brian amongst them):
Check out DSH Pragmatic Software Development Workshop!

DQMH Lead Architect * DQMH Trusted Advisor * Certified LabVIEW Architect * Certified LabVIEW Embedded Developer * Certified Professional Instructor * LabVIEW Champion * Code Janitor

Have you been nice to future you?
0 Kudos
Message 6 of 8
(6,001 Views)
Solution
Accepted by topic author FabiolaDelaCueva

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. 

Message 7 of 8
(5,908 Views)

Hokie,

 

Thank you very much!! it seems that the guide is going to clarify some of my doubts.

 

Thanks 

For an opportunity to learn from experienced developers / entrepeneurs (Steve, Joerg, and Brian amongst them):
Check out DSH Pragmatic Software Development Workshop!

DQMH Lead Architect * DQMH Trusted Advisor * Certified LabVIEW Architect * Certified LabVIEW Embedded Developer * Certified Professional Instructor * LabVIEW Champion * Code Janitor

Have you been nice to future you?
0 Kudos
Message 8 of 8
(5,854 Views)