LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

help in the programming of the Hc-sr04 ultrasonic sensor

Solved!
Go to solution

 

Hi im new in labview, i have to connect the HC-SR04 ultrasonic sensor to the SensorDAQ, and i have to measure the distance betwen the sensor and an objetc, i have done a little program but the distance is very erratic, and i have seen an example but i dont underestand all the code in the example, so i dont know how to change it to do what i need, later today i will put the to vi's, the one i did and the one i have found, my code is very short adn the code i found i terrible long.

 

If my program is bad, can you tellme where adn why? or is not the code the sensor requieres please tell me.

 

If the example i add the code i really need can you explain me all the parts, and how to change it in order to function with the sensordaq.

 

Can you tell me how to wire the sensor to the sensor daq? i will add my connection diagram and photos so you can help me.

 

I have to make a tank sensor with the data of this sensor, and control a stepper motor with it, if the level is less than 20% use the stepper to open a valve, is its gratter than 80% close the stepper.

 

Other thing i need is when the level of the tank is gratter than 80% another mottor, non steper have to be turned on and must be running for a set time. when this set time is over a signal of "empty the tank" must be displayed.

 

I think is a lot of help what i need, i have wired the stepper mottor(bipolar 4 wires motor)  and i make it run, i dont know how to make it run in either direction so I have to fix this.

 

I'm going to add photos and my vis later today, please helpme, the most important thing is to make the sensor to work.

 

THANKS FOR THE HELP.

 

 

 

 

0 Kudos
Message 1 of 42
(7,739 Views)

Hi nmerzul

 

Please tell us what example you are looking at or please attach it to the forum so we can explain it to you. Also, I can take a look at your program to see if I can give you any advice.

 

P.S. We also have spanish support if you like.

 

Regards

Francisco S.
National Instruments
Account Manager
www.ni.com/soporte
0 Kudos
Message 2 of 42
(7,705 Views)

 

Thanks franciscosaenz, i add the 2 vis, sensordist.vi is what i do, and distance sensor counter.vi is teh example.

 

My vi make the sensor start pulsing but the echo is not correct.

 

With the example i get the sensor to start pulsing but i dont get any signal back. Thanks.

Download All
0 Kudos
Message 3 of 42
(7,702 Views)

Hi nmerzul.

 

There are two ways to perform DAQ tasks. One is with the DAQ assistant (the one that you are using) and the low level steps (the one of the example). Basically they both work the same. The difference is that you can configure all the settings in one step with the DAQ Assistant and with the other method you can do it step by step. I modified the example with a lot of notes so you can understand the functionality of each step.

 

Now, to help you with the wiring of the sensor and the DAQ, could you tell me what DAQ you are using? 

 

Thanks

Francisco S.
National Instruments
Account Manager
www.ni.com/soporte
0 Kudos
Message 4 of 42
(7,698 Views)

 

I´m using sensorDaq vernier. and i have the DCU.

 

I wired it this way:

the vcc to chanel 5 of sensor daq
the trig to chanel 7 of sensor daq
the echo to chanel 11 of sensor daq
and the gnd to chanel 10

 

Thanks for the notes, I will read it today night because i dont have labview in the computer of the factory.

 

0 Kudos
Message 5 of 42
(7,696 Views)

SIC

Francisco S.
National Instruments
Account Manager
www.ni.com/soporte
0 Kudos
Message 6 of 42
(7,684 Views)

I was looking at the sensorDaq Vernier user manual (http://www.vernier.com/files/manuals/sdaq.pdf) and it seems that only has one counter. The example that you gave me is designed to use two counters so the DAQ that you have will not be able to perform what the program states. Where did you get that example? Do you know if it was designed for that sensorDAQ?

Francisco S.
National Instruments
Account Manager
www.ni.com/soporte
0 Kudos
Message 7 of 42
(7,683 Views)

 

I don't remember were i find it, I'm almost sure i get it in other post of this forum, but the post was closed, I have acces to the DAQmx, but can i connect the DCU to the DAQmx, and the DAQ mx work with this sensor?

 

Can we do get any extra hardware so we can use the sensorDAQ?

 

Thanks for your responses.

0 Kudos
Message 8 of 42
(7,675 Views)

You can use DAQmx because the device support the drivers. DAQmx is just a driver that you use to configure your DAQ and it allows you to use Analog I/O, Digital I/O and Counter I/O. The example that you have requires your DAQ to have at least 2 counters and the sensorDAQ Vernier only has one counter. That means that, with the sensorDAQ you can only use the counter (which is terminal 7) to make the triggering function or the pulse width measuring function.

 

I would suggest you to use the counter to measure the pulse width, and then make your own triggering using a digital port (terminals 1-4) by changing the "CO Pulse Time" task to "Digital Ouput" and using timming. That means that you can manually set the digital terminal to the High state for 10us and then turn the signal low so you perform the trigger. You can leave the "CI Pulse Width" as it is, since is the task that is going to use the counter (terminal 7).

Francisco S.
National Instruments
Account Manager
www.ni.com/soporte
0 Kudos
Message 9 of 42
(7,670 Views)

Can you help me with the trigger? how i have to program it? and wath changes to my conection, I underestand i should change the echo to the port i connect the trigger, and change the programming so the ch 7 is an input, and to the trigger i have to use any CH1 to 4 to generate the signal?

 

If i connect the DCU, can we read the pulse from it with out changing the ch7 from the trigger?

 

Thanks for all the help

0 Kudos
Message 10 of 42
(7,667 Views)