12-18-2006 11:18 AM
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.
12-19-2006 02:30 AM
12-19-2006 05:19 AM
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-
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.
12-19-2006 08:31 AM
12-20-2006 10:45 AM - edited 12-20-2006 10:45 AM

Message Edited by Jochen on 12-20-2006 05:46 PM
12-20-2006 11:39 AM
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.
12-21-2006 06:43 AM
01-05-2007 05:31 AM
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.
01-05-2007 06:19 AM
01-05-2007 11:07 AM