Sonar Range Finder in Visual Basic .Net
Posted 14 April 2004 - 09:28 AM
I'm using Visual Basic .Net as the programming language, but I have not had any success...
Some quick background on the sensor: "You only need to supply a short 10uS pulse to the trigger input to start the ranging. The SRF04 will send out an 8 cycle burst of ultrasound at 40khz and raise its echo line high. It then listens for an echo, and as soon as it detects one it lowers the echo line again. The echo line is therefore a pulse whose width is proportional to the distance to the object. By timing the pulse it is possible to calculate the range in inches/centimeters or anything else. If nothing is detected then the SRF04 will lower its echo line anyway after about 36mS."
I'm comfortable writing the VB code, but being fairly new to using the LabJack I'm not aware of how to provid the necessary pulses, etc.
A Basic Stamp program and details can be founf here:
Any assistance or pointers would be great appreciated.
Posted 14 April 2004 - 10:33 AM
Posted 14 April 2004 - 12:13 PM
Posted 14 April 2004 - 12:16 PM
Posted 14 April 2004 - 12:22 PM
Posted 15 April 2004 - 08:46 AM
Posted 15 April 2004 - 08:59 AM
Posted 16 April 2004 - 04:01 PM
Posted 16 April 2004 - 04:51 PM
Here is an example that does a simple call to AIBurst using the .NET drivers and VB .NET.
Hi - do you have an example of code showing the declaration of the paramters required for the AIBurst call and the call itself? The example in the documentaion appears to be a C example? using pointers. I'm not having any luck figuring out the VB .net representation.
Module Module1 Public Sub Main() Dim lngErrorcode As Integer Dim lngIDNum As Integer Dim sngScanRate As Single Dim lngStateIOout(4096) As Integer Dim lngOverVoltage As Integer Dim alngChannels(4) As Integer Dim alngGains(4) As Integer Dim asngVoltages(4, 4096) As Single Dim cntr As Integer Console.WriteLine("Acquiring Data") For cntr = 0 To 4095 asngVoltages(0, cntr) = 0 asngVoltages(1, cntr) = 0 asngVoltages(2, cntr) = 0 asngVoltages(3, cntr) = 0 lngStateIOout(4096) = 0 Next cntr alngChannels(0) = 0 alngChannels(1) = 1 alngChannels(2) = 2 alngChannels(3) = 3 alngGains(0) = 0 alngGains(1) = 0 alngGains(2) = 0 alngGains(3) = 0 lngIDNum = -1 sngScanRate = 2048 lngErrorcode = lj.LabJack.AIBurst(lngIDNum, 0, 0, 0, 1, 4, alngChannels, alngGains, sngScanRate, 0, 0, 0, 1024, 10, asngVoltages, lngStateIOout, lngOverVoltage, 0) Console.WriteLine(Str(asngVoltages(0, 0))) Console.WriteLine(Str(asngVoltages(1, 0))) Console.WriteLine(Str(asngVoltages(2, 0))) Console.WriteLine(Str(asngVoltages(3, 0))) End Sub End Module
You can see how each of the parameters are defined, and where they are called. In addition to this code you need to add a reference to the LJDotNet.dll that you can find on our downloads page.
Posted 24 April 2004 - 03:05 PM
Posted 25 April 2004 - 04:20 PM
Posted 25 April 2004 - 04:32 PM
Posted 25 April 2004 - 07:00 PM
Posted 25 April 2004 - 07:16 PM
Posted 13 July 2004 - 11:22 AM
Posted 29 October 2004 - 11:50 AM
Posted 31 October 2004 - 09:22 PM
Posted 01 November 2004 - 10:06 AM
I am trying to use the labjack/pc as the controller for a robot so i need to have the program detect the distance automaticly instead of looking at the outputs from AIburst.
You mean you need more of a real-time response. I think burst is still your best option. You can just shorten the length of the burst to reduce your latency as small as possible.
Posted 03 November 2004 - 12:05 PM
Posted 03 November 2004 - 12:15 PM
Posted 05 November 2004 - 10:29 AM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users