User Tools

Site Tools




Compare channel, target#, port, targetState

channel High-speed counter channel
target# Target # of pulses (CH0: 0 to 65535, CH1: 0 to 255)
port Output port (DO NOT USE input-only ports)
targetState Target output port state

When the high-speed counter value reaches a set target point (target#), the processor will set an I/O Port to logic low or logic high.

If targetState is set to 1 and the target number of pulses (target#) have been received, the output port (port) will output logic high. Likewise, if the targetState is set to 0 and the target number of pulses (target#) have been received, the output port(port) will output logic low.

Channel Compare Range
HCOUNT Channel 0 0 to 65535
HCOUNT Channel 1 0 to 255

The high-speed counter itself supports up to 32-bits, but the Compare is limited since this command was designed to not affect the overall multitasking of Cubloc's main processor. Note: For channel 0, please use the Set Count0 On command before using Compare.

Dim i As Integer
Set Count0 On
compare 0,10,61,1
  i = Count (0)
  Debug Goxy,0,0,dec4 i,Cr
  Delay 100

The above uses high-speed counter channel 0 with a target of 10 pulses. When the counter value becomes 11, the output port (port 61) will output logic high.

Go CUBLOC home

cubloc/compare/index.txt · Last modified: 2016/04/14 11:07 (external edit)