Motion Control and Motor Drives

cancel
Showing results for 
Search instead for 
Did you mean: 

Get Position from 9512 Encoder in FPGA

Hello,

 

I am using the following Software/Hardware:

 

LV2010 with SoftMotion, Realtime, and FPGA modules

cRIO-9073 with NI 9512 Stepper Card and associated NI Drive

Misc Input and Output cards for digital signals

 

My application is essentially a conveyor capable of running up to 12.5 inches/sec with product spaced at approx 1.25" intervals.  I need to locate the parts on the conveyor using a trigger photoeye and then initiate different actions at different points of the conveyor as the product traverses down the conveyor.  The spacing between parts is variable.

 

This is my first RT/FPGA application but I have underwent the NI Training.  I was originally planning on using the RT controller in scan mode, but my initial testing shows this may not be fast enough.  I have written code to perform the following:

 

1. Activate Conveyor

Using Softmotion Function Blocks the RT controller starts the stepper motor and hence runs the conveyor.  I am currently testing the conveyor at two speeds to simulate real life conditions (Currently testing at 6 in/s and 12.5 in/s)

 

2. Capture Trigger Position

Capture the part location using a photoeye.  I am NOT currently using the position capture feature of the 9512.  Instead I have a loop looking for a rising edge of the trigger photoeye and then using the Softmotion Function Block to read the current position at that point.  I shift the position into an array to serve as a shift register.  To reduce jitter, I may eventually go to the hardware capture point on the 9512.

 

3. Inspect Part

I have another loop constantly evaluating the position of the belt using a Softmotion FB read and searching the array to see if the current position minus an offset amount (distance of device from trigger point) is in the array within a given tolerance.  For instance, say a part was seen on the conveyor after the belt has moved 1.000" from its initialization.  1.000" is shifted into the array from step #2 above.  A visual inspection of the part needs to occur at 10" from the photoeye.  The loop monitors the position of the belt and when the position of the belt is seen between 10.980 and 11.020", the inspection loop triggers the inspection and evaluates the results.  The results are updated in the shift register for the part evaluated.  As you can see, the jitter in the system requires a window and not an exact value.  Obviously, I want this window to be as small as possible.

 

4.  Divert Part

Based on the inspection results, the part is divereted off of the belt.  Another loop monitoring the conveyor position (using the Softmotion FB Read) is constantly inspecting the current position to see if the part is in the diverter position.  This loop functions exactly as Step #3 but the offset is different (15.000").  When the conveyor position is between 15.980" and 16.020", the diverter is activated if the part is bad.

 

5. Monitoring Loop

This is a test loop I have added to determine the jitter in the system and how much conveyor movement has occurred since the last scan.  Basically this loop uses the Softmotion Read FB and subtracts the previous iteration's position from the current iteration to determine the belt movement since the last scan.

 

ISSUES

I have all loops set to sync with scan engine and the scan engine running at the default 5mS.  With the conveyor moving at 6 in/sec, I am seeing the monitor loop show a conveyor movement of approx 0.031" between scans.  This indicates that the part moved 0.031" before the RT controller can respond to this.  Therefore, the position tolerance windows in steps 3 and 4 above have to be greater then 0.031" to see the part and react as it passes by the point on the conveyor.  In this instance it seems to be working, but occasionally, the distance traversed is much greater.  If that occurs, then parts can be missed.

 

When I run at 12.5 in/sec, I am seeing about double the distance traveled.  I need to minimize the position jitter on the system to insure that the part is as tightly controlled in location as possible.  If the part moves too much between scans, then my inspections might not be aligned with the part (ie. out of the vision FOV).  In my original research of the RT control system and discussions with NI technicians, I was under the impression that the scan engine would be running at 1kHz therefore, I could expect a position jitter of around 0.012".  Now that I have the hardware and am programming, I see that the recommended scan engine setting for Softmotion is 5ms.  That puts my position error around 0.060". 

 

Furthermore, I plan on adding more inspections and actions at different points of the conveyor prior to the divert.  Therefore, it is beneficial to reduce the amount of delay.  My fall back approach was to program the hardware with FPGA which should give very quick response and minimize the position error between scans.  However, now that I am programming, I cannot find a way to control the 9512 with FPGA or read the encoder of the 9512 with FPGA.

 

According to the NI C Series Module Compatibility Chart on the website, the NI 9512 is controllable from ScanEngine or FPGA.  I can create a project with FPGA and place the NI 9512 module under the FPGA portion, but there is no I/O or functions available for the module.  When adding a DIO card to the FPGA, Inputs and/or Output nodes are created.  Also, the Softmotion tools palette only has a couple of commands and none refer to the encoder. Am I overlooking something.

 

SPECIFIC QUESTIONS

1. How does one control the NI 9512 in FPGA.

 

2. How can the encoder count from the NI 9512 module be examined in FPGA.

 

3. Any insights on how to optimize the project or if it can be done in FPGA with the 9512 hardware.

 

My gut feeling is that I will have to abandon the Scan Engine approach and go straight FPGA, but I am struggling to find ways to control the 9512 with FPGA.

 

Thanks,

 

Rick

0 Kudos
Message 1 of 4
(5,404 Views)

Hello RickMudd,

 

If you wish to use 9512 in FPGA, you can follow the tutorial here

http://www.ni.com/pdf/manuals/372596b.pdf

 

It walks you through how to setup your chassis and module in your project as well as setting up the I/O in FPGA.

 

Andy Chang
National Instruments
0 Kudos
Message 2 of 4
(5,385 Views)

Hello Andy,

 

Thank you for the reply.  I have reviewed that document and cannot find anything specific about the NI 9512 Stepper Module.  I understand how to create a small FPGA project, but the problem I'm specifically having is that when I add the NI 9512 module under the FPGA target, I do not get any FPGA I/O available.  When I add the 9512 module to slot 3, I can see the module itself under the FPGA target, but there is not any FGPA I/O available under Mod3 (there isn't even a Mod3 folder created).  I have attached a JPG showing my project and the absence of any Module 3 I/O.

 

I cannot find a way to obtain the Enoder count from the 9512 module in FPGA.  I have searched for some examples on how to control this module in FPGA, but cannot find anything relevant.  Can you elaborate more specifically concerning the NI 9512 module in FPGA mode.

 

Thanks,

 

Rick

0 Kudos
Message 3 of 4
(5,379 Views)

Hi Rick

 

To use the 9512 in FPGA mode you will need to be on the LabVIEW 2010 platform and use our new tool for updating the firmware on the module.

 

With 2010 installed for a tutorial on how to use the Firmware update tool navigate to FPGA Module>>CompactRIO Reference and Procedures (FPGA Interface)>> Motion Modules>>NI 9512>> Downloading Firmware to an NI 951x Module (FPGA Interface). This will walk you through all the steps necessary, under this same folder you will see all the Write, Scan and Read Methods the module runs on. Keep in mind this module uses methods to transfer data from the FPGA not I/O.

 


Thank You
Eric Reid
National Instruments
Motion R&D
0 Kudos
Message 4 of 4
(5,302 Views)