ni.com checkout is currently experiencing issues.
Support teams are actively working on the resolution.
ni.com checkout is currently experiencing issues.
Support teams are actively working on the resolution.
07-05-2012 12:35 PM
hi I want to use labview interface with arduino to receive a ultrasonic sensor SRF05
http://www.robot-electronics.co.uk/htm/srf05tech.htm
I have been successfully using SRF05 to read distance with arduino UNO
http://www.robot-electronics.co.uk/files/arduino_srf04.ino
but there is no built-in pulseIN function in Labview interface for Arduino
and I can't find example.
so I use a similar labview code which is successfully used in sbRIO 9602
but it goes wrong
I check the loop time it's about 16 ms to finish a loop
Is it a main reason the received data goes wrong?
How can I shorten the loop time? or is there any other way to make a pulseIN function in Labview+Arduino
07-05-2012 05:55 PM
You would need to make a custom LIFA function to execute the arduino code that you say works for your sensor. This shouldn't too hard. Give me a few days to work on it. Some things I need to know:
Regarding loop time, not entirely sure what kind of time you are supposed to expect but it will be limited by the communication time required to talk to Arduino vi Serial. Also, you should NOT set the pin mode inside the loop unless it is changing, that is two extra functions that contribute to the loop execution time. How much? I don't know for sure but I would move those and try it again to see if it's significant.
07-05-2012 10:32 PM
Hi NathanB.
thanks for reacting
my LIFA version is 2.1.1.69
my LABVIEW version is 2011
Arduino IDE version is 1.0.1
mode1 ( I want to trigger at pin 3 then receive PWM signal from pin 2)
sorry I am very new to this field so I am just trying to find some possible failure reason
I think the sampling rate should higher than PWM frequency and that why I point out the loop time
I try to send a PWM signal from pin 9 to pin 2 which suppose to be 500Hz
so I think the loop should be less than (1/500)*1000=2ms
but if I just want to catch the echo pulse(100us to 25ms) maybe it's OK for longer loop time
ps. setting pin 13 on/off is just for test if Arduino is successfully connceted
It will be fine to delete it.
07-06-2012 05:49 PM
From what i read, you shouldn't be worried about loop time. None of this has anything to do with PWM. Also, PWM output timing is entirely handled by Arduino and not by LabVIEW if you were to ever use PWM signals.
I'll try to get working on this function this weekend.
07-08-2012 02:03 PM
Ok, here it is. Test it out and see if it works as I'm not able to test it completely. Remember that you need to upload my custom version of the firmware.
UPDATE: Updated to work with LIFA 2.2.0.79.
UPDATE: Found and fixed a major mistake that may have been causing this to not work.
07-09-2012 11:04 AM
Hi NathanB.
I try this but the distance signal is wrong. It doesn't change with my hand becoming near.The distance signal is about 1~5cm randomly.
I don't know how to modify the firmware but I think it may be wrong with sampling rate.
Atfer trigger ,we should wait at least 30ms,but the trigger time seems faster
and the echo signal is a PWM signal ,the distance depends on how long it lasts. It's digital?
Does sampleContinously() read analog signals?
Can we void pulseIN() in Labviewinterface
sorry I know nothing about how to modify the firmware
thanks for help
07-09-2012 06:16 PM
According to the documenation, there are no PWM signals sent to the Arduino. The signal that looks like a PWM signal is the actual sound waves sent out by the sensor. The sensor then outputs a single pulse on the echo line. You simply read the time that the echo pulse is high. I did it like it's done in the sketch that you linked to (which you say works). The only thing that I changed was the timeout parameter on the pulseIn() function since it defaults to 1 second. You can remove that third argument and then try it to see if that is messing it up.
Also, you have a potential race condition in your code. You need to have all of those Arduino functions inline.
04-11-2013 08:50 PM
hello friend, if you want to work with an ultrasonic sensor SRF05 or Parallax PING, you have to embed a code in arduino to realize the conversion as a function of pulse width as a function of distance wing, then the number of pulses counted by the Arduinos you convert to centimeters or inches, you finally send the converted data to the serial port on the computer must have a program in labview to receive this information, if you still do not solve the problem I can send the code to the arduino, Greetings
04-11-2013 08:59 PM
code using Parallax Ping ultrasonic sensor...
int distanceCm;
void setup()
{
Serial.begin (9600);
}
void loop()
{
pinMode (sonar, OUTPUT);
digitalWrite (sonar, LOW);
delayMicroseconds (2);
digitalWrite (sonar, HIGH);
delayMicroseconds (5);
digitalWrite (sonar, LOW);
pinMode (sonar, INPUT);
duration = pulseIn(sonar, HIGH);
distanceCm = microsecondsToCentimeters(duration);
Serial.println (distanceCm);
delay (2);
}
long microsecondsToCentimeters(long microseconds)
{
return microseconds / 58;
}