Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Electrical (http://www.chiefdelphi.com/forums/forumdisplay.php?f=53)
-   -   Microswitch only returns 0 (http://www.chiefdelphi.com/forums/showthread.php?t=125136)

MHSrobotics2853 23-01-2014 21:06

Microswitch only returns 0
 
We need help with our microswitch. :confused:

We've tested it with the multimeter (returns 5V when not pressed 0V pressed). When we press it, it won't return 1, the only value it returns is 0.

It's plugged into the Digital I/O port (we've already swapped out three sidecars so we know that that's not the issue). Our code is as follows:
Code:


#include "WPILib.h"
#include <DigitalInput.h>
#include <DigitalOutput.h>
#include <DigitalSource.h>

class RobotDemo : public SimpleRobot
{
        DigitalInput micro;
       
public:
        RobotDemo(void):
                micro(2,14)
                {       
                }
        void Autonomous()
        {
        }
        void OperatorControl()
        {
                while (IsOperatorControl())
                {       
                        DriverStationLCD *groundhogs = DriverStationLCD::GetInstance();
                        while (micro.Get() == 0)
                        {
                                groundhogs -> PrintfLine(DriverStationLCD::kUser_Line2, "I'm not pressed!");
                                Wait (0.005);
                                groundhogs -> UpdateLCD();
                        }
                        groundhogs -> PrintfLine(DriverStationLCD::kUser_Line2, "I'm pressed!");
                        Wait (0.005);
                        groundhogs -> UpdateLCD();
                }
        }
       
        /**
        * Runs during test mode
        */
        void Test() {
               
        }
};

START_ROBOT_CLASS(RobotDemo);

We've been ripping out our hair over this for two days already. Any suggestions/answers/holy revelations? Thanks!

Joe Ross 23-01-2014 21:10

Re: Microswitch only returns 0
 
You're instantiating the switch on digital module 2, which is probably not what you want.

MHSrobotics2853 23-01-2014 21:13

Re: Microswitch only returns 0
 
We've already tried it as (14) and (1,14). (2,14) was our most recent trial. Still won't work :(

MrRoboSteve 23-01-2014 21:26

Re: Microswitch only returns 0
 
1. How exactly do you have it wired?
2. Try changing the cable that connects the sidecar to the cRIO
3. Does it work on another port?

MHSrobotics2853 24-01-2014 00:09

Re: Microswitch only returns 0
 
1. Digital module to sidecar (occupies second slot on the cRIO), sidecar to switch on the Digital IO row
2. We have already switched but it still hasn't worked
3. No, not on any port (we've literally tried all of them)

otherguy 24-01-2014 00:20

Re: Microswitch only returns 0
 
how is your limit switch wired?

The digital sidecar has internal pullup resistors on its input channels. This means that when nothing is connected to the pins it sees 5v.

Your switch should have a ground and a signal wire connected to it (5v isnt' required). Per your stated wiring, when the switch is pressed, the signal wire should be shorted to ground. If this is not the case, then you won't see a logic level state change at the digital side car.

kevin.li.rit 24-01-2014 00:23

Re: Microswitch only returns 0
 
Quote:

Originally Posted by MHSrobotics2853 (Post 1331471)
We've tested it with the multimeter (returns 5V when not pressed 0V pressed). When we press it, it won't return 1, the only value it returns is 0.

In this case I would expect it tor return a 0 when pressed. Does it return 1 when not pressed?

MHSrobotics2853 24-01-2014 00:35

Re: Microswitch only returns 0
 
Quote:

Originally Posted by kevin.li.rit (Post 1331566)
In this case I would expect it tor return a 0 when pressed. Does it return 1 when not pressed?

It doesn't it only returns zero

kevin.li.rit 24-01-2014 00:38

Re: Microswitch only returns 0
 
Can you post a wiring diagram of how your switch is wired?

MHSrobotics2853 24-01-2014 01:01

Re: Microswitch only returns 0
 


Its our test bed; the microswitch is in the lower right connected to the Digital IO slot in the sidecar, which is connected to the second cRIO module slot.

(Ignore bunch of arrows coming out of the sidecar, mocked this up real quick.)

Alan Anderson 24-01-2014 01:22

Re: Microswitch only returns 0
 
You're only showing one connection for your switch, and its ends aren't labeled with anything specific. People keep asking you how you have it wired, and obviously you aren't understanding the level of detail they're looking for. What pins on the Digital Sidecar connect to what terminals on the switch?

MHSrobotics2853 24-01-2014 01:28

Re: Microswitch only returns 0
 

We wired the switch like this. It's hooked up to the third row of pins in the digital IO column (ground next to the port number, signal next to the guard)

Please don't be angry with us :/ Nuances in text and the group we have this year is pretty new to the forums.

Alan Anderson 24-01-2014 01:52

Re: Microswitch only returns 0
 
Do you read a 1 from the switch when it isn't physically plugged in? If so, then your switch might be faulty.

If you still read 0 from a digital input that isn't connected to anything, then there's a software or wiring problem elsewhere and we'll have to do some deeper troubleshooting. Start by describing for us what the big orange Robot Signal Light is doing.

kevin.li.rit 24-01-2014 02:22

Re: Microswitch only returns 0
 
Is this returning the fatal instance and returning 0?

Is micro.get() passing enough parameters to read the digital I?

otherguy 24-01-2014 14:42

Re: Microswitch only returns 0
 
1 Attachment(s)
The wires going to the switch look ok, is it plugged into the digital sidecar like shown in the attachment?

Attachment 15941

MHSrobotics2853 25-01-2014 03:03

Re: Microswitch only returns 0
 
DigitalInput input(5) is declared as part of the constructor. Calling input.Get() always returns zero when nothing is connected. Probing ground versus signal on the digital sidecar DIO line is reporting 4 Volts when nothing is connected. We tried swapping out cRIOs, Digital modules, digital module cable to sidecar, and sidecars and the problem still persists. We are trying to uninstall windriver and re-install next since we accidentally installed 3.3 on a 32-bit system. I don't know if this would be the cause of the problem but it's worth a try. We don't have the robot signal light installed, but the led that is next to the location where the wire would go is blinking.
Any other suggestions would be helpful as we've never seen this problem before for the past 3 years. Thanks.

kevin.li.rit 25-01-2014 08:50

Re: Microswitch only returns 0
 
Maybe try setting the if fatal return 0 to return 2 instead to see if it reads 0 it or is meeting the fatal condition in get().

MHSrobotics2853 25-01-2014 18:27

PROBLEM SOLVED :D
 
We solved our problem we had found the source of our error, we had not imaged our cRIO correctly, we used our image from last year. But anyways thank you so much for all your help.

DonRotolo 26-01-2014 09:04

Re: Microswitch only returns 0
 
Quote:

Originally Posted by MHSrobotics2853 (Post 1331600)
Please don't be angry with us :/ Nuances in text and the group we have this year is pretty new to the forums.

Not angry! Just getting more forceful in asking for specifics. You see, we really DO want to help solve the problem: It's how WE learn, too.

Verify the Digital Sidecar connections for us please, and if that is as specified above, then it's not the switch.

Answer these specifically:
What is the RSL doing?
What are the 3 green LEDs on the DSC (by the RSL connection) doing?

Thanks.


All times are GMT -5. The time now is 04:59.

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