Go to Post Looks to me like they have a tasty robot. - Andy Baker [more]
Home
Go Back   Chief Delphi > Technical > Programming > NI LabVIEW
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 15-01-2012, 13:13
DominickC DominickC is offline
Registered User
FRC #0023 (PNTA)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 1620
Location: Boston
Posts: 435
DominickC is an unknown quantity at this point
LabView and Ultrasonic Rangefinder

Hello -

I'm trying to code something in LabView which takes the data from the Ultrasonic Rangefinder and spits out the distance in the dashboard. Now, I've currently got this...



In this, I'm getting the Refnum registry (which I assume is already defined somewhere, but I might be wrong), and getting the range in inches. If I want to pump the distance output from Get Range to the dashboard, how would I go about doing that?

Thanks for your help.

FRC Team 23
Reply With Quote
  #2   Spotlight this post!  
Unread 15-01-2012, 13:54
DominickC DominickC is offline
Registered User
FRC #0023 (PNTA)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 1620
Location: Boston
Posts: 435
DominickC is an unknown quantity at this point
Re: LabView and Ultrasonic Rangefinder

Here's a quick update of the code.



I've made a Case Structure and placed the code inside of it. When button 2 on either Joystick 1 or 2 is depressed, it runs the code which should send out a ping and range it into inches. My question remains - How can I send the readout from Get Range into the Dashboard? And is my code correct? I might be going about this in the wrong way.
Reply With Quote
  #3   Spotlight this post!  
Unread 15-01-2012, 18:10
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: LabView and Ultrasonic Rangefinder

A reference won't be in the registry until you put it there. That's what happens in the Begin vi. Open the sensor and use a Refnum Set to give it a name.

Are you using the rangefinder from the Kit of Parts? The most straightforward way to read it is using an Analog channel. I think the Ultrasonic Get Range function you're using is for the SRF04 part, a different style of ultrasonic sensor. Look at the examples for the MB1010 instead.
Reply With Quote
  #4   Spotlight this post!  
Unread 15-01-2012, 18:26
DominickC DominickC is offline
Registered User
FRC #0023 (PNTA)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 1620
Location: Boston
Posts: 435
DominickC is an unknown quantity at this point
Re: LabView and Ultrasonic Rangefinder

Ah, I see.

Yes, I am using the MB1010. I was just taking a look at the included example code about 10 minutes ago, and saw that there are major differences between what this years KOP had and what they are using..

EDIT - When you say look at the examples for the MB1010, do you mean the code they've got on their website or somewhere within LabView's various examples ?

Last edited by DominickC : 15-01-2012 at 18:30.
Reply With Quote
  #5   Spotlight this post!  
Unread 15-01-2012, 18:34
DominickC DominickC is offline
Registered User
FRC #0023 (PNTA)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 1620
Location: Boston
Posts: 435
DominickC is an unknown quantity at this point
Re: LabView and Ultrasonic Rangefinder

Ah, I see the examples within LabView's set of examples! Now, what are the pro's and con's for using analog versus digital?
Reply With Quote
  #6   Spotlight this post!  
Unread 15-01-2012, 18:46
DominickC DominickC is offline
Registered User
FRC #0023 (PNTA)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 1620
Location: Boston
Posts: 435
DominickC is an unknown quantity at this point
Re: LabView and Ultrasonic Rangefinder

And if I wanted to import the example code into the example teleop.vi, could I just copy/paste the code in, and put it within a while loop which becomes true when a button on the joystick is pressed? (thus ranging once and displaying one distance in the dashboard)?
Reply With Quote
  #7   Spotlight this post!  
Unread 15-01-2012, 22:20
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: LabView and Ultrasonic Rangefinder

Quote:
Originally Posted by DominickC View Post
Now, what are the pro's and con's for using analog versus digital?
Both of the examples give you a continuously updating sensor value that you can read at any time. The digital connection is theoretically less susceptible to electrical noise within the robot. The analog connection might be preferable if you want to use the digital inputs for other sensors. It is also possible to do some more complicated wiring to the digital connections that lets you choose when to activate the sensor, which cuts down on interference if multiple sonar rangefinders are in use at the same time.

Quote:
Originally Posted by DominickC View Post
And if I wanted to import the example code into the example teleop.vi, could I just copy/paste the code in, and put it within a while loop which becomes true when a button on the joystick is pressed? (thus ranging once and displaying one distance in the dashboard)?
For a "ping on demand", you'll need to read up on the MB1010 documentation and find out how to control it with that level of detail. Displaying things on the dashboard is another topic entirely, and I should probably come up with a good instructional document -- once I figure out a better way to do it than the manual synchronization of clusters that I used last year.

In general, applying the examples to a robot project is a matter of putting everything to the left of the example's while loop into Begin, putting everything inside the while loop into Teleop (or Periodic Tasks), and everything after the loop into Finish. Use a RefNum Registry Set in Begin to save the reference for later retrieval with a RefNum Registry Get. For some of the examples, you might want to look up the documentation for the "Data Operations" item on front panel controls, specifically the "Make Current Value Default" command.

The analog example actually has some things inside the while loop that probably belong in Begin. The digital example is much more straightforward to put into a robot project.
Reply With Quote
  #8   Spotlight this post!  
Unread 15-01-2012, 22:36
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,563
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: LabView and Ultrasonic Rangefinder

Quote:
Originally Posted by DominickC View Post
And if I wanted to import the example code into the example teleop.vi, could I just copy/paste the code in, and put it within a while loop which becomes true when a button on the joystick is pressed? (thus ranging once and displaying one distance in the dashboard)?
NI created a tutorial on adding data to the dashboard. https://decibel.ni.com/content/docs/DOC-14704

The major recommendation I would make is that instead of reading the data from the sensor the build dashboard data vi as shown, I would read the data where you want it (either teleop or periodic tasks) and save it in a global variable, and then read the global variable in the build dashboard data vi.
Reply With Quote
  #9   Spotlight this post!  
Unread 16-01-2012, 11:15
Doug Norman's Avatar
Doug Norman Doug Norman is offline
Registered User
no team (National Instruments)
Team Role: Engineer
 
Join Date: Jan 2010
Rookie Year: 2009
Location: Austin, TX
Posts: 136
Doug Norman will become famous soon enoughDoug Norman will become famous soon enough
Re: LabView and Ultrasonic Rangefinder

Also, Tutorial 7 from the LabVIEW Getting Started Window shows how to send data to the dashboard. See Part 2 of that tutorial.
__________________
Doug Norman
National Instruments
Reply With Quote
  #10   Spotlight this post!  
Unread 16-01-2012, 20:18
DominickC DominickC is offline
Registered User
FRC #0023 (PNTA)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 1620
Location: Boston
Posts: 435
DominickC is an unknown quantity at this point
Re: LabView and Ultrasonic Rangefinder

Thank you all for your help and references!

I read and tried to follow the tutorial from NI step by step, but left more confused than when I began. Then, I went through tutorial 7 from LabView's Getting Started Window. Now I feel that I have a grasp on what's going on.

I'll give it a crack and post my results.
Reply With Quote
  #11   Spotlight this post!  
Unread 16-01-2012, 21:35
DominickC DominickC is offline
Registered User
FRC #0023 (PNTA)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 1620
Location: Boston
Posts: 435
DominickC is an unknown quantity at this point
Re: LabView and Ultrasonic Rangefinder

Great news! I was able to properly code in the rangefinder!

Now, one final question. I read somewhere that there should only be one Set High(/Low) User Data Priority per vi? If this is so, how would I integrate the Gyro, Accelerometer, Rangefinder, and Potentiometer in with each other ?
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 09:26.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi