Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   NI LabVIEW (http://www.chiefdelphi.com/forums/forumdisplay.php?f=182)
-   -   Increase a value using a joystick (http://www.chiefdelphi.com/forums/showthread.php?t=94175)

siggy2xc 30-03-2011 19:19

Increase a value using a joystick
 
I want to increase a value over time when using the joystick. The value would start out at zero and you would press the joystick forward, the longer you press it forward the larger the value gets and when you hold the joystick down the value gets smaller over time.

WizenedEE 30-03-2011 19:24

Re: Increase a value using a joystick
 
I'd have a feedback node/shift register storing the current value, and each iteration the value of the joystick adds to it. It'd probably be a good idea to make a separate loop in periodic tasks so that you get a constant rate.

What are you using this for?

EricVanWyk 30-03-2011 19:27

Re: Increase a value using a joystick
 
I think you are looking for a "shift register". It is a node that remembers the last thing that you wrote to it.

This can be found on the Programming -> Structures palette. It looks like an arrow in a rectangle. It can point in either direction (right click to change). New data goes into the tail of the arrow, old data comes out the tip of it.

siggy2xc 30-03-2011 19:37

Re: Increase a value using a joystick
 
In simplest terms, I'm trying to move a point on a graph using the joystick. I can get it to increase and decrease, i just need to make it so that it is not so rapid. Would i just put a wait timer in there or would that slow down the code?

Mark McLeod 30-03-2011 19:41

Re: Increase a value using a joystick
 
A wait timer would slow down Teleop, but would work fine in Periodic Tasks.
Anything you can do in Teleop, you can also do in Periodic Tasks if you need explicit delays.

siggy2xc 30-03-2011 19:50

Re: Increase a value using a joystick
 
This isn't part of the robot project. This is just a simulator

siggy2xc 30-03-2011 19:54

Re: Increase a value using a joystick
 
Would i just have the values writing in a separate while loop with a wait timer in it?

EricVanWyk 30-03-2011 19:55

Re: Increase a value using a joystick
 
Lets say you hold the joystick full forward "forever". What do you want the output to be? Should it keep going up, or settle to match the joystick's position?

siggy2xc 30-03-2011 19:56

Re: Increase a value using a joystick
 
keep going up

Mark McLeod 30-03-2011 20:33

Re: Increase a value using a joystick
 
A separate, independent while loop that constantly checks the joystick at the rate you decide upon would work.

WizenedEE 30-03-2011 23:46

Re: Increase a value using a joystick
 
Or if you want to be fancy, you could have it update the value every so often, while still running the loop.

Better still, have it update the value every iteration, but have something that reads the speed of the loop and divides the value of the joystick by a number proportional to that.

Or just add the timer...

You should have the program generate a maze, plot it on an XY graph, and then use the joystick to navigate the maze. That would be epic.

siggy2xc 30-03-2011 23:57

Re: Increase a value using a joystick
 
I like your ideas WizenedEE! but I'm just trying to simulate a robot drive (which is a lot easier than I originally thought!). That maze project sounds like some good practice :]


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

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