Go to Post Unfortunately, there's no special type of transmission that will magically get you past defense. The best way to deal with defense is to practice, regardless of gearing. - connor.worley [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 Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 09-02-2010, 14:35
dekker120 dekker120 is offline
Registered User
AKA: Matt Mohler
no team
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2008
Location: Lees Summit
Posts: 15
dekker120 is an unknown quantity at this point
LabView question

ok.. I looked at the examples for creating a latching button... but does anyone know how to create a delayed button... (i.e. you press a button and it retains the value of true for x seconds/milliseconds and then resets to false).
__________________
Reply With Quote
  #2   Spotlight this post!  
Unread 09-02-2010, 15:24
Ziaholic's Avatar
Ziaholic Ziaholic is offline
Elec/SW Mentor
AKA: Marc
FRC #1164 (Project NEO)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2002
Location: Las Cruces, NM
Posts: 194
Ziaholic is a jewel in the roughZiaholic is a jewel in the roughZiaholic is a jewel in the roughZiaholic is a jewel in the rough
Re: LabView question

I'd use a state-machine sort of case structure, with a shift register.

When the button is initially pressed, you enter into the START state and read the current time, add your offset time and write it into the shift register. You'd also write the next state into the shift register ... named something like "WAITING".

In the WAITING state, you'd check the current time and the stored time in the shift register. If the current time is still less than the stored time, stay in the WAITING state. Once the current time is greater than the stored time, you exit the WAITING state.

There is a good example of State Machines and shift registers at the LabView Mastery website.
__________________
----
There are 10 types of people. Those who understand binary, and those that do not.
Team #1164 - Project NEO Robotics
Reply With Quote
  #3   Spotlight this post!  
Unread 09-02-2010, 15:31
dekker120 dekker120 is offline
Registered User
AKA: Matt Mohler
no team
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2008
Location: Lees Summit
Posts: 15
dekker120 is an unknown quantity at this point
Re: LabView question

Ok... Could you post a pic with an example of that... (As you may have noticed, I am the electrical guy... We lost all our programmers... And I am somewhat lost)
__________________
Reply With Quote
  #4   Spotlight this post!  
Unread 09-02-2010, 16:03
Racer26 Racer26 is offline
Registered User
no team
Team Role: Alumni
 
Join Date: Apr 2003
Rookie Year: 2003
Location: Beaverton, ON
Posts: 2,229
Racer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond repute
Re: LabView question

Attached is a JPG of a VI i just wrote that does this.

Click the button, button stays down for 1000ms (1s) and then comes up.
Attached Thumbnails
Click image for larger version

Name:	delay button vi.JPG
Views:	198
Size:	75.4 KB
ID:	8582  
Reply With Quote
  #5   Spotlight this post!  
Unread 09-02-2010, 16:47
kws4000's Avatar
kws4000 kws4000 is offline
Team Mentor - Programming
AKA: Krazy Karl
FRC #2405 (Divided by Zero)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Fruitport, MI
Posts: 164
kws4000 is a jewel in the roughkws4000 is a jewel in the roughkws4000 is a jewel in the roughkws4000 is a jewel in the rough
Re: LabView question

Can this be dropped directly into the TELEOP subvi and used to run solenoids just the way it is?
Right now all I have are the solenoids being called and being fed the joystick value TorF, and they are just sitting inside the "Execute Default" case structure. I know these have to be maintained for at least 30ms; how can this be worked into your example?

Thanks
__________________
Mentoring:
1) Educating students on the ability to learn and have fun at the same time.
2) Giving back to those who made you who you are.

2009-2011 Student 2405 Electrical/Programming & Asst. Captain
2012-???? Mentor 2405 Programming/Jack-of-all-Trades

Last edited by kws4000 : 09-02-2010 at 17:01.
Reply With Quote
  #6   Spotlight this post!  
Unread 09-02-2010, 16:56
Racer26 Racer26 is offline
Registered User
no team
Team Role: Alumni
 
Join Date: Apr 2003
Rookie Year: 2003
Location: Beaverton, ON
Posts: 2,229
Racer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond repute
Re: LabView question

I don't think it can. I have not used LabVIEW for the FRC robots, I use it in my work, however, my understanding of how it works says you couldn't simply drop this in. However, you can adapt the concept of it (measuring the time between now and when you pushed the button).

On a simplicity note: Why not just have your drivers ensure they hold the button down for at least 30ms? 30ms is not a very long time, and chances are good that your drivers already ARE holding the button for this long. I remember always having to code my robots to trap the rising edge of a button, because if i used the buttons on/off state, I would read many more "on"'s than one.

EDIT: ie.
Code:
 
if( oldButtonState == off && ButtonState == on) {
//do some stuff
}
oldButtonState = ButtonState;
30ms is 0.03s. Roughly 30Hz, which is right around the same speed our eyes operate at.

