![]() |
Re: Limit Switchers Logic Problem
Try this, keep track of which limit switch is tripped (on) and compare that to which direction button is getting pressed. For example, if left limit switch is tripped and you want to rotate left, don't let this happen, but turn the motor on if you want to turn right. Same procedure for the other side.
Hope this helps. |
Re: Limit Switchers Logic Problem
I think the problem is that you blindly set the output to 0 when the switch is pressed. I think you want the logic to be something like this
Code:
IF left button is pressed |
Re: Limit Switchers Logic Problem
I still run into a problem though. As soon as I set that false state to set motor to 0. I now have to hold the button to go left, and hold the button to go right.
|
Re: Limit Switchers Logic Problem
The problem that you're describing is more complex and probably shouldn't be done the way your code is laid out. The reason I say this is that you have 3 blocks that are affecting the same output. In order to do what you want the program to do, you'll need to look at the 3 buttons and 2 switches and make a decision on what to do to the output.
I think this is the logic that you want to use. Note that based on the inputs we calculate a state and store it into a persistent variable called state. Then at the end, we look at state and write the output. Code:
IF left is pressed |
Re: Limit Switchers Logic Problem
Personally, I'd read all the jstick buttons and limit switches. Then look at the jstick buttons to decide what to do with the motor disregarding the limits. You need some logic about multiple buttons being pushed, but you can build a lookup integer from the the three bits or you can do lots of logic.
After you decide what to do with the motor, look at the limits. One limit forces negative numbers to zero, the other forces positive to zero. Greg McKaskle |
Re: Limit Switchers Logic Problem
Your problem is that your not toggling your buttons, we had this problem too in labview. If you look at the wiring, u said that if button 1 is true than such happens (set motor speed) but that action is within the case box, and it only executes if and only when button 1 is true. The only time button 1 is constantly true is if ur holding the button. Try holding ur buttons and see if the motors are moving the way u'd like.
Now if that doesn't work, i don't know if its also the values ur inputting to the motors which are affecting it but... when I was programming it i didn't realize u cud put values -1 -> 1 to indicate full speed rev and full speed forward, and so i used 127 and -127 and i'm not sure if that makes a difference. Because I tried 127 first i don't know if thats the default pwm values for the program to read. Now about the limit switching, I have just finished a program where for our robot, a gate will be drawn up and down to let balls roll out of our basket. We used limit switches to trigger the stoppingmotion of the gate. I wouldn't mind giving it to u if you want but the problem is I don't understand it much to explain. I spent a whole night doing it and got it working through debugging, but if you were to ask me how each block works i would have no clue haha... Oh and I can give you a toggling vi as well if you'd like. If this gives you too much trouble there is another thing you can do which makes it a whole lot simpler. Since your motion is rotating you can use a potentiometer and use a PID control loop to control how it spins... but i guess if you constantly want to spin left u can't since theres a max and min value for a pot. You can also try an encoder, I dunno much so just suggesting. |
Re: Limit Switchers Logic Problem
1 Attachment(s)
See if this works for you.
It allows CW rotation when the CCW switch is hit and vise verse. |
Re: Limit Switchers Logic Problem
Quote:
That doesn't work because it would just continue to spin left forever and the limit switch would only be checked when the button is pressed again. The other logic would work maybe, but I'm not sure if the limit switcher would work. Also, I wish this was C, I'd be done way sooner. However, I have to write this in LabView. To Greg: I did set up the buttons to move the motors. That works perfect. When you press right, it goes right, when it goes left it goes left. When I press stop, it stopped. Only problem is the limits. Also, once the limit switch is pressed down, I do force the motor to 0. This way the motor actually does stop. However, the limit stays true once it hits it, and the motor is constantly forced to 0. @DarKCroNo: You have a VI that toggles the joystick instead of auto updating? Such as, you press right to be true, and it toogles to true, instead of auto updating it back to false? If so, PLEASE GIVE! @billbo911: I will look right into that as soon as class is over. Thanks! Thanks for your support and I will keep everything updated on how this goes. This is a very important task, and I need this working. Thanks for you help again. |
Re: Limit Switchers Logic Problem
I didn't say to set the value to zero when limit was pressed. One limit switch forces positive motor input to zero but leaves negative alone, the other forces negative and leaves positive alone.
To handle the button toggles, I'd add a state variable. The buttons update the state variable, then the state variable selects positive, zero, or negative speed, then the limit switches pin as described above. The state variable obviously needs to be in either a shift register, a local, or something that maintains state data. Greg McKaskle |
Re: Limit Switchers Logic Problem
Quote:
|
Re: Limit Switchers Logic Problem
Hmm, is there anyway to set something just once. Like let's say the limit switch becoems true, is there a way to set motor speed to 0, ONCE, and not continuously locking up the device.
edit: @DarkOrono, I can't hold it. I need to be able to press and go. I cannot have it have the need to be held. |
Re: Limit Switchers Logic Problem
What you want to do is:
- If no limit switches are pressed, do whatever the joystick says. - if left limit switch is pressed, two cases: a.If joystick wants to move lazy susan left, keep motors at 0. b.If joystick wants to not move or move right(or the "else" case for a.), do as joystick wants. - if right limit siwthc is pressed, two cases: a.If joystick wants to move lazy susan right, keep motors at 0. b.If joystick wants to not move or move left(or the "else" case for a.), do as joystick wants. - if both limit switches are pressed (:ahh: ), stop motors - sirious error! (or someone is cheating :P ) There's a way where you can put all of these in one big case structe, and in each case ("true" and "false") have another case structre with "true" or "false". |
Re: Limit Switchers Logic Problem
I'll describe it again. One limit switch allows positive, but negatives are disallowed and are forced to zero. This means that once a limit switch goes true, it disallows further movement in one direct, but allows movement to unpress the limit.
Greg McKaskle |
Re: Limit Switchers Logic Problem
Quote:
|
Re: Limit Switchers Logic Problem
What is button latching?
Also if you guys know how to just run a piece of code once, when a limit is pressed instead of continuously that would help. |
Re: Limit Switchers Logic Problem
1 Attachment(s)
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. |
Re: Limit Switchers Logic Problem
Alright thanks a lot guys. A lot of your ideas helped us get stuff working. Your vis helped too with the range and conerce ideas. Eventually we got it working with the motors, now we just have to see it reacts on the robot.
Thanks again for your help, and input. |
| All times are GMT -5. The time now is 15:31. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi