LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DC motor control using NI 9401 and DC motor driver

Solved!
Go to solution

 

 i am using cRIO 9073 ,NI 9401,DC motor and motor Driver, I have attached my VI , i am acquiring  two signals which i represented with  1 and 2 in my attached block and caluclating their amplitudes and comparing them individually with a set threshold.

 

1)when signal 1 condition is true DI0 and DI1 should be true and false respectively so that motor rotates clockwise if the condition is false no movement that is DIo and DI1 should be 0 and 0

 

2)coming to signal  2 when its condition is true DI0 and DI1 should be false and true so that motor rotates anticlock wise direction if the condition is false

no motor movement i.e DI0 and DI1 should be 0 and 0

 

 Plese give me some  solution i made two case structures for the two different signals but my motor is rotating only in one direction and it is just vibrating.

Download All
0 Kudos
Message 1 of 11
(3,656 Views)

Hello,

 

From what I can see in these attachments you have 2 main issues:

1) the case where both conditions are true this needs to be handled

2) you need to put this block in a while loop with a wait/wait until next multiple so that the program re-checks these conditions at a given rate

 

If you have any more questions please ask away.

 

Regards,

Toader Mihai

Message 2 of 11
(3,649 Views)

one thing i  forgot to tell you is two cases conditions will never be true,my acquired signals are in such a way that when one signal  is high voltage the other one will be low. but, i want to compare both the conditions at a time.

 

main problem i am facing in the two case structures is when one is false it is sending DI0 and DI 1 as 0 and 0 which i have assigned in the false codtion for both cases of signal 1 and signal 2 (false condition not shown in previous attached figure).

 

now the thing is when signal one reaches threshold it executes true case but at the same time signal2 is  gives  false condition and writes 0 and 0 to DI0 and DI1 which is resulting my motor to vibrate .

 

 

please provide me a solution of this

0 Kudos
Message 3 of 11
(3,642 Views)

Hello,

 

I suggest unifying the two case structures into one with the cases:

1)FALSE FALSE: both outputs set to 0

2)FALSE TRUE: DO0-false DO1-true

3)TRUE FALSE: DO0-true DO1-false

4)TRUE TRUE: even though this might not happen it's good practice to handle it, pop out an error and terminate execution

 

See my attachment to see how I implemented it. If you have any more questions feel free to ask.

 

Regards,

Toader Mihai

Message 4 of 11
(3,625 Views)

hello sir i  have written the code for  all the four options you gave  it but i am a geeting and  error which i have attached in the attachment.

 

one more problem i want to address is my signal  one always oscillates evn though it crosses threshold.i faced this this problem when i done  with a

single signal acqusision.how to address this problem in this case.  

0 Kudos
Message 5 of 11
(3,621 Views)
Solution
Accepted by topic author Illa

Hello,

 

You should set the false false case as the default one, and the error will disapear. As for the oscillating part can you give me more details probe values on the comparison or on the string for example?

 

Hope this helps.

 

Regards,

Toader Mihai

Message 6 of 11
(3,609 Views)

sir its working now

 

Regarding oscilation 

 

i am acquiring two signals at a rate of 1800 samples per second i.e signal 1 and signal 2, i am caluclating RMS for both the signals for every  1800 sample length ,when  signal 1 RMS value is greater than threshold it should give 1 and 0 for DI0 and DI1 same thing for signal 2 but  0 and 1 for DI0 and DI1.both cases true not possible as i mentioned earlier.

 

the problem is  if RMS is constant and satisfies the condition the motor rotates perfectly without disturbance but  my RMS value keeps changing as i am acquiring the signal continuously and the signal also has a no constant amplitude  . that time my motor just rotates with disturbance.

 

(how can i terminate the single case execution which you have mentioned earlier) 

 

0 Kudos
Message 7 of 11
(3,598 Views)

Hello,

 

Depending on your aplication requirements you can add a wait until next ms timer so outputs get changed slower(not 5-10 times a second). If you can describe the application requirements maybe I can find a btter solution then this, but this is viable and simple to implement(also most DC motors have high inductance so switching fast between signals is not a very good idea).

 

As for the application termination, the case structure does not need to be terminated because it will execute very fast, it only has to do 2 assignments. If I misunderstood you question please clarify I'm unsure this is what you meant.

 

Regards,

Toader Mihai

0 Kudos
Message 8 of 11
(3,586 Views)

i am taking two muscle EMG signlas continoulsy  from body and filtering them and caluclating their RMS. The condition is  when one muscle is active it will give EMG both muscles active is not possible.

now we are caluclating RMS for a sample lenght of 1800  for both signals and comparing with a thresholld value .if one EMG is active it will enable the motor to movein one direction and if other muscle is active it will rotate in anticlock wise after comparing with thresholds

 

my RMS just keeps on changing without sticking to one value now the problem comes here where my motor just gets disturbed.

 

please provide me some solution so that when one signal is high the motor rotates for some time.

0 Kudos
Message 9 of 11
(3,577 Views)

Hello,

 

So my idea is to move the case logic subVI in a paralel loop with a smaller loop rate(a wait until next ms timer with a higher value than the first loop) and pass the data through local variables from one loop to the other. However this solution will take into account particular RMS values at specified points in time and might cause problems for example: if your condition is the rms value greater than 2 and you get in the upper loop 3,4,3,5,6,1,4,2,6,4 the lower loop could execute when the 1 is in the local variable and get a false condition. A better option would be to consider a different kind of conditioning in which values don't vary that much(some sort of avareging).

 

Hope this helps.

 

Regards,

Toader Mihai

0 Kudos
Message 10 of 11
(3,565 Views)