Last edited by Racer26 : 09-02-2010 at 17:04.
Reply With Quote
  #7   Spotlight this post!  
Unread 09-02-2010, 17:04
kws4000's Avatar
kws4000 kws4000 is offline
Team Mentor - Programming
AKA: Krazy Karl
FRC #2405 (Divided by Zero)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Fruitport, MI
Posts: 164
kws4000 is a jewel in the roughkws4000 is a jewel in the roughkws4000 is a jewel in the roughkws4000 is a jewel in the rough
Re: LabView question

[quote=1075guy;916533] I remember always having to code my robots to trap the rising edge of a button, because if i used the buttons on/off state, I would read many more "on"'s than one.


What do you mean by "the rising edge of the button"? and "many more on's than one"?
__________________
Mentoring:
1) Educating students on the ability to learn and have fun at the same time.
2) Giving back to those who made you who you are.

2009-2011 Student 2405 Electrical/Programming & Asst. Captain
2012-???? Mentor 2405 Programming/Jack-of-all-Trades
Reply With Quote
  #8   Spotlight this post!  
Unread 09-02-2010, 17:12
kws4000's Avatar
kws4000 kws4000 is offline
Team Mentor - Programming
AKA: Krazy Karl
FRC #2405 (Divided by Zero)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Fruitport, MI
Posts: 164
kws4000 is a jewel in the roughkws4000 is a jewel in the roughkws4000 is a jewel in the roughkws4000 is a jewel in the rough
Re: LabView question

Han on, here's an image of where I'm at.
Attached Thumbnails
Click image for larger version

Name:	solenoid teleop.JPG
Views:	119
Size:	101.5 KB
ID:	8585  
__________________
Mentoring:
1) Educating students on the ability to learn and have fun at the same time.
2) Giving back to those who made you who you are.

2009-2011 Student 2405 Electrical/Programming & Asst. Captain
2012-???? Mentor 2405 Programming/Jack-of-all-Trades
Reply With Quote
  #9   Spotlight this post!  
Unread 09-02-2010, 17:13
Racer26 Racer26 is offline
Registered User
no team
Team Role: Alumni
 
Join Date: Apr 2003
Rookie Year: 2003
Location: Beaverton, ON
Posts: 2,229
Racer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond repute
Re: LabView question

a button is a digital signal. It can either be on or off. The transition between the on and off states is called an edge. It is described as rising (off->on) or falling (on->off). You can either just use the state of the button (on or off) to drive your code, or you can use the edge to drive your code.

Consider a 'start' button, that causes a sequence of things to happen.

If you trigger it on the state of the on button, what happens when the button is "on" for more than one consecutive cycle?

If you trigger it on the rising edge, (ie. the button was off on the last cycle, and its on now), then it doesnt matter how long you hold the button.

Which method you choose depends on the action you want.

EDIT: In order to do this, you must store the state of the button from the previous iteration.

EDIT2: I just built a small VI to clock my mouse click. It takes me on average 40ms to quickly click and release the button on my mouse. I saw times as low as 8ms on a particularly fast cycle.

Last edited by Racer26 : 09-02-2010 at 17:23.
Reply With Quote
  #10   Spotlight this post!  
Unread 09-02-2010, 17:45
kws4000's Avatar
kws4000 kws4000 is offline
Team Mentor - Programming
AKA: Krazy Karl
FRC #2405 (Divided by Zero)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Fruitport, MI
Posts: 164
kws4000 is a jewel in the roughkws4000 is a jewel in the roughkws4000 is a jewel in the roughkws4000 is a jewel in the rough
Re: LabView question

I posted just a minute before you while you were writng your response. Scroll up and find enclosed attachment of where I am on coordinating solenoids.
__________________
Mentoring:
1) Educating students on the ability to learn and have fun at the same time.
2) Giving back to those who made you who you are.

2009-2011 Student 2405 Electrical/Programming & Asst. Captain
2012-???? Mentor 2405 Programming/Jack-of-all-Trades
Reply With Quote
  #11   Spotlight this post!  
Unread 09-02-2010, 23:35
Ziaholic's Avatar
Ziaholic Ziaholic is offline
Elec/SW Mentor
AKA: Marc
FRC #1164 (Project NEO)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2002
Location: Las Cruces, NM
Posts: 194
Ziaholic is a jewel in the roughZiaholic is a jewel in the roughZiaholic is a jewel in the roughZiaholic is a jewel in the rough
Re: LabView question

I had a similar problem to solve, so I whipped up a quick VI to show you what's involved in getting the trigger to set off a timed sequence that lasts longer than the 20 msec DS packet times.

You could simply keep what you've got, and tell the driver to just tap the trigger, and it'd work OK. Your 30 msec requirement is only 2 "cycles" of the standard 20 msec main-loop timer. Tapping the button would pretty much get what you want.

