11-27-2022 05:48 AM
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.
The Collector pin of the transistor is connected to the DIO1 port of the myDAQ.
And here's the LabVIEW code.
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
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.
11-27-2022 10:13 AM - edited 11-27-2022 12:31 PM
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?
11-27-2022 02:46 PM
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
11-27-2022 03:28 PM
my bad. still new to this. here's how the circuit is connected.
with pin 2 being on dio1
and the vi is already attached to the original post
11-27-2022 06:16 PM
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?
11-28-2022 02:22 AM
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
11-28-2022 09:54 AM
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