View Single Post
  #4   Spotlight this post!  
Unread 05-02-2009, 20:41
DarKCroNo's Avatar
DarKCroNo DarKCroNo is offline
Registered User
FRC #2670
 
Join Date: Dec 2007
Location: Toronto
Posts: 37
DarKCroNo is an unknown quantity at this point
Re: Limit Switchers Logic Problem

OK so um heres the vis, but the vi is not complete to be able to use as a sub vi you have to do that wire thing for the block icon. Anyway the way i programmed it was at home so its not part of the robot coding, so using the switches on the front panel it'll simulate the desired affect.

Now to briefly describe wats going on... ( I don't have much time right now since i have 2 tests tommorow to study for, however if u have any problems just tell me and i'll reply later on)
okay so for the Toggle program

What I did was simply put a variable that is set to 1 while the button is pressed and then if pressed again it'll change to 0. So if the variable is 1 it'll do something and if the variable is 0 it'll do another task. Now if u imagine wat is going on, if the button is pressed the value is 1, so every millisecond it is pressed it'll continueally set it to 1 and than 0 than 1 than 0. To stop this i put a delay, meaning once u press the button u have to let it go after a certain time. Anyway to observe this, just like a joystick button, on the front panel when u run continuesilly you have to press the trigger and then press the trigger again so that the button simulates the joystick button being let go. Hopefully you can understand wat i said, so basically when u press the trigger u have to press it again right away so that u let go of the button. Now if done correctly u will see the motor value changing from 127 to 0 every time u do so. But there is a limitation to the programming, you must not hold the joystick button for any longer than the delay, if the button is kept held it will continually toggling between the 2 instructions. Now with regards to the limit switches, there is a way around this problem.

So with the gateway vi...
First a few things must be explained, for our mechanism we wanted a gateway to rise and fall so that the balls can be rolled out, and we wanted one button to do it. So for your purposes there is alot u'd need to change since u would want 3 different buttons. But first thing u need to understand is that if no limit switches are tripped than they will continually provide a True statement. So when u run continuesilly on the front panel u must set upper and lower limit on true. Now when the program runs, simply press the trigger and once again to simulate pressing a button. wat u will see is that the motor speed will be positive simulating that its raising. Now if u imagine the gateway touching a limit switch, the upper limit switch will be turned into false, so on the front panel u have to turn it off manually. Once that becomes tripped u will see the motor speed set to 0. Now if you were to press the trigger button again and once more to simulate the joystick button, you will see the motor speed will be negative which simulates the gateway moving downwards. Now if u imagine when the gate moves down, it will let go of the upper limit switch and so u must turn the upper limit back on manually, and so both limits will be true and than if u imagine as it continues to lower it will trigger the lower limit. So if u manually turn the lower limit to false u will see again the motor speed will become 0. you can continually do this and you will see you will get the desired affect so long as u can simulate wat is happening. Now to explain wat i meant of going around the delay problem, If you look at the coding I've set it so that once the trigger is turned on it will set the a variable to a value. Now i put an if statement if that variable is that value than it will do a task. The solution is that at the END of the task I reset the variable back to 0. This way instead of pressing the trigger again to set it to 0, it will be set back to 0 when the instructions are done.
I really hope u can understand what I've said, and I'm sure this is wat your looking for just if you cud get the front panel to work. The rest of the stuff for the gateway vi i can explain later if you want(like the block diagram stuff, because I don't really understand it very well, I started out well and kept getting errors, after alot of debugging it worked but I had to add a whole lot to make it work. So as a whole i cannot explain but parts i can.
Attached Files
File Type: zip Toggle and gateway.zip (37.3 KB, 31 views)