LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I control a dc motor speed using an optical switch?

I am trying to use LabVIEW to create a VI that controls the speed of a DC motor. The system needs to have an user set rpm and the DC motor needs to adjust the duty cycle to obtain the correct rpm dependant on the load. A disk with holes and an optical switch is being used to measure rpm.

 

The current problem is that I cannot get the rpm based on the optical switch.

 

Thanks for your help!

0 Kudos
Message 1 of 11
(3,748 Views)

@ku2 wrote:

 

The current problem is that I cannot get the rpm based on the optical switch.

 



have the switch signal input into your Daq counter, get a frequency (cycles/sec)..do the math depending on how many holes/revolution

0 Kudos
Message 2 of 11
(3,732 Views)

Thanks for your reply.

 

We were able to get the frequency using the DAQ. We are now trying to implement the frequency as the process variable for the PID controller. We have it setup so we enter a specified frequency in as the setpoint.

 

When we do this, we get an error saying the number of samples to write are not the same, even though we seem to have both daq assists set the same.

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

what is the exact error# message

0 Kudos
Message 4 of 11
(3,715 Views)

Error - 200103 occured at Speed reg.vi:Instance:2:1

 

Possible reason(s):

Number of samples to write must be the same for every channel.

 

Task Name:_unnamedTask<C5>

0 Kudos
Message 5 of 11
(3,712 Views)

We are using the frequency output of the Tone Measurements module to detect the signal from the optical switch (essentially a square wave). When the speed of the motor drops below about 250 rpm (there are 4 slots so this corresponds to a signal frequency of about 16-17 Hz), the frequency detected by Tone Measurements begins increasing and diverges from the true value. Could this be related to the problem, and should we be using a different tool to detect the frequency of the square wave signal? (We have also tried the Pulse Measurements module, which results in an error when the speed drops below about 600 rpm.)

 

Thank you very much for your help.

0 Kudos
Message 6 of 11
(3,700 Views)

there is a problem with the first Daq Assistant....

  • double click on it, to open daq assistant
  • press 'ok'
  • press 'no' to show error
  • it will show you the reason and what you can select to fix it....change generation mode to 'on demand'
0 Kudos
Message 7 of 11
(3,691 Views)

The error for the samples to write does not appear after redoing the vi. Thanks. The controller seems to be working mostly.

 

However, the issue with the Tone Measurement reading inaccurately at low frequencies still exist. Any ideas?

 

I have attached the latest vi.

 

Thanks again!

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

Hi ku2,

 

So I took a look through your VI and have a couple of thoughts. 

 

First of all, it would be useful if you could post the data you're seeing both directly from the DAQ assistant and after it has passed through your Tone Measurement Express VI. It is possible that the motor is turning too slowly to detect the full revolution given your sampling parameters.

 

Also, note that the Express VIs you are using take much longer to process than lower-level functions. Your DAQ Assistant VI for example probably takes several hundred ms to run, which may seriously limit your acquisition rate. Just a few things to think about.

 

I hope this helps!

 

Andy C.

Applications Engineer

National Instruments 

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

Thanks.

 

Now, everything works, but we are not able to increase our sample rate. Labview currently takes data at 10 points per second, but soon as we change the rate, the system stops functioning correctly.

 

All we want to do is for more samples per second to be written so that we can have a better plot when we analyze our data. Any thoughts? Thanks again.

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