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