04-14-2022 04:29 AM
Good morning,
I'm working with a USB 6343 with Python3 and nidaqmx lib.
I want to control a continuous motor and is it correct to control it's speed, rotation direction and of/off like that ?
(I can set its speed from 0 to 10V)
Now i've got a second question, i want to control another type of motor which can be controlled with sinus waves.
I can set its frequency and amplitude by sending it a sin waves with frequency/amplitude as paramters.
I want it to have to following behaviour:
i send it a sin waves, and it keep the parameters untill i decided to send another to sin wave.
Do you have some clues to help me ?
Thank's a lot !
04-15-2022 02:55 AM
Hi, sorry for posting again but i've find a partial solution:
import nidaqmx
import numpy as np
import time
from nidaqmx.constants import AcquisitionType, TaskMode
Fs = 8000
f = 300
sample = 8000
x = np.arange(sample)
y = np.sin(2 * np.pi * f * x / Fs)
with nidaqmx.Task() as task:
task.ao_channels.add_ao_voltage_chan('Dev1/ao1')
task.timing.cfg_samp_clk_timing(8000,sample_mode=AcquisitionType.CONTINUOUS)
print('Generation is started')
task.write(y)
task.control(TaskMode.TASK_COMMIT)
task.start()
while True:
print("Generating")
time.sleep(1)
This solution is okay, it's working fine.
I've got two questions about it:
I can change the frequency by changing the "f" var.
How can i change the amplitude ?
And why Fs / sample should be setted to 8000 is it for precision ? I can change those values but the comportment of my motor is'nt the same can someone explain me why ?
Thank's a lot !