![]() |
Limit Switches help
Hi, I'm new at this sort of thing, and with a week left I could use some help with my forklift. I want to make it so it stops at each level. First level is the starting position, almost at the ground. 2nd level is the first level of the rack (the lowest level...24 inches i think). 3rd level in the programming will be the 2nd level on the rack (middle level). And the 4th level in the programming will be the highest level of the rack. Now, there aer a few ways I could do this I've heard. One is a metallic sensor which produces 1 if metal passes by it (a small piece of metal tape on the rope that we are using for the winch system) and 0 if its not. Here is the code I made for that:
Code:
void Default_Routine(void)Code:
/***************The line of code pwm = 127; that is in each of the cases I don't think will work because pwm03 is mapped to the joystick so in the next loop (26 ms later) it will keep going the direction that the joystick was going. So, using limit switches could help me maybe? I've never used them before. help would be greatly appreciated! Only 4 days left befoer we have to ship our robot!! |
Re: Limit Switches help
A limit switch is any kind of switch that closes when your mechanism reaches a "limit" of travel.
We use microswitches (some were included in the KOP), you could use anything including optical detector that you are using, bumper switch, etc. They are easiest to use when there are only two "limits" (eg: - fully clockwise, fully counter-clockwise). When you have intermediate positions (as in your case) you have to be creative in how and where to place the switches. There would normally be two "limits" (bottom-most position, top-most position) and then a detector for intermediate position. Hope this is clear - it's been a long day. |
Re: Limit Switches help
Thanks. How would I program pwm03 to stop when the switch goes on? I'm using a joystick to control pwm03, so when I set it to 127 if the switch is open wont it still not work because during the next loop (26 milisec later) pwm03 is still mapped to p3_y and thers not enough time for the joystick to go back to neutral position. they conflict dont they?
|
Re: Limit Switches help
Quote:
Code:
|
Re: Limit Switches help
I am trying to get the micro switches to work as limit switches also and I am not sure if I am doing this right as it isn't working at all and could use some help...
I have connected these switches to digital input 01 & 02 normally open with the signal and ground from each respective input and I am relying on the internal pullups on the RC inputs to give me a "1" condition if the switches are not activated. We noticed that the joystick wheel is at a value of 43 if untouched (neutral) and in the down position is ~ 148 and in the up position is ~ 255, hence the loose values in my code below. When connected to the dashboard viewer, the switch 1 and switch 2 leds light when I close my switches so I know that electrically these are working but I must have my logic wrong. Here is my code: Quote:
What am I doing wrong here? Thanks! |
Re: Limit Switches help
= is an assignment operator.
== is the logical operator. |
Re: Limit Switches help
Ah yes... how silly of me to forget that...
been a while since I wrote anything in C... thanks for the reminder. |
Re: Limit Switches help
we have limit switches wire to the digital in/outs. The motor turns untill a certian pattern of switches open/clsed is reached, To make an integer from 4 digital i/os do this:
word = dig_in01<<3 word+= dig_in02<<2 word+= dig_in03<<1 word+= dig_in04 Say dig_01 & dig_03 were closed, making "0", the 4 bit word would be 0110 or 6. Remember, inside the digital_in/outs are tied high, they read 1, you need to ground it to read 0. Turn the motor until the number is the lift state you want. Think "state machine". |
| All times are GMT -5. The time now is 04:51. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi