LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

frequency counter input on myDAQ not working

Hey guys

I'm trying to measure the speed of a small DC motor using a rotary encoder and an OPTO sensor, and counter input on myDAQ.

 

Here's my circuit on the breadboard.

 

CHARNICS_1-1669548792432.png

CHARNICS_2-1669548825211.png

CHARNICS_3-1669548848412.png

 

The Collector pin of the transistor is connected to the DIO1 port of the myDAQ.

 

And here's the LabVIEW code.

 

CHARNICS_0-1669548104463.png

 

On the front panel, I only have the RPM numeric indicator.

 

When I run the program, with the rotary encoder spinning in the gap of the OPTO coupler, nothing happens. The RPM numeric indicator keeps showing 0.

 

I thought the problem was my OPTO coupler. I tested it through analog input and I successfully visualised the pulses, as shown here

CHARNICS_4-1669549351048.png

 

So the problem is not the OPTO coupler.

 

And I can't seem to figure out the source of the problem. I would really appreciate some help please.

0 Kudos
Message 1 of 7
(1,476 Views)

It is impossible to tell from the pictures how things are connected. Do you have a diagram?

 

What if you would reverse the pins to get positive voltages?

0 Kudos
Message 2 of 7
(1,434 Views)

The Digital I/O on the myDAQ expects a TTL signal, that is, something between 0 (off) and +5 V (on), with somewhere around 3.3 V being "I don't know" (ambiguous).  As Altenbach notes, your signals run from 0 to -5 V, suggesting you've got some wires swapped.

 

Why do you think showing us pictures of error messages, wiring (with no wires identified), and no circuit diagram will be helpful to us trying to help you?  Attach LabVIEW code (hint -- it's a file with the extension ".vi"), don't attach "phone photos" of screens.

 

Bob Schor

0 Kudos
Message 3 of 7
(1,407 Views)

my bad. still new to this. here's how the circuit is connected.

CHARNICS_0-1669584470684.png

with pin 2 being on dio1

and the vi is already attached to the original post

 

0 Kudos
Message 4 of 7
(1,400 Views)

As we said, your voltage is not right, because it is negative.

 

You have four pins on the detector, so why do you think it is sufficient to only mention 25% of the pins. Is your 5V correct?

0 Kudos
Message 5 of 7
(1,376 Views)

As is very clear in the diagram I attached, the pins are either on the 5V or the GND (of the mydaq of course). And the dio1 is the counter input. I don't see which pins I have failed to mention... grateful for the help

0 Kudos
Message 6 of 7
(1,358 Views)

So maybe when you showed the "Analog signal", you recorded differentially (good) but wired your Optoisolator signal to the negative input of the Analog Channel, and ground to the positive input?  How else can you explain the -5V signal from your simple wiring diagram?

 

You are correct that I missed the "broken VI" that you attached with your Original Post.  My apologies.

 

Why did you attach a VI that has a broken arrow?  Can't you at least wire a "Stop" indicator to the Stop Control of the While Loop?  Did you notice that your Counter is reporting Frequency in Hz (the default).  So how often do you think you will get a rising edge on your Counter input?  Judging by the inverted Analog Signal you showed, the Frequency is around 2 Hz.  Your While loop takes 1 Sample, and has a 0.1 second timeout.  So if no edge appears in that time interval, the Counter function "fails", generates an Error, and returns 0.  You are not checking the Error Line, so you don't know if 0 is "data" or "no data because of an Error".  And when it fails, you immediately do it again.

 

I'll confess that I haven't used Counter-Timers to measure frequency very often, so I usually have to go back to the DAQmx Help and description of Counter-Timers and how to use them. Here is one reference I found for a search of "measuring frequency with DAQmx counter-timer" .

 

Bob Schor

0 Kudos
Message 7 of 7
(1,322 Views)