![]() |
Limit Switch Draws Tears
Imagine yourself: 11 hours, 5 programmers, no mentors, 1 fiesty limit switch. The result? 5 programmers suffering a severe mental breakdown.
We are attempting to program a very simple limit switch that will disable a motor when the limit switch circuit is closed. We have wired the two limit switch wires into to the ground and signal connections on input four of the digital sidecar. We are programming in C++ and whenever we attempt to get a signal back from the input it always shows up as equaling one, no matter what we do. Please help us, it seemed so simple when we started 11 HOURS AGO! |
Re: Limit Switch Draws Tears
what are you using to discover the value? The Dashboard? If so the default dashboard code returns hard-coded values that do not reflect the status of the system
Make sure the digital module is on slot 4. Also make sure power is properly wired to the sidecar. Try last year's sidecar if you have to. Also try a different limit switch. If you are using the CAN bus for motor control, you could just directly wire the limit switch to the Jaguar and forget about this entire mess |
Re: Limit Switch Draws Tears
Quote:
What are you using as a limit switch? The microswitches I'm familiar with have three connections. |
Re: Limit Switch Draws Tears
As far as we can tell everything is as you say, we have the module in slot 4 and are attemting to get the state of the input directly from the module itself not the dashboard. We simply created an object called Dig4 and set it equal to DigitalInput(1), here's the code.
Code:
#include "WPILib.h"Soo, we are still stuck. |
Re: Limit Switch Draws Tears
Which rule was that? <R54> is the no modifying motors rule.
<R60-L> reads: Quote:
Quote:
|
Re: Limit Switch Draws Tears
This is going to sound very strange, but today (we haven't ever come in on sunday before) my team was supposed to spend 4 hours in the shop to clean up the wires on our bot for a revealing day/ showcase tommorow. After putting everything back together, our robot still didn't run. 5 hours later we realized that a limit switch was creating a short. It took us about a total of 13 hours to get it going. I feel your immense pain.
|
Re: Limit Switch Draws Tears
<<< Dig1 = new DigitalInput(1, 1); >>>
Your digital sidecar is in slot 4, so the line above should be Dig1 = new DigitalInput(4,1); if my memory serves me correctly, assuming that you are using digital input 1 as the code implies. |
Re: Limit Switch Draws Tears
In your constructor, I see this line that stands out:
Code:
Dig1 = new DigitalInput(1, 1);Code:
DigitalInput::DigitalInput(UINT32 slot, UINT32 channel)If you change it to look like this it should read Digital Input #1 from the default digital module (module #4). Code:
Dig1 = new DigitalInput(1); |
Re: Limit Switch Draws Tears
Quote:
Therefore, I would guess that the statement above should be Dig1 = new DigitalInput(4, 4); Or am I missing something? Regards, Mike |
Re: Limit Switch Draws Tears
Quote:
|
Re: Limit Switch Draws Tears
We have tried all of the possible solutions however they have all failed terrifically.
|
Re: Limit Switch Draws Tears
Quote:
Now, don't get me wrong. Your code has more than one problem (like 3 conditions for a Boolean condition) but, for anyone to help, you need to clearly define what is wired and what you want to do, in plain language please... Mike |
Re: Limit Switch Draws Tears
where exactly would these 3 conditions for a boolean variable be?
|
Re: Limit Switch Draws Tears
The digital input is one, or zero.
Don't count on the code handled by the final else statement to ever get executed. if (Dig1->Get() == 0) { jag1->Set(0.0); jag2->Set(0.0); jag3->Set(0.0); jag4->Set(0.0); } else if(Dig1->Get() == 1) { jag1->Set(-leftstick->GetY()); jag2->Set(rightstick->GetY()); jag3->Set(-leftstick->GetY()); jag4->Set(rightstick->GetY()); } else { jag1->Set(-1.0); jag2->Set(1.0); } |
Re: Limit Switch Draws Tears
Ahhh... While I sleep, my minions carry on!
Thanks Doc. A switch is either ON or OFF... |
Re: Limit Switch Draws Tears
Focusing on the limit switch problem:
1. It should be referred to as DigitalInput (1) or DigitalInput (4,1) - nothing else. The first number refers to the slot where your digital module is - in this case Slot 4. 2. Make sure your switch itself is a normally Open type switch Switches come as Normally Open and Normally Closed - closed will always show one unless it is operated in a different way. You can check this using a multimeter. |
Re: Limit Switch Draws Tears
Quote:
There are many times when you want a NC switch. This is particularly true of limit switches. If a wire breaks and the switch is no longer "in the circuit" you want the motor or actuator that you are limiting to stop. This is usually much safer... Regards, Mike |
Re: Limit Switch Draws Tears
Yes yes yes, we understand the dynamics of how a switch works :)
The third condition was just an act of desperation, seeing if anything would work. The switch itself is perfect. It is wired up correctly and everything as previously stated. I believe where our problem lies is within the coding. I think it is declared properly, yet the switch refuses to recognize a closed position. I blame Fate. |
Re: Limit Switch Draws Tears
Quote:
How do you expect anyone to help you? Mike |
Re: Limit Switch Draws Tears
Quote:
Quote:
|
Re: Limit Switch Draws Tears
Make sure your limit switch is wired up between the Signal and Ground wires (and NOT Signal and Power). Signal and Ground are the only two wires you need for a simple limit switch.
Double check with a meter with the switch connected and robot powered on that the voltage across the switch changes from 0 to 5V. I know this might be something you have already done, however I've run into many teams that try and wire the Power and Signal wires to the switch, and verify that the "switch works" by just checking whether the resistance across the switch goes to 0 |
Re: Limit Switch Draws Tears
Now here is where things get interesting. We have read and tried all of the above solutions AND the reason why we posted the code was so that you could better understand our situtation. Just because we had 3 conditions for a boolean operation does not constitute snotty remarks. It is very eaasy to ignore the third condition as that is not our main problem. I think it is you that must read our responses to the solutions posted. Thank you Mr. Lim and those of you who posted solutions, we have tried all of them , but failure seems too proud to leave us this day.
|
Re: Limit Switch Draws Tears
Quote:
You originally said that you had two limit switches wired to DI 4 on the digital sidecar. You then posted a code fragment with this: Dig1 = new DigitalInput(1, 1); which is an example of code that can not possible work. Why? The Analog I/O module must be in slot #1. I replied that the code fragment should have been Dig1 = new DigitalInput(4, 4); assuming the digital I/O module is plugged into slot 4 of the cRIO. You then replied that you had "tried all of the possible solutions" and I asked you to tell us exactly how the switches are wired. You did not. The discussion of three conditions came about because you asked. I merely said that you had more than one issue... I also asked you to tell us what you were trying to accomplish. You did not. The discussion of normally open versus normally closed was especially pertinent as we still do not know how the TWO switches are wired. Since you will not tell us how things are wired we have to guess... Two normally open switches, wired in series and operated one at a time will never close a circuit and always return a 1 in your code... This is an example of why limit switches are almost always wired as normally closed. You were asked to explain your wiring. You did not... You posted code which could not work and you knew that it could not work because you are addressing the analog module... And somehow you infer that we are to blame because we can not read your mind... I am done here... Good luck Mike |
Re: Limit Switch Draws Tears
z2daj,
You need to understand that the CD community consists of VERY good mentors who pretty much could solve your problem in a matter of seconds if they were there and able to collect the information they need. What you perceive as a snotty remark is probably a bit a frustration on our part by the inability to get the information we need. It's a limit switch, and we want to get you up and running ASAP. Can you answer these questions for us? 1. Does your switch, when hooked up with the robot powered on, measure 5V and then change to 0V across the terminals when you press and release your switch? 2. Where exactly is your switch hooked up on the digital side car? Digital I/O 4? Not relays, or PWM? 3. Is there anything else hooked up to this Digital Side Car? Speed controllers? Other switches/sensors? 4. Do these other items on the Digital Side Car work? Are all the green LEDs on? 5. Where is the Digital Side Car hooked up to on the cRIO? To a DIO module in slot 4? Using the originally supplied cable? Are the thumbscrews screwed in? 6. If your switch is hooked up to digital input 4 on the digital side car, and the digital sidecar is hooked up to the cRIO through a DIO module in the fourth slot (fourth counted from the end with the power connector) then your initialization should be: Code:
Dig4 = new DigitalInput(4);6. Add a printf line to the end of your teleop code: Code:
printf("DIO4: %d\n",Dig4->Get());8. The Target Console should now spit out the state of your switch continuously. Does it ever switch from 1 to 0 when you press your switch? 9. Are there any experienced teams in your area you can contact? Two days to burn on a limit switch is too much, and if I were in your shoes, I'd get help in person ASAP. FIRST is a wonderful thing - I'm sure someone would be willing. |
Re: Limit Switch Draws Tears
Ok guys, after re-reading my posts, I would like to apologize for my rudeness. I let my frustration get the better of me. I left it alone for awhile and let somebody else take control. He told me later that he got it working, although I didn't get to ask how due to the snow.
Thank you all for everything and good luck to you and your teams during these final days of the build season. -Zach Jasensky |
| All times are GMT -5. The time now is 21:29. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi