Motion Control and Motor Drives

cancel
Showing results for 
Search instead for 
Did you mean: 

Switching buffers in contour mode

Hello,

I’m trying to implement the technique described in the help file – Advanced Uses - item 1 & 2 for the function flex_configure_buffer. So far I only get to work the first configured buffer. After “switching” to the second buffer the motion became erratic.

I attached the portion of my C code that is intended to do this, please tell me what I’m doing wrong or where I can find an implementation of this technique.

 

Thanks.

0 Kudos
Message 1 of 15
(5,138 Views)
TulioB,

could you please explain in more detail what you try to accomplish from an application's point of view? Additionally could you please post the part of the help file (which help file?) you are referring to? I haven't been able to find the items that you have mentioned.

Thanks,

Jochen Klier
National Instruments Germany
0 Kudos
Message 2 of 15
(5,126 Views)

Hi Jochen,

 


What I’m trying to do is to reduce the total time that my application takes to complete a job. This application controls an XY cutting table. It uses contour mode to cut the pieces, linear interpolation to positioning at the beginning of each part that needs to be cut and I/O ports to change tools.

Every call to a flex_... function takes some time to complete (they are synchronous functions), the sum of this times can sometimes increase the time to complete a piece in much as 3 seconds. The most time consuming calls are allocating and writing to a contour buffer, but changing from contour mode to linear interpolation, setting velocity/ acceleration, loading target position and starting the move can add a significant time if the piece requires a lot of positioning.

So to “eliminate” this extra time it will be desirable to perform all motions in a single contour buffer. All trajectories will be pre-calculated, and written to the buffer on the fly. But a single buffer creates a problem of how to synchronize a tool change with some coordinate in the piece.

I considered using breakpoints, but this solution only work with encoders. If I can switch buffers, I will have an opportunity to make a call to I/O functions in very precise point, let’s says, at completion of one buffer. The idea is while one buffer is being interpolated, the other is being writing. I’m open to any suggestions in those issues.

 


The documentation that I referred is “October 2003 Edition, Part Number 370538B-01”,

for flex_configure_buffer:

 


Advanced Uses

Using input vectors and return vectors with the Read Buffer and Write Buffer functions, you can write to and read from the buffer with data stored in onboard variables. You will need to limit the number of points to read or write, since there are only 120 onboard variables. Data will be read from or written to onboard variables sequentially starting at the variable specified by the inputVector or returnVector in the Write Buffer function or Read Buffer function.

 

1) Specify a bufferSize of 0 to associate a resource (like an axis or vector space) to an existing buffer, without affecting the size of the buffer or the data contained in the buffer. The following examples illustrate the use of this technique:

 


2) A single resource (e.g. axis or vector space) can use buffer 1 for a contouring operation, and then be switched over to buffer 2 for a subsequent operation. You can set up the two buffers ahead of time, and when the first operation is complete, you can make an additional call to Configure Buffer with a bufferSize of 0, the same value for resource, and the new buffer number for buffer.

If you wish to reuse a buffer with another resource, simply call the Configure Buffer function with the same buffer number, a bufferSize of 0, and a new value for resource. Both resources can still use the single buffer, but not at the same time.

 


3) A buffer size of 0 allows you to associate a resource with an existing buffer, without changing the contents of the existing buffer. Also, a buffer size of 0 can be used to leave the current buffer alone, but change the value of another parameter, such as totalPoints. If you are reconfiguring a buffer with a bufferSize of 0, the read mark is set to 0. If the buffer is an output buffer, the write mark is set to bufferSize. If the buffer is an input buffer, the write mark is set to 0.

 


4) When a buffer has been saved to ROM using the Object Memory Management function, and the association between the buffer and the resource (for example, axis or vector space) has been lost (most likely through a power cycle or a call to Clear Buffer), the association between the resource and the buffer needs to be re-established before a buffered operation can be performed with the buffer. Since the buffer already exists in ROM, specifying a bufferSize of 0 will tell the NI motion controller to associate the specified resource with the specified buffer without allocating any new memory for the buffer. If the buffer does not exist, an NIMC_objectReferenceError is generated.

