Function
Sets count match event callback function.
Format
Ret = SmcWCountEvent( Id , AxisNo , CallBack , EventMode , CountType, Count , Parameter )
Parameters
Id [ C, C++: short ] [ Python: ctypes.c_short ]
Specify the device ID retrieved by SmcWInit function.
AxisNo [ C, C++: short ] [ Python: ctypes.c_short ]
Specify axis number.
CallBack [ C, C++: PSMC_COUNT_CALLBACK ] [ Python: PSMC_COUNT_CALLBACK ]
Specify the address of the
callback function.
If NULL is specified, the notification setting by callback is cleared.
EventMode [ C, C++: short ] [ Python: ctypes.c_short ]
Set the event to valid/invalid.
0 |
Invalidate the event. |
1 |
Validate the event |
CountType [ C, C++: short ] [ Python: ctypes.c_short ]
Set the counter that does the count agreement.
0 |
Number of output pulses |
1 |
Number of encoders of count pulses |
Count [ C, C++: int ] [ Python: ctypes.c_int ]
Set the number of counts.
Range : -134217728 to 134217727
Parameter [ C, C++: void * ] [ Python: ctypes.c_void_p ]
Specify the parameter address
to pass to the callback.
Specify NULL if no parameter is required.
Return Value
Ret [ C, C++: long ] [ Python: ctypes.c_long ]
0 |
Terminated normally |
Non-zero |
Terminated abnormally |
See also: Error code details
Remarks
When the counter value reaches
the number of specified counts, the events occur.
If the event generation function is executed once, the event is generated
every time the factor is generated afterwards.
It is not necessary to execute it two or more times excluding the purpose
to stop the event.
When a count match occurs,
notify the application through a callback.
After setting the callback, when a count match occurs, the set callback
function is called.
In the SmcWSetCtrlTypeOut function, the count agreement can output the signal while the condition is consisting only as for the output signal that the counter count agreement signal setting is done.
-Therefore, the change in
the level is at a very fast pulse output and there is a possibility not
to be able to recognize as data in the output destination for the moment.
-The signal become like the state that the level changes when stopping
by the number of specified pulses.
-One shot pulse that specifies the width of the signal cannot be output.
There are two kinds of signals as follows.
-Output pulse counter count
agreement signal(CP1)
Set "0: the number of output pulses" to CountType and when the
output pulse number count agreement event is effective.
-Encoder counter count agreement
signal(CP2)
Set "1: the number of encoders of count pulses" to CountType
and when the encoder pulse number count agreement event is effective.
Example
The count agreement event when becoming number 500 of output pulses for axis number 1 is set.
C, C++
long Ret;
Ret = SmcWCountEvent( Id , 1 , CallBack , 1 , 0 , 500 , this );
Python
Ret = ctypes.c_long()
Ret.value = csmc.SmcWCountEvent( Id , 1 , CallBack , 1 , 0 , 500 , 0 )
See Also
Callback Function
Format
CallBack( Id , AxisNo , Message , Parameter )
Parameters
Id [ C, C++: short ] [ Python: ctypes.c_short ]
The ID retrieved by SmcWInit function is passed.
AxisNo [ C, C++: short ] [ Python: ctypes.c_short ]
The axis number that the event occurred is passed from the driver.
Message [ C, C++: int ] [ Python: ctypes.c_int ]
The message ID that cause the callback function to be called is passed .
Parameter [ C, C++: void * ] [ Python: ctypes.c_void_p ]
The parameter specified by the SmcWCountEvent is passed.
Return Value
None [ void ]