This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Last revision Both sides next revision | ||
cubloc:steppulse:index [2019/12/11 08:38] COMFILE Technology |
cubloc:steppulse:index [2023/12/11 16:03] COMFILE Technology [StepPulse] |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== StepPulse ====== | ||
+ | ''StepPulse channel, port, freq, qty'' | ||
+ | | //channel// | StepPulse channel (StepAccel supports only 0) | | ||
+ | | //port// | Output port | | ||
+ | | //freq// | Output frequency (Up to 15000) | | ||
+ | | //qty// | # of pulses to output (up to 2147483647) | | ||
+ | |||
+ | This command outputs a set number of pulses at a set frequency (up to | ||
+ | 15kHz). [[:cubloc:freqout:|FreqOut]] and [[:cubloc:pwm:|Pwm]] can also output pulses, but the number of pulses | ||
+ | cannot be controlled and only the dedicated PWM ports can be used. With | ||
+ | ''StepPulse'', any output port can be used, and the number of pulses and | ||
+ | pulse frequency can be controlled. | ||
+ | |||
+ | Depending on the Cubloc module used, the number of available channels | ||
+ | may change. Please refer to the following table for module specific | ||
+ | information. | ||
+ | |||
+ | ^Module ^Channels ^Channel ^PWM Channels that cannot be used during use of the command^ | ||
+ | |CB2XX, CB3XX, CT1721C| 1 |0 |Channel 0: PWM 3, 4, 5| | ||
+ | |CB400, CB405, CB405RT | 2 |0 or 1 |Channel 0: PWM 3, 4, 5 \\ Channel 1: PWM 6, 7, 8| | ||
+ | |||
+ | ''StepPulse'' uses the Cubloc processor’s PWM counters. When using this | ||
+ | command, PWM3, PWM4, and PWM5 cannot be used. | ||
+ | |||
+ | For the CB400/CB405/CB405RT, when using channel 1, PWM6, PWM7, and PWM8 | ||
+ | cannot be used. With the CB2XX and CB3XX series, only channel 0 may be used. With | ||
+ | the the CB400/CB405/CB405RT, StepPulse can be used on 2 different channels | ||
+ | simultaneously. | ||
+ | |||
+ | You can use any of the available I/O ports on the Cubloc. When the | ||
+ | ''StepPulse'' command is executed, the specified port's I/O mode is | ||
+ | automatically set to output. Even after the command has finished | ||
+ | generating pulses, the port's I/O mode remains output. | ||
+ | |||
+ | The output frequency can be set from 1hz to 15kHz. | ||
+ | |||
+ | This command will run in the background independently, so system | ||
+ | resources can be used for other tasks. | ||
+ | |||
+ | ''StepPulse'' should not be used simultaneously with ''StepAccel'' command. | ||
+ | |||
+ | ===== Example ===== | ||
+ | |||
+ | <code xbasic> | ||
+ | Const Device = CB280 | ||
+ | Do | ||
+ | Do While In(0) = 1 | ||
+ | Loop | ||
+ | StepPulse 0, 5, 5000, 300 | ||
+ | Do While In(0) = 0 | ||
+ | Loop | ||
+ | Loop | ||
+ | </code> | ||
+ | |||
+ | When the port 0 switch is pressed, port 5 will output 300 pulses at the | ||
+ | speed of 5kHz. The following is a circuit diagram for the code above: | ||
+ | |||
+ | {{ :cubloc:steppulse:steppulse.png?nolink |}} | ||
+ | |||
+ | A stepper motor controller can be created using a stepper motor and | ||
+ | stepper motor driver as shown below. | ||
+ | |||
+ | {{ :cubloc:steppulse:steppermotor.png?nolink |}} | ||
+ | |||
+ | Connect 3 Cubloc I/O ports to the stepper motor driver. The DISABLE and | ||
+ | DIRECTION pins are only to enable and set the direction of the stepper | ||
+ | motor. | ||
+ | Please refer to your stepper motor specifications for how many pulses are | ||
+ | required to move the stepper motor one rotation. | ||
+ | |||
+ | [[cubloc:index#system_library:|Go CUBLOC home]] |