1

I am using a M series DAQ's two counter channel to generate pulse train to control two step motor, but these two channels are not fully independent, when one channel generate pulse, the other channel with change state too. In this link, it mentioned a way to use paule trigger to pause the other channel when one channel generating finite pulse. Link I tried to convert it to python code as below:

outputchannel = "Dev1/Ctr0"
gatechannel = "Dev1/Ctr1"
frequency = 1000
samples = 1000

def GenerateFinitePulse(outputchannel, gatechannel, pulsecount, frequency):
    with nidaqmx.Task() as pulse_task:
        pulsechannel = pulse_task.co_channels.add_co_pulse_chan_freq(
            counter=outputchannel,freq=frequency, duty_cycle=0.5)

        pulse_task.timing.cfg_implicit_timing(
            sample_mode=nidaqmx.constants.AcquisitionType.CONTINUOUS,
            samps_per_chan=1000)

        pulse_task.triggers.pause_trigger.trig_type = nidaqmx.constants.TriggerType.DIGITAL_LEVEL
        pulse_task.triggers.pause_trigger.dig_lvl_src = gatechannel + "InternalOutput"
        pulse_task.triggers.pause_trigger.dig_lvl_when = nidaqmx.constants.Level.LOW

        pulse_task.start()

        with nidaqmx.Task() as gate_task:
            gatechannel = gate_task.co_channels.add_co_pulse_chan_time(
                counter=gatechannel, low_time= 1, high_time= pulsecount/frequency)
            gatechannel.co_pulse_term = " "
            gate_task.start()

        time.sleep(10)

one question is that even set the co_pulse_term = " ", i still can get the pulse output from the channel from a oscilloscope. and here is an error I got:

nidaqmx.errors.DaqError: Source terminal to be routed could not be found on the device.

Make sure the terminal name is valid for the specified device. Refer to Measurement & Automation Explorer for valid terminal names. Property: DAQmx_DigLvl_PauseTrig_Src Property: DAQmx_DigLvl_PauseTrig_When Source Device: Dev1 Source Terminal: Dev1/Ctr1InternalOutput

somehow it can't find the "Internal output".

please help if anyone has experience. Thank you very much!

Forrest
  • 51
  • 1
  • 9

0 Answers0