Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Limit Switch Draws Tears (http://www.chiefdelphi.com/forums/showthread.php?t=82695)

z2daj 14-02-2010 23:49

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!

Radical Pi 14-02-2010 23:56

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

Alan Anderson 15-02-2010 00:08

Re: Limit Switch Draws Tears
 
Quote:

Originally Posted by z2daj (Post 920257)
We have wired the two limit switch wires into to the ground and signal connections on input four of the digital sidecar.

Have you verified that the switch works? How?

What are you using as a limit switch? The microswitches I'm familiar with have three connections.

z2daj 15-02-2010 00:14

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"
#include "Vision/AxisCamera.h"
#include "Vision/HSLImage.h"
#include "PIDController.h"
#include "Gyro.h"
#include "Target.h"
#include "DashboardDataSender.h"
#include "Jaguar.h"
#include "Compressor.h"
#include "Solenoid.h"
#include "Victor.h"


class DefaultRobot : public SimpleRobot
{
       
        //RobotDrive *myRobot;                        // robot drive system
        Joystick *rightstick;                        // joystick 2
        Joystick *leftstick;                        // joystick 1
        Gyro *gyro;                                                // gyro initialization
        DashboardDataSender *dds;                // Driver station data sender
        DriverStation *ds;                                // driver station object
        Victor *jag1;// single jaguar motor control
        Victor *jag2;
        Victor *jag3;
        Victor *jag4;
        Compressor *compressor;                // new compressor object
        Solenoid *solleft;                                // solenoid on left
        Solenoid *solright;                                // solenoid on right
        DigitalInput *Dig1;
       
        enum Resolution_t
                {
                        kResolution_320x240
                };
        /*enum                                                        // Driver Station jumpers to control program operation
        { ARCADE_MODE = 1,                                // Tank/Arcade jumper is on DS Input 1 (Jumper present is arcade)
          ENABLE_AUTONOMOUS = 2,                // Autonomous/Teleop jumper is on DS Input 2 (Jumper present is autonomous)
        } jumpers;        */                           

public:
                DefaultRobot(void)
        {
                GetWatchdog().SetEnabled(false);
                ds = DriverStation::GetInstance();
                //myRobot = new RobotDrive(1, 3, 2, 4);        // create robot drive base
                leftstick = new Joystick(1);
                rightstick = new Joystick(2);                        // create the joysticks
                dds = new DashboardDataSender();                // dashboard data sending
               
                compressor = new Compressor(10, 8);  //compressor on ports 10 and 8
                solleft = new Solenoid(1);                        //solenoid on ports 1 and 2(below)
                solright = new Solenoid(2);
                jag1= new Victor(1);
                jag2= new Victor(2);
                jag3= new Victor(3);
                jag4= new Victor(4);
                Dig1 = new DigitalInput(1, 1);
               
                //Update the motors at least every 100ms.
               
               

        }

        /**
        * Drive left & right motors for 2 seconds, enabled by a jumper (jumper
        * must be in for autonomous to operate).
        */
        void Autonomous(void)
        {
               
        }

       
        void OperatorControl(void)
        {
                AxisCamera &camera = AxisCamera::GetInstance();
                camera.WriteResolution(AxisCameraParams::kResolution_320x240);
                camera.WriteBrightness(200);
                while (IsOperatorControl())
                                       
                {        GetWatchdog().Feed();
       
                        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);
                        }
                        compressor->Start();
                        if (leftstick->GetRawButton(2))
                        {
                                //jag->Set(1.0);
                                solleft->Set(1);
                                solright->Set(0);
                        }
                        else
                        {
                                //jag->Set(0.0);
                                solleft->Set(0);
                                solright->Set(1);
                        }
                        //myRobot->TankDrive(rightstick, leftstick);
                        compressor->GetPressureSwitchValue();
                }
                };
       
};START_ROBOT_CLASS(DefaultRobot);

We have also used our multimeter to check the limit switch and the digital side car works for everything else we have used (motors, compressor, gyro and so on). We also found out earlier that this year it is illegal to connect the limit switch directly to the jaguar in accordance to R<54>.

Soo, we are still stuck.

EricH 15-02-2010 00:29

Re: Limit Switch Draws Tears
 
Which rule was that? <R54> is the no modifying motors rule.

<R60-L> reads:
Quote:

L. If CAN-bus functionality is used, limit switch jumpers may be removed from a Jaguar speed controller and a custom limit switch circuit may be substituted (so that the cRIO-FRC may read the status of the limit switches).
Also see:
Quote:

<R68> All outputs from sensors, custom circuits and additional electronics shall connect to only
[...]
G. the CAN-bus if and only if all Jaguar speed controllers on the CAN-bus are wired in full compliance with Rule <R63> and Rule <R64>, or
H. the sensor inputs on the Jaguar speed controller.

John G 15-02-2010 00:34

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.

eugenebrooks 15-02-2010 00:34

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.

MattD 15-02-2010 00:35

Re: Limit Switch Draws Tears
 
In your constructor, I see this line that stands out:

Code:

Dig1 = new DigitalInput(1, 1);
The DigitalInput constructor you're using looks like this:

Code:

DigitalInput::DigitalInput(UINT32 slot, UINT32 channel)
By constructing with DigitalInput(1, 1), it will try to look for a digital input on module 1. This won't work, since that's the analog module.

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);

Mike Betts 15-02-2010 00:37

Re: Limit Switch Draws Tears
 
Quote:

Originally Posted by z2daj (Post 920269)
... Dig1 = new DigitalInput(1, 1);`...

In your original post you state that the swich is wired into input 4 on the digital sidecar. And, as Alan pointed out, the cRIO digital module should be plugged into slot 4.

Therefore, I would guess that the statement above should be

Dig1 = new DigitalInput(4, 4);

Or am I missing something?

Regards,

Mike

Alan Anderson 15-02-2010 00:51

Re: Limit Switch Draws Tears
 
Quote:

Originally Posted by z2daj (Post 920269)
...We simply created an object called Dig4 and set it equal to DigitalInput(1), here's the code.
Code:

                Dig1 = new DigitalInput(1, 1);

[edit]Yeah, lots of people caught this one.[/edit]

z2daj 15-02-2010 01:28

Re: Limit Switch Draws Tears
 
We have tried all of the possible solutions however they have all failed terrifically.

Mike Betts 15-02-2010 01:57

Re: Limit Switch Draws Tears
 
Quote:

Originally Posted by z2daj (Post 920304)
We have tried all of the possible solutions however they have all failed terrifically.

OK. That statement really scares me...

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

z2daj 15-02-2010 02:28

Re: Limit Switch Draws Tears
 
where exactly would these 3 conditions for a boolean variable be?

eugenebrooks 15-02-2010 02:53

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);
}

Mike Betts 15-02-2010 06:10

Re: Limit Switch Draws Tears
 
Ahhh... While I sleep, my minions carry on!

Thanks Doc.

A switch is either ON or OFF...


All times are GMT -5. The time now is 02:19.

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