Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

NI 6343 multi analog out signal

Hello, 

 

I have to control 2 differents analog output. 

Thoses two output are used to control two motors. 

I have to change value of voltage at differents times. 

 

For example motor A voltage should be: 

 

- 1 during 4 seconds

- 2 during 3 seconds

- 3 during 5 seconds

- 4 during 7 seconds

- 5 during 1 seconds

 

Motor B should be :

 

- 5 during 2 seconds

- 4 during 2 seconds

- 3 during 8 seconds

- 2 during 3 seconds

- 1 during 5 seconds

 

I am using nidaqmx python lib, actually i'm able to control one motor, and changing the value of analog output with the following code: 

 

        with nidaqmx.Task() as task:
            task.ao_channels.add_ao_voltage_chan(port)  
            task.timing.cfg_samp_clk_timing(
                8000, sample_mode=AcquisitionType.CONTINUOUS
            )
            task.write(y[i])
            task.control(TaskMode.TASK_COMMIT)
            task.start()
        while timer:
            if time.time() - le_temps >= temps[i]:
                print("STOPPP")
                print(time.time() - le_temps)
                timer = False

 

This code works well, but when i try to use it in differents threads to run it simulteanously with above code: 

 

t1 = threading.Thread(
    target=moteurs.gestion_amplitude,
    args=[FREQUENCE_A, reglages_ampli_A, t, "Dev1/ao1"],
)
t2 = threading.Thread(
    target=moteurs.gestion_amplitude,
    args=[FREQUENCE_B, reglages_ampli_B, t, "Dev1/ao2"],
)
t1.start()
t2.start()
t1.join()
t2.join()

 

It doesn't work, i get an error: 

 

nidaqmx.errors.DaqWriteError: The specified resource is reserved. The operation could not be completed as specified.
Task Name: _unnamedTask<1>

Status Code: -50103

 

Does someone has an idea of how to do this in a correct way ?

Thank you for help !

0 Kudos
Message 1 of 1
(532 Views)