After a contouring operation, the same buffer of points can be contoured again, with a different time interval between points, or number of totalPoints. Just pass in a 0 for buffer size and change the other parameters as desired.

 


When reconfiguring an existing output buffer (e.g. contouring buffer) by passing a bufferSize of 0, the buffer is assumed to be full of data. If you want to change its contents, do so before reconfiguring the buffer.

 


Thanks.

0 Kudos
Message 3 of 15
(5,124 Views)
TulioB,

I'm sorry but I won't be able to do more investigations today. I will do some tests tomorrow and post an answer as soon as possible.

Regards,

Jochen
0 Kudos
Message 4 of 15
(5,117 Views)
Hi TulioB,

thank you for this detailed explanation. I agree that using breakpoints would be a desirable solution but as there are obviously no encoders available it's not an option and using two alternating buffers sounds like a feasible solution.
I have done a quick test by modifying a LabVIEW example and it worked properly. In fact I couldn't find significant differences between your example and mine. The only difference seems to be the fact that I have configured both buffers for the same axis.

I have configured the second buffer first and then the first one so when I have started the move the first buffer was assigned to the axis. After the first move was finished I have reconfigured the second buffer with a buffer size of "0" and the second move has started as expected. Here you can see a screenshot from the position plot in MAX. The first sine wave was generated by the first buffer, the second one by the second buffer.



Could you please provide more information what you mean with "After switching to the second buffer the motion became erratic"?. Which NI-Motion version are you using?

Jochen

Message Edited by Jochen on 12-20-2006 05:46 PM

Message 5 of 15
(5,108 Views)

Hi Jochen,

What I mean is that when the second buffer is executed, one of the axis (always the same axis) travel in reverse direction. If I put a call to flex_stop_motion(boardID, NIMC_VECTOR_SPACE1, NIMC_DECEL_STOP, 0) before configuring the second buffer with buffer size 0, the motion works fine. I configured both buffers for the same vector space as you do but it didn’t change the behavior. It only works if I force a stop on the vector space. Can you tell me if the example that you used force this stop before changing the buffers?

Adopting a solution that doesn’t require encoders to work is desirable, but not mandatory. The problem that I see with breakpoints is that they work only on a per axis base, not on a vector space. Is it possible to use breakpoints on a vector space?

I would also like to know if you are aware of other strategies that I could use to design my application in order to improve my cutting time.

Thank you very much for your help so far Jochen. I’m very pleased.  

Message 6 of 15
(5,104 Views)
Hi TulioB,

I have modified my test and now it runs with a 2D vector space instead of a single axis and it behaves exactly as you have explained. As long as there is no flex_stop_motion() between the two moves the second move will be erratic or it won't start at all. With a single axis I haven't been able to reproduce this behavior.

I will pass this information to NI Motion R&D and keep you updated.

I agree with you that using breakpoints with 2D vector spaces is not an option. The reason for that is the fact that a 2D or 3D breakpoint would require all two or three axes to be simultaneously present at an exactly defined position which is in practice nearly impossible.

Besides dual buffered contouring blending could be an option for your application but this will only work if the standard interpolation modes (linear, circular) work for your application and if the moves are long enough to allow loading the new move constraints for the next move.

Jochen
0 Kudos
Message 7 of 15
(5,094 Views)
Hi Jochen,

I finished a small program that implements the double buffer technique and run some trials on it to compare the performance. To my disappointment the performance was not what I expected. Since I’m not completely sure that I use correctly the FlexMotion functions, I would like to know if I can send to you the program/source code to analyze. I do not wish to post this source code openly in the forum. Is there any other way to send the code?

 


Thanks.

0 Kudos
Message 8 of 15
(5,039 Views)
Hi TulioB,

you can upload your code to ftp://ftp.ni.com/incoming. This is a directory on our ftp server where you can upload files but noboday can download files from it outside the NI firewall. Please use zip format and post the file name.

Thanks,

Jochen
0 Kudos
Message 9 of 15
(5,037 Views)
Hi Jochem,
I uploaded the file 'ToJochem_DoubleBuffer.zip' in the ftp. There is a ReadMe.doc explaining the contents of the file.

Thanks.
0 Kudos
Message 10 of 15
(5,029 Views)