The RMP Motion Controller APIs
UserLimit.cs
1
85using RSI.RapidCode.dotNET; // Import our RapidCode Library.
86using NUnit.Framework;
87using System;
88
89#if DOXYGEN // RSI internal documentation use only
90using RSI.RapidCode;
91#endif
92
94[TestFixture]
95[Category("Software")]
96public class UserLimit : StaticMemoryTestBase
97 {
98 //[Test, Timeout(Constants.MAX_TEST_TIME)]
99 [Test]
100 public void UserLimitDigitalInputOneCondition()
101 {
103 // Constants
104 const int INPUT_INDEX = 0; // This is the index of the digital input you will use to trigger the user limit.
105 const int OUTPUT_INDEX = 1; // This is the index of the digital output that will go active when the user limit triggers.
106
107 controller.AxisCountSet(1); // The number of user limits must not be greater than the number of axis and must be set before the number of user limits
108 controller.UserLimitCountSet(1); // Set the amount of UserLimits that you want to use. (every connected axis will automatically get 1 user limit)
109 controller.InterruptEnableSet(true); // Enable User Limit Interrupts. (When a user limit input comparison is met, and interrupt is triggered)
110
111 UInt64 userBufferAddress = controller.AddressGet(RSIControllerAddressType.RSIControllerAddressTypeUSER_BUFFER, 0); // Grabing an memory address to store a simulated IO point.
112
113 //Instead of using physical IO we will use simulated IO using a memory address as simulated IO. See the IO sample apps to see how to use a physical IO instead.
114 IOPoint input0 = IOPoint.CreateDigitalInput(controller, userBufferAddress, INPUT_INDEX); // Create a simulated IOpoint using userBuffer memory.
115 IOPoint output0 = IOPoint.CreateDigitalOutput(controller, userBufferAddress, OUTPUT_INDEX); // Create IOPoint object. Can be used to automatically get the address of a specified node and input index
116
119
120 //-------- PARAMETERS FOR UserLimitConditionSet --------
121 int userLimitNumber = 0; // Specify which user limit to use.
122 int condition = 0; // Specify which condition to use (0 or 1) ("0" to compare 1 input || "1" to compare 2 inputs)
123 RSIUserLimitLogic logic = RSIUserLimitLogic.RSIUserLimitLogicEQ; // Logic for input value comparison.
124 UInt64 inputAddress = input0.AddressGet(); // Use IOPoint or manually set using controller.NetworkInputAddressGet(INPUT_INDEX); for Beckhoff 10 was the index of 1st input. (To check your IO indexes go to RapidSetup -.
125
126 uint test = (uint)input0.MaskGet();
127 uint inputMask = (uint)input0.MaskGet(); // Get the appropriate mask from your IOpoint. OR use 0x00010000 for AKD General IO, 1 for Beckhoff IO Terminals
128 uint limtValue = (uint)input0.MaskGet(); // Get the appropriate mask from your IOpoint. OR use 0x00010000 for AKD General IO, 1 for Beckhoff IO Terminals
129
130 // [1] Configure the input's trigger condition.
131 controller.UserLimitConditionSet(userLimitNumber,// (User Limit Index) - Specify which user limit to use
132 condition, // (Condition Number) - Specify how many inputs you want to compare.
133 logic, // (Comparison Logic) - Specify the how the input value(s) will be compared
134 inputAddress, // (Input Address) - Specify the address of the input that will be compared.
135 inputMask, // (Input Mask) - Specify the bits in an address which need to be used when comparing inputs.
136 limtValue); // (Limit Value) - Specify the value to be compared with.
137
138 //-------- PARAMETERS FOR UserLimitConfigSet --------
139 RSIUserLimitTriggerType triggerType = RSIUserLimitTriggerType.RSIUserLimitTriggerTypeSINGLE_CONDITION;
140 RSIAction action = RSIAction.RSIActionNONE;
141 int axisNumber = 0;
142 int duration = 0;
143
144 // [2] Configure and Enable the user limit.
145 controller.UserLimitConfigSet(userLimitNumber,// (User Limit Index) - Specify which user limit to use.
146 triggerType, // (Trigger Type) - Specify how your condition should be evalutated.
147 action, // (User Limit Action) - Specify the action you want to cause on the axis when the user limit triggers.
148 axisNumber, // (Current Axis) - Specify the axis that the action (defined above) will occur on.
149 duration); // (Output Timer) - Specify the time delay before the action is executed after the User Limit has triggered.
150
151
152 //-------- PARAMETERS FOR UserLimitOutputSet --------
153 uint andMask = (uint)output0.MaskGet(); // Get the appropriate mask from your IOpoint. OR use 0x00010000 for AKD General IO, 1 for Beckhoff IO Terminals
154 uint orMask = (uint)output0.MaskGet(); // Get the appropriate mask from your IOpoint. OR use 0x00010000 for AKD General IO, 1 for Beckhoff IO Terminals
155 UInt64 outputAddress = output0.AddressGet(); //Alternatively set manually using: controller.NetworkOutputAddressGet(OUTPUT_INDEX);
156 bool enableOutput = true;
157
158 // [3] Configure what the output will be. (Call this method after UserLimitConfigSet if you want an output to be triggered) (The output will only be triggered if the input conditions are TRUE.)
159 controller.UserLimitOutputSet(userLimitNumber,// (User Limit Index) - Specify which user limit to use.
160 andMask, // (Logic AND Mask) - Specify the value that the digital output will be AND-ed with.
161 orMask, // (Logic OR Mask) - Specify the value that the digital output will be OR-ed with.
162 outputAddress, // (Output Address) - Specify the digital output address.
163 enableOutput); // (Enable Output Set) - If TRUE, the output AND-ing and OR-ing will be executed when the User Limit triggers.
164
165 while (controller.InterruptWait(250) != RSIEventType.RSIEventTypeUSER_LIMIT) // Loop will execute every 250 ms
166 {
168 Assert.False(output0.Get(), "We expect the output to NOT be triggered");
169
171 controller.MemorySet(input0.AddressGet(), 1);
172 }
173
175 Assert.True(output0.Get(), "We expect the output to be triggered");
176
177 controller.UserLimitDisable(userLimitNumber); // Disable User Limit.
178 output0.Set(false); // Disable User Limit.
180 }
181
182 [Test]
183 public void UserLimitDigitalInputTwoCondition()
184 {
186 // Constants
187 const int INPUT_INDEX0 = 0; // This is the index of the digital input you will use to trigger the user limit.
188 const int INPUT_INDEX1 = 1; // This is the index of the digital input you will use to trigger the user limit.
189 const int OUTPUT_INDEX = 2; // This is the index of the digital output that will go active when the user limit triggers.
190
191 controller.AxisCountSet(1); // The number of user limits must not be greater than the number of axis and must be set before the number of user limits
192 controller.UserLimitCountSet(1); // Set the amount of UserLimits that you want to use. (every connected axis will automatically get 1 user limit)
193 controller.InterruptEnableSet(true); // Enable User Limit Interrupts. (When a user limit input comparison is met, and interrupt is triggered)
194
195 //-------- PARAMETERS FOR 1st and 2nd UserLimitConditionSet --------
196 int userLimitNumber = 0; // Specify which user limit to use.
197 RSIUserLimitLogic logic = RSIUserLimitLogic.RSIUserLimitLogicEQ; // Logic for input value comparison.
198
199 UInt64 userBufferAddress = controller.AddressGet(RSIControllerAddressType.RSIControllerAddressTypeUSER_BUFFER, 0); // Grabing an memory address to store a simulated IO point.
200
201 //Instead of using physical IO we will use simulated IO using a memory address as simulated IO. See the IO sample apps to see how to use a physical IO instead.
202 IOPoint input0 = IOPoint.CreateDigitalInput(controller, userBufferAddress, INPUT_INDEX0); // Create IOPoint object. Can be used to automatically get the address of a specified node and input index
203 IOPoint input1 = IOPoint.CreateDigitalInput(controller, userBufferAddress, INPUT_INDEX1); // Create IOPoint object. Can be used to automatically get the address of a specified node and input index
204 IOPoint output0 = IOPoint.CreateDigitalOutput(controller, userBufferAddress, OUTPUT_INDEX); // Create IOPoint object. Can be used to automatically get the address of a specified node and input index
205
209
210 int condition0 = 0; // Specify which condition to use (0 or 1) ("0" to compare 1 input || "1" to compare 2 inputs)
211 UInt64 input0Address = input0.AddressGet(); // 10 was the index of my 1st input. (To check your IO indexes go to RapidSetup -.
212
213 uint input0Mask = (uint)input0.MaskGet();
214 uint limitValue0 = (uint)input0.MaskGet();
215
216 int condition1 = 1; // Specify which condition to use (0 or 1) ("0" to compare 1 input || "1" to compare 2 inputs)
217 UInt64 input1Address = input1.AddressGet(); // 11 was the index of my 2nd input. (To check your IO indexes go to RapidSetup -.
218
219 uint input1Mask = (uint)input1.MaskGet();
220 uint limitValue1 = (uint)input1.MaskGet();
221
222 // [1] Configure the 1st input's trigger condition. (condition 1)
223 controller.UserLimitConditionSet(userLimitNumber, // (User Limit Index) - Specify which user limit to use
224 condition0, // (Condition Number) - Specify how many inputs you want to compare.
225 logic, // (Comparison Logic) - Specify the how the input value(s) will be compared
226 input0Address, // (Input Address) - Specify the address of the input that will be compared.
227 input0Mask, // (Input Mask) - Specify the bits in an address which need to be used when comparing inputs.
228 limitValue0); // (Limit Value) - Specify the value to be compared with.
229
230 // [2] Configure the 2nd input's trigger condition. (condition 2)
231 controller.UserLimitConditionSet(userLimitNumber, // (User Limit Index) - Specify which user limit to use
232 condition1, // (Condition Number) - Specify how many inputs you want to compare.
233 logic, // (Comparison Logic) - Specify the how the input value(s) will be compared
234 input1Address, // (Input Address) - Specify the address of the input that will be compared.
235 input1Mask, // (Input Mask) - Specify the bits in an address which need to be used when comparing inputs.
236 limitValue1); // (Limit Value) - Specify the value to be compared with.
237
238 //-------- PARAMETERS FOR UserLimitConfigSet --------
239 RSIUserLimitTriggerType triggerType = RSIUserLimitTriggerType.RSIUserLimitTriggerTypeCONDITION_AND;
240 RSIAction action = RSIAction.RSIActionNONE;
241 int axis = 0;
242 int duration = 0;
243
244 // [3] Configure and Enable the user limit.
245 controller.UserLimitConfigSet(userLimitNumber, // (User Limit Index) - Specify which user limit to use.
246 triggerType, // (Trigger Type) - Specify how your condition should be evalutated.
247 action, // (User Limit Action) - Specify the action you want to cause on the axis when the user limit triggers.
248 axis, // (Current Axis) - Specify the axis that the action (defined above) will occur on.
249 duration); // (Output Timer) - Specify the time delay before the action is executed after the User Limit has triggered.
250
251 //-------- PARAMETERS FOR UserLimitOutputSet --------
252 uint andMask = (uint)output0.MaskGet();
253 uint orMask = (uint)output0.MaskGet();
254 UInt64 outputAddress = output0.AddressGet();
255 bool enableOutput = true;
256
257 // [4] Configure what the output will be. (Call this method after UserLimitConfigSet if you want an output to be triggered) (The output will only be triggered if the input conditions are TRUE.)
258 controller.UserLimitOutputSet(userLimitNumber, // (User Limit Index) - Specify which user limit to use.
259 andMask, // (Logic AND Mask) - Specify the value that the digital output will be AND-ed with.
260 orMask, // (Logic OR Mask) - Specify the value that the digital output will be OR-ed with.
261 outputAddress, // (Output Address) - Specify the digital output address.
262 enableOutput); // (Enable Output Set) - If TRUE, the output AND-ing and OR-ing will be executed when the User Limit triggers.
263
264 while (controller.InterruptWait(250) != RSIEventType.RSIEventTypeUSER_LIMIT) // Wait for user limit to trigger. Loop will execute every 250 ms
265 {
267 Assert.False(output0.Get(), "We expect the output to NOT be triggered");
268 controller.MemorySet(input0.AddressGet(), 1); // Set bit 0 high.
269 Assert.False(output0.Get(), "We expect the output to NOT be triggered");
270 controller.MemorySet(input0.AddressGet(), 2); // Set bit 1 high.
271 Assert.False(output0.Get(), "We expect the output to NOT be triggered");
272 //---TRIGGER---
273 controller.MemorySet(input0.AddressGet(), 3); // Set bits 0 and 1 high.
274 }
276
278 Assert.True(output0.Get(), "We expect the output to be triggered");
279 }
280
281 [Test]
282 public void UserLimitDigitalInputEStopStorePosition()
283 {
285 // Constants
286 const int AXIS_INDEX = 0; // This is the index of the axis you will use to command motion.
287 const int INPUT_INDEX = 0;
288 const int AXIS_COUNT = 1; // Axes on the network.
289 const int USER_LIMIT = 0; // Specify which user limit to use.
290 const int CONDITION = 0; // Specify which condition to use. (0 or 1) ("0" to compare 1 input || "1" to compare 2 inputs)
291 const RSIUserLimitLogic LOGIC = RSIUserLimitLogic.RSIUserLimitLogicEQ; // Logic for input value comparison.
292 const int LIMIT_VALUE = 1; // The value to be compared which needs to be set here.
293 const RSIUserLimitTriggerType TRIGGER_TYPE = RSIUserLimitTriggerType.RSIUserLimitTriggerTypeSINGLE_CONDITION; // Choose the how the condition (s) should be evaluated.
294 const RSIAction ACTION = RSIAction.RSIActionE_STOP_ABORT; // Choose the action you want to cause when the User Limit triggers.
295 const double DURATION = 0.125; // Enter the time delay before the action is executed after the User Limit has triggered.
296 const int USER_DATA_INDEX = 0;
297
298 // Some Necessary Pre User Limit Configuration
299 controller.AxisCountSet(1);
300 controller.UserLimitCountSet(1); // Set the amount of UserLimits that you want to use.
301 controller.InterruptEnableSet(true); // Enable User Limit Interrupts. (When a user limit input comparison is met, and interrupt is triggered)
302
303 UInt64 userBufferAddress = controller.AddressGet(RSIControllerAddressType.RSIControllerAddressTypeUSER_BUFFER, 0); // Grabing an memory address to store a simulated IO point.
304
305 //Instead of using physical IO we will use simulated IO using a memory address as simulated IO. See the IO sample apps to see how to use a physical IO instead.
306 IOPoint input0 = IOPoint.CreateDigitalInput(controller, userBufferAddress, INPUT_INDEX); // Create IOPoint object. Can be used to automatically get the address of a specified node and input index
307
308 axis = CreateAndReadyAxis(Constants.AXIS_NUMBER); // Initialize your axis object.
309
310 axis.MoveVelocity(10.0, 20.0); // Command a velocity move (Velocity=1.0, Acceleration=10.0).
311
312 // USER LIMIT CONDITION
313 controller.UserLimitConditionSet(USER_LIMIT, CONDITION, LOGIC, input0.AddressGet(), (uint)input0.MaskGet(), LIMIT_VALUE); // Set your User Limit Condition (1st step to setting up your user limit)
314
315 // USER LIMIT CONFIGURATION
316 controller.UserLimitConfigSet(USER_LIMIT, TRIGGER_TYPE, ACTION, AXIS_INDEX, DURATION); // Set your User Limit Configuration. (2nd step to setting up your user limit)
317
318 // USER LIMIT USER DATA SET
319 controller.UserLimitInterruptUserDataAddressSet(USER_LIMIT, // Specify the user limit you want to add User Data for.
320 USER_DATA_INDEX, // Specify what user data index you would like to use. (must be a value from 0 to 4)
321 axis.AddressGet(RSIAxisAddressType.RSIAxisAddressTypeCOMMAND_POSITION)); // Specify the address of the data value you want to store in your User Data so that you can retrieve it later after the UserLimit limit triggers.
322
323 // WAIT FOR DIGITAL INPUT TO TRIGGER USER LIMIT EVENT.
324 while (controller.InterruptWait(250) != RSIEventType.RSIEventTypeUSER_LIMIT) // Wait until your user limit triggers.
325 {
327 controller.MemorySet(input0.AddressGet(), 1);
328 }
329
330 int triggeredUserLimit = controller.InterruptSourceNumberGet() - AXIS_COUNT; // Check that the correct user limit has triggered. (an extra user limit is allocated for each axis)
331 double interruptPosition = controller.InterruptUserDataDoubleGet(USER_DATA_INDEX); // Get the data stored in the interrupt's user data you configured.
332
333 Console.WriteLine("TRIGGERED - User Limit Interrupt Position = " + interruptPosition / axis.UserUnitsGet()); // Get the position of the axis when it user limit event triggered.
334
335 controller.UserLimitDisable(USER_LIMIT);
337 }
338
339 [Test]
340 public void UserLimitFeedRate()
341 {
343 // Constants
344 const int USER_LIMIT = 0; // Specify which user limit to use.
345 const int USER_LIMIT_COUNT = 1;
346 const int AXIS_COUNT = 1;
347 const int CONDITION = 0; // Specify which condition to use. (0 or 1) ("0" to compare 1 input || "1" to compare 2 inputs)
348 const RSIUserLimitLogic LOGIC = RSIUserLimitLogic.RSIUserLimitLogicGT; // Logic for input value comparison.
349 const double POSITION_TRIGGER_VALUE = 5; // The value to be compared which needs to be set here.
350 const RSIUserLimitTriggerType TRIGGER_TYPE = RSIUserLimitTriggerType.RSIUserLimitTriggerTypeSINGLE_CONDITION; // Choose the how the condition (s) should be evaluated.
351 const RSIAction ACTION = RSIAction.RSIActionNONE; // Choose the action you want to cause when the User Limit triggers.
352 const int DURATION = 0; // Enter the time delay before the action is executed after the User Limit has triggered.
353 const double DEFAULT_FEED_RATE = 1.0;
354 const double DESIRED_FEED_RATE = 2.0;
355
356 // Other Global Variables
357 UInt64 feedRateAddress;
358
359 // Some Necessary Pre User Limit Configuration
360 controller.AxisCountSet(AXIS_COUNT); // The number of user limits must not be greater than the number of axis and must be set before the number of user limits
361 controller.UserLimitCountSet(USER_LIMIT_COUNT); // Set the amount of UserLimits that you want to use.
362
363 axis = CreateAndReadyAxis(Constants.AXIS_NUMBER); // Initialize your axis object.
364
365 axis.FeedRateSet(DEFAULT_FEED_RATE); // Restore FeedRate to default value.
366
367 // USER LIMIT CONDITION
368 // We will use command position because we are working with a phantom axis. Actual position can be used for real axis.
369 controller.UserLimitConditionSet(USER_LIMIT, CONDITION, LOGIC, axis.AddressGet(RSIAxisAddressType.RSIAxisAddressTypeCOMMAND_POSITION), POSITION_TRIGGER_VALUE); // Set your User Limit Condition (1st step to setting up your user limit)
370
371 // USER LIMIT CONFIGURATION
372 controller.UserLimitConfigSet(USER_LIMIT, TRIGGER_TYPE, ACTION, axis.NumberGet(), DURATION); // Set your User Limit Configuration. (2nd step to setting up your user limit)
373
374 // USER LIMIT OUTPUT
375 feedRateAddress = axis.AddressGet(RSIAxisAddressType.RSIAxisAddressTypeTARGET_FEEDRATE);
376 controller.UserLimitOutputSet(USER_LIMIT, DESIRED_FEED_RATE, feedRateAddress, true);
378
380 Assert.AreEqual(DEFAULT_FEED_RATE, axis.FeedRateGet(), "We expect the feedrate to be default");
381 axis.MoveSCurve(POSITION_TRIGGER_VALUE + 1);
382 axis.MotionDoneWait();
383 Assert.AreEqual(DESIRED_FEED_RATE, axis.FeedRateGet(), "We expect the feedrate to be changed");
384 }
385
386 [Test]
387 public void UserLimitPositionOneCondition()
388 {
390 // Constants
391 const int AXIS_COUNT = 1;
392 const int USER_LIMIT_COUNT = 1;
393 const int USER_LIMIT_NUMBER = 0;
394 const double TRIGGER_POSITION = 0.05; // Specify the position where the user limit will trigger.
395 const double MOVE_POSITION = 1.0; // We'll move to this position, which must be past the trigger position.
396 const int OUTPUT_INDEX = 1; // This is the index of the digital output that will go active when the user limit triggers.
397 const int WAIT_FOR_TRIGGER_MILLISECONDS = 100; // we'll wait for the UserLimit interrupt for this long before giving up.
398
399 // Some Necessary Pre User Limit Configuration
400 controller.AxisCountSet(AXIS_COUNT); // The number of user limits must not be greater than the number of axis and must be set before the number of user limits
401 controller.UserLimitCountSet(USER_LIMIT_COUNT); // Set the amount of UserLimits that you want to use. (every connected axis will automatically get 1 user limit)
402 controller.InterruptEnableSet(true); // Enable User Limit Interrupts. (When a user limit input comparison is met, and interrupt is triggered)
403
404 UInt64 userBufferAddress = controller.AddressGet(RSIControllerAddressType.RSIControllerAddressTypeUSER_BUFFER, 0); // Grabbing a memory address to make a simulated IO point.
405 IOPoint output0 = IOPoint.CreateDigitalOutput(controller, userBufferAddress, OUTPUT_INDEX); // Create IOPoint object. Can be used to automatically get the address of a specified node and input index
406 output0.Set(false); // be sure we are starting with a value of 0 aka off
407
408 axis = CreateAndReadyAxis(Constants.AXIS_NUMBER); // Initialize your axis object.
409
410 //-------- PARAMETERS FOR UserLimitConditionSet -------- // Specify which user limit to use.
411 int condition = 0; // Specify which condition to use (0 or 1) ("0" to compare 1 input || "1" to compare 2 inputs)
412 double limitValue = TRIGGER_POSITION; // The limit value will be in counts so we multiply our desired position by USER_UNITS
413
414 controller.UserLimitConditionSet(USER_LIMIT_NUMBER, // (User Limit Index) - Specify which user limit to use
415 condition, // (Condition Number) - Specify how many inputs you want to compare.
416 RSIUserLimitLogic.RSIUserLimitLogicGT, // (Comparison Logic) - Specify the how the input value(s) will be compared
417 axis.AddressGet(RSIAxisAddressType.RSIAxisAddressTypeCOMMAND_POSITION),// (Input Address) - Specify the address of the input that will be compared. // FOR A REAL AXIS USE ACTUAL POSITION
418 limitValue); // (Limit Value) - Specify the value to be compared with.
419
420 //-------- PARAMETERS FOR UserLimitConfigSet --------
421 RSIUserLimitTriggerType triggerType = RSIUserLimitTriggerType.RSIUserLimitTriggerTypeSINGLE_CONDITION;
422 RSIAction action = RSIAction.RSIActionABORT; // Abort move when user limit triggers.
423 int duration = 0;
424
425 // [2] Configure and Enable the user limit.
426 controller.UserLimitConfigSet(USER_LIMIT_NUMBER, // (User Limit Index) - Specify which user limit to use.
427 triggerType, // (Trigger Type) - Specify how your condition should be evalutated.
428 action, // (User Limit Action) - Specify the action you want to cause on the axis when the user limit triggers.
429 axis.NumberGet(), // (Current Axis) - Specify the axis that the action (defined above) will occur on.
430 duration); // (Output Timer) - Specify the time delay before the action is executed after the User Limit has triggered.
431
432 //-------- PARAMETERS FOR UserLimitOutputSet --------
433 uint andMask = (uint)output0.MaskGet(); // Get the appropriate mask from your IOpoint. OR use 0x00010000 for AKD General IO, 1 for Beckhoff IO Terminals
434 uint orMask = (uint)output0.MaskGet(); ; // Get the appropriate mask from your IOpoint. OR use 0x00010000 for AKD General IO, 1 for Beckhoff IO Terminals
435 UInt64 outputAddress = output0.AddressGet(); //Alternatively set manually using: controller.NetworkOutputAddressGet(OUTPUT_INDEX);
436 bool enableOutput = true;
437
438 // [3] Configure what the output will be. (Call this method after UserLimitConfigSet if you want an output to be triggered) (The output will only be triggered if the input conditions are TRUE.)
439 controller.UserLimitOutputSet(USER_LIMIT_NUMBER, // (User Limit Index) - Specify which user limit to use.
440 andMask, // (Logic AND Mask) - Specify the value that the digital output will be AND-ed with.
441 orMask, // (Logic OR Mask) - Specify the value that the digital output will be OR-ed with.
442 outputAddress, // (Output Address) - Specify the digital output address.
443 enableOutput); // (Enable Output Set) - If TRUE, the output AND-ing and OR-ing will be executed when the User Limit triggers.
444
445 Assert.False(output0.Get(), "We expect the output to NOT be triggered");
446
447 // TRIGGER
448 axis.MoveSCurve(MOVE_POSITION); // Command simple motion past the trigger position.
449
450 RSIEventType interruptType = controller.InterruptWait(WAIT_FOR_TRIGGER_MILLISECONDS);
451
452 if (interruptType == RSIEventType.RSIEventTypeUSER_LIMIT)
453 {
454 // note - the object number returned for USER_LIMIT interrupts is raw an unscaled and we must add the controller's AxisCount since internally
455 // there is one UserLimit allocated per Axis
456 Assert.That(controller.InterruptSourceNumberGet(), Is.EqualTo(USER_LIMIT_NUMBER + AXIS_COUNT), "We got a USER_LIMIT interrupt but it was the wrong one.");
457 Assert.True(output0.Get(), "We expect the output to be turned on when the user limit triggers.");
458 }
459 else
460 {
461 Assert.Fail("We expected a USER_LIMIT interrupt when the trigger position was exceeded but instead got " + interruptType.ToString());
462 }
463
464 axis.AmpEnableSet(false); // Disable the motor.
465 controller.UserLimitDisable(USER_LIMIT_NUMBER); // Disable User Limit.
466 output0.Set(false); // Set output low so program can run again
468 }
469 }
static void CheckErrors(RapidCodeObject rsiObject)
Check if the RapidCodeObject has any errors.
Helper Functions for checking logged creation errors, starting the network, etc.
uint64_t AddressGet()
Get the Host Address for the I/O point.
void Set(bool state)
Set the state of a Digital Output.
static IOPoint * CreateDigitalInput(Axis *axis, RSIMotorDedicatedIn motorDedicatedInNumber)
Create a Digital Input from an Axis' Dedicated Input bits.
static IOPoint * CreateDigitalOutput(Axis *axis, RSIMotorDedicatedOut motorDedicatedOutNumber)
Create a Digital Output from an Axis' Dedicated Output bits.
bool Get()
Get the state of Digital Input or Output.
int32_t MaskGet()
Get the bit mask for the I/O point.
Represents one specific point: Digital Output, Digital Input, Analog Output, or Analog Input....
Definition rsi.h:11319
void UserLimitDisable(int32_t number)
Disable the processing of a User Limit.
void UserLimitConditionSet(int32_t number, int32_t conditionNumber, RSIUserLimitLogic logic, uint64_t addressOfUInt32, uint32_t userLimitMask, uint32_t limitValueUInt32)
Set the conditions for a User Limit with a 32-bit integer trigger value.
void MemorySet(uint64_t address, int32_t data)
Write a value to controller memory.
uint64_t AddressGet(RSIControllerAddressType type)
Get the an address for some location on the MotionController.
void UserLimitOutputSet(int32_t number, uint32_t andMask, uint32_t orMask, uint64_t outputPtr, bool enabled)
Configure a User Limit Output block.
void UserLimitInterruptUserDataAddressSet(int32_t number, uint32_t userDataIndex, uint64_t address)
Set the User Data address based on a User Limit trigger.
void UserLimitConfigSet(int32_t number, RSIUserLimitTriggerType triggerType, RSIAction action, int32_t actionAxis, double duration, bool singleShot)
Configure a User Limit.
void UserLimitCountSet(int32_t userLimitCount)
Set the number of processed UserLimits in the MotionController.
void InterruptEnableSet(bool enable)
Control interrupts for this class.
void AxisCountSet(int32_t axisCount)
Set the number of allocated and processed axes in the controller.
double InterruptUserDataDoubleGet(uint32_t userDataIndex)
Get the user data associated with the interrupt, as a 64-bit double.
int32_t InterruptSourceNumberGet()
Get the number (or index) of the object (Axis, Motor, etc) that generated the interrupt.
RSIEventType InterruptWait(int32_t milliseconds)
Suspend the current thread until an interrupt arrives from the controller.
RSIControllerAddressType
Used to get firmware address used in User Limits, Sequencers, etc.
Definition rsienums.h:404
RSIEventType
Event Types or Status Bits.
Definition rsienums.h:911
RSIUserLimitLogic
Logic options for User Limits.
Definition rsienums.h:631
RSIAction
Action to perform on an Axis.
Definition rsienums.h:1051
RSIAxisAddressType
Used to get firmware address used in User Limits, Sequencers, etc.
Definition rsienums.h:425
RSIUserLimitTriggerType
Trigger types for UserLimits.
Definition rsienums.h:618