APIs, concepts, guides, and more
SequencerDigitalOutput.cpp
1
2/* sequencerDigitalOutput.cpp
3
4 Copyright(c) 1998-2009 by Robotic Systems Integration, Inc. All rights reserved.
5 This software contains proprietary and confidential information of Robotic
6 Systems Integration, Inc. (RSI) and its suppliers. Except as may be set forth
7 in the license agreement under which this software is supplied, disclosure,
8 reproduction, or use with controls other than those provided by RSI or suppliers
9 for RSI is strictly prohibited without the prior express written consent of
10 Robotic Systems Integration.
11
12 This sample code presumes that the user has set the tuning paramters(PID, PIV, etc.)
13 prior to running this program so that the motor can rotate in a stable manner.
14
15 For any questions regarding this sample code please visit our documentation at www.roboticsys.com
16
17
18 Warning! This is a sample program to assist in the integration of your motion
19 controller with your application. It may not contain all of the logic and safety
20 features that your application requires.
21*/
22
23
24#include "rsi.h"
25
26#define SEQUENCER 0
27#define TRIGGERS 100
28#define BIT_MASK RSIControlIOMaskUSER0_OUT
29
30
31using namespace RSI::RapidCode::SynqNet;
32
33
34void sequencerDigitalOutputMain()
35{
36 try
37 {
38
39 MotionController *controller ;
40 Axis *axis ;
41 long controllerDigitalOutputAddr;
42 long axisActualPositionAddr;
43
44 // initialize RSI classes
45 controller = MotionController::CreateFromBoard(0);
46 axis = controller->AxisGet(0);
47
48 IOPoint *userOut;
49
50 //userOut->CreateDigitalOutput( controller,
51 // get the host controller address for the controller digital outputs
52 controllerDigitalOutputAddr = controller->AddressFromStringGet("SystemData.IO.HostOutput[0]", "c:\\mei\\xmp\\bin\\winnt\\stdmei.map");
53
54 // get the host controller adddress for the axis' actual position
55 axisActualPositionAddr = axis->AddressGet(RSIAxisAddressTypeACTUAL_POSITION);
56
57
58 controller->SequencerEnableSet(SEQUENCER, true);
59
60 // append trigger and I/O commands to Sequencer
61 for(int i = 0; i < TRIGGERS; i++)
62 {
63 // wait for Actual Poisition to be exceeded
64 controller->CommandWaitLong(SEQUENCER,
65 RSICommandOperatorGREATER_OR_EQUAL,
66 axisActualPositionAddr,
67 (i + 1) * 100 ); // incrementing the "trigger" position
68 // turn bit on
69 controller->CommandComputeLong(SEQUENCER,
70 RSICommandOperatorOR,
71 controllerDigitalOutputAddr, // input to computation
72 controllerDigitalOutputAddr, // output from computation written here
73 BIT_MASK );
74 // wait a while
75 controller->CommandDelay(SEQUENCER, 0.50); //seconds
76
77 // turn bit off
78 controller->CommandComputeLong(SEQUENCER,
79 RSICommandOperatorAND,
80 controllerDigitalOutputAddr, // input to computation
81 controllerDigitalOutputAddr, // output from computation
82 ~(BIT_MASK) );
83
84 }
85
86 controller->SequencerStart(0);
87
88 printf("press a key to stop and delete sequencer \n");
89 // start the motion on the axis here now
90 // wait for key press
91 while(controller->OS->KeyGet(RSIWaitPOLL) < 0)
92 {
93 controller->OS->Sleep(1);
94 }
95
96 controller->SequencerStop(0);
97 controller->SequencerEnableSet(0, false);
98
99 }
100 catch (RsiError *err)
101 {
102 printf("%s\n", err->text);
103 }
104}
Axis * AxisGet(int32_t axisNumber)
AxisGet returns a pointer to an Axis object and initializes its internals.
uint64_t AddressFromStringGet(const char *const addressName)
Get a controller memory address from string.
RapidCodeOS * OS
Provides access to operating system (Windows) features.
Definition rsi.h:3792
void Sleep(int32_t milliseconds)
Put the current thread to sleep.
int32_t KeyGet(int32_t milliseconds)
Wait for a key to be pressed and return its value.