06-04-2021 12:06 PM
Dear community,
for a laboratory application, I need to control a DC motor with a computer (on/off/direction of rotation/speed). I have an electric motor from an old stick blender, a NI myDAQ and a L298N H-Bridge motor driver at hand.
Unfortunately, I am not an engineer and I don't know how to wire the motor driver with the myDAQ (i.e. which screw terminals of the myDAQ I need to connect with which terminals of the L298N). Due to my ignorance in engineering, my question might lack essential information. I hope not to thereby offend anybody, please feel free to ask for details. Thank you in advance for your kind advice.
Esra
Solved! Go to Solution.
06-08-2021 08:36 PM
Hi Esra,
This isn't hard, I've done this before. The L298N driver is quite popular in the Arduino and maker community. The motor from your blender is most likely a DC motor.
You can then look at this guide: https://lastminuteengineers.com/l298n-dc-stepper-driver-arduino-tutorial/
Basically you want to replace the Arduino with the myDAQ. If you just want to drive 1 motor, essentially you need 3 digital signals from the myDAQ: 1) Enable, 2) PWM Signal, 3) Dir Signal. The enable and dir signals should be just simple on/off, you can use myDAQ to toggle these digital output signal. For outputting PWM, you can check this out: https://knowledge.ni.com/KnowledgeArticleDetails?id=kA03q000000x1P0CAI&l=en-US
Hope this helps!
06-16-2021 04:40 PM
Hi,
sorry for the late reply. I just read your answer today; thought I'd get an email notification in case of a reply.
Thank you very much that you took your time for explaining these basics and for searching the links!
I'll go through them, assemble everything accordingly and will give feedback here in the next days.
Esra
06-16-2021 07:40 PM
No problem! Motion control is my specialty. I did a similar project with myRIO a long time ago, with some Pololu A4988 stepper motor drivers: https://www.youtube.com/watch?v=pdbDDZlHsr0. Have fun!
07-14-2021 05:59 AM
With the help of the links, which you kindly! provided, I have managed to control the direction and the speed of the DC motor with the L298N motor driver connected to myDAQ and Labview.
Here is how I got it going:
Wiring:
MyDAQ:
I hope this is of help for anybody facing the same challenge...
07-14-2021 07:47 PM
Very nice! Glad you got it working.
08-05-2021 06:53 AM
The control of the DC motor in Labview (solved question from above) is part of a development project of a new laboratory device. With this device, I want to measure the flow of compressed air through a porous material into the atmosphere at a defined (very small) air overpressure of 1 mbar. The final goal is to determine the air-permeability of the porous material at 1 mbar air pressure.
The next development step is to automatically set and hold the air pressure in the system at 1 mBar, with a sort of feedback loop between the measurement of air pressure and the control of inflow of compressed air. The DC motor is supposed to control the inflow of air, by pressing and releasing a soft rubber part of the tube through which the compressed air flows. The pressing of the rubber tube is achieved by translating the circular motor movement into a linear movement with help of a Lego linear actuator 🙂 . The air pressure is measured with an electric pressure transducer, which is also connected to Labview via the myDAQ interface.
The DC motor is controlled with the myDAQ Outputs DIO 0 and 1 (direction control) and AO 1 (PWM speed control). At the moment I use the NI ELVISmx digital writer for that purpose. The electrical input signal from the pressure transducer is continuously transmitted through the input channel AI 0+. At the moment it is measured with the NI ELVISmx Data Logger.
A value of 0 mbar pressure in the system corresponds to -10,7 V. The target value of 1 mbar corresponds to, let’s say, -9 V (this is just an example value, because I don’t know the exact value at the moment. I need to measure it with another device in the lab later on).
So my question is: How can a feedback loop be created, in which LABview controls the direction and speed of the DC motor as a function of the air pressure signal in Volt with -9 V as a target value?
As an example: The target value of air pressure of 1 mbar corresponds to a certain volt value, lets say, -9 V. This signal comes continuously from the AI 0+ input of the myDAQ. When the actual measured Volt value is -10,7 (corresponding to 0 mBar), it means that the control of air flow is far away from the target value, since the tube is closed and no air can flow through. Hence, the DC motor can run with maximum speed (PWM control with AO 1 output) in the direction that opens the tube and therefore increases the pressure, leading to a more positive Volt value (output DIO 0=“high” and DIO 1=“low”). The nearer the Volt value of the continuous measurement comes to the target value of -9 V, the slower the DC motor needs to turn. When the target value ‑9 V is reached, the DC motor needs to stop and keep the same pressure continuously for approx. 1 min.
I hope I presented all the necessary specifications. If I have been missing something, please let me know.
Thanks a lot for your help in advance,
Esra
08-06-2021 08:45 PM
Hi Esra,
Look up "PID control loop LabVIEW". Here's a great tutorial: https://www.ni.com/en-us/innovations/videos/10/building-a-pid-controller-with-your-computer.html
This should get you started. Have fun!
08-07-2021 09:47 AM
Hi RIObotics, thanks a lot for the tutorial! I'll go through it and will then present the results.
08-08-2021 05:36 PM
I have gone through the tutorial about PID control. Unfortunately the PID control seems to work only for analogue output (or am I wrong with that?). But my DC motor is controled via a H-Bridge that requires digital output (DIO Lines 0 and 1 set to "high" or "low"). I might control the motor speed (PWM ) with the PID, but first I need to tell the motor in which direction to run at which circumstances.
For that purpose the DIO (Digital Output) Lines need to be set as follows: DIO Line 0=“high” and Line 1=“low” for backwards spin of the motor that opens the tube, when analogue input Value is below the target value of -9 V; and vice versa DIO 0=“low” and DIO 1=“high” for forwards spin of the motor that closes the tube, when analogue input Value is above the target value of -9 V.
In the attachment you find my unsuccessfull block diagram ( "Air permeameter loop control.vi"). I have connected the Analogue Input (DAQ Assistant, called "Analogue pressure Input in V (AI0+)" in my example) with "Greater than" and "Smaller than" operators. Then I have set the comparison values ("y") to the target value of -9 V. Then I inserted the ELVISmx Digital Writer in the block diagram. But I was not able to control the DO lines of the ELVISmx Digital Writer as described above with the output of the operators "Greater than" and "Less than".
If you have an idea about how to get it going, I'd appreciate it if you could also directly illustrate it in the example vi file.
Many thanks in advance,
Esra