|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Microswitch only returns 0
We need help with our microswitch.
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);
Last edited by MHSrobotics2853 : 23-01-2014 at 21:09. |
|
#2
|
||||||
|
||||||
|
Re: Microswitch only returns 0
You're instantiating the switch on digital module 2, which is probably not what you want.
|
|
#3
|
||||
|
||||
|
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
![]() |
|
#4
|
|||
|
|||
|
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? |
|
#5
|
||||
|
||||
|
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) |
|
#6
|
||||
|
||||
|
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. |
|
#7
|
|||||
|
|||||
|
Re: Microswitch only returns 0
In this case I would expect it tor return a 0 when pressed. Does it return 1 when not pressed?
|
|
#8
|
||||
|
||||
|
Re: Microswitch only returns 0
It doesn't it only returns zero
|
|
#9
|
|||||
|
|||||
|
Re: Microswitch only returns 0
Can you post a wiring diagram of how your switch is wired?
|
|
#10
|
||||
|
||||
|
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.) |
|
#11
|
|||||
|
|||||
|
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?
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|