But if you want the SW to take care of it for you, and allow for "driver error", or if you need it to last for 300 msec, then you'll need to get familiar with shift registers.

This isn't exactly cut/pasteable into your code, this is advanced stuff. It'd be safer for you if you created it for yourself ... maybe using the attached pics as a guide.

One of the pics shows the TRUE case, where the trigger has just been sensed as going from FALSE to TRUE. The other shows the FALSE case which gets executed until the driver2 lifts and eventually re-presses the trigger.

I didn't make a third pic, but the unshown case in the FALSE pic has nothing in it at all. While that inner-case is TRUE, you're doing nothing, waiting for the timer to go off.
Attached Thumbnails
Click image for larger version

Name:	Help_True.jpg
Views:	127
Size:	120.0 KB
ID:	8594  Click image for larger version

Name:	Help_False.jpg
Views:	101
Size:	122.0 KB
ID:	8595  
__________________
----
There are 10 types of people. Those who understand binary, and those that do not.
Team #1164 - Project NEO Robotics
Reply With Quote
  #12   Spotlight this post!  
Unread 10-02-2010, 11:10
Omar's Avatar
Omar Omar is offline
Registered User
no team
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2008
Location: Huntsville, AL
Posts: 122
Omar is a glorious beacon of lightOmar is a glorious beacon of lightOmar is a glorious beacon of lightOmar is a glorious beacon of lightOmar is a glorious beacon of light
Re: LabView question

This VI will detect a “rising edge” of a Boolean In and will latch and hold the Boolean output high for a set amount of time passed in as HoldTime. The hold time is in sec.

Feed the joystick button into the Boolean In and connect the Boolean Out to what you wish to control.

This VI is set to “Reentrant Execution” with Preallocate clone for each instance so it can be use in many different places and get will keep separate time.

Omar
Huntsville, AL
Attached Files
File Type: vi Hold_and_Release.vi (11.6 KB, 58 views)
File Type: vi Edged Detect.vi (7.2 KB, 43 views)
__________________
Omar
Reply With Quote
  #13   Spotlight this post!  
Unread 10-02-2010, 15:10
kws4000's Avatar
kws4000 kws4000 is offline
Team Mentor - Programming
AKA: Krazy Karl
FRC #2405 (Divided by Zero)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Fruitport, MI
Posts: 164
kws4000 is a jewel in the roughkws4000 is a jewel in the roughkws4000 is a jewel in the roughkws4000 is a jewel in the rough
Smile Re: LabView question

Ziaholic, thanks for the assurance that I just have to hold button 1 in order to achieve the same effects.

Omar, I'm not exactly sure how your sample VIs work, except that they do work.

Anyway, thanks a whole bunch, all of you!

Now, to get the robot over the hump with a half dead battery...
__________________
Mentoring:
1) Educating students on the ability to learn and have fun at the same time.
2) Giving back to those who made you who you are.

2009-2011 Student 2405 Electrical/Programming & Asst. Captain
2012-???? Mentor 2405 Programming/Jack-of-all-Trades
Reply With Quote
  #14   Spotlight this post!  
Unread 10-02-2010, 15:55
Omar's Avatar
Omar Omar is offline
Registered User
no team
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2008
Location: Huntsville, AL
Posts: 122
Omar is a glorious beacon of lightOmar is a glorious beacon of lightOmar is a glorious beacon of lightOmar is a glorious beacon of lightOmar is a glorious beacon of light
Re: LabView question

Quote:
Originally Posted by kws4000 View Post
Omar, I'm not exactly sure how your sample VIs work, except that they do work.
You would only need it if you needed precise timing that repeats each time you press a button.

When you first press a button the VI calculates the release time and stores it in the Feedback Node.
Each time around your outer loop the VI is called and checks if the release time has been passed. If so it set the output to false.

If you press and hold the button or press and quickly release the button, you will always get an active high for the same amount of time defined by release time.
__________________
Omar
Reply With Quote
  #15   Spotlight this post!  
Unread 19-02-2010, 00:10
lucoytoa's Avatar
lucoytoa lucoytoa is offline
Programmer
AKA: Nicolas Xiong
FRC #2276 (STARS of Cypress)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Spring, TX
Posts: 20
lucoytoa is an unknown quantity at this point
Re: LabView question

Omar, where should I save the codes to work? I've deployed the 2 codes but my 2nd joystick is still not moving
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Labview Programming Technique Question MotorHead NI LabVIEW 2 27-01-2010 23:30
Question|Help in LabVIEW Rafael2215 NI LabVIEW 2 20-01-2010 10:47
Labview Question professorX NI LabVIEW 7 21-02-2009 11:07
Labview Rookie Question -- Motors cmh0114 NI LabVIEW 2 23-01-2009 20:44
Labview Programming question pollyproof12 General Forum 2 30-09-2008 16:29


All times are GMT -5. The time now is 22:39.

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