Go to Post It is possible to live without the Big sponsors, it just takes a lot of fund raising and hard work. - Raumiester2010 [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 03-12-2010, 04:09 PM
TheGrassyNull~ TheGrassyNull~ is offline
"-TheGrassyNull-"
FRC #3012
 
Join Date: Jan 2010
Rookie Year: 2009
Location: Katy, Tx
Posts: 1
TheGrassyNull~ is an unknown quantity at this point
Exclamation cRIO upgrade v20 relay problems

The relay code behavior appears to have changed when we updated the cRio firmware from v19 to v20.

The relay is set into forward only mode. When a joystick button is pushed, the relay is turned "on" (sets it to kOn). Our code then sleeps for 500 ms, then turns the relay off (sets it to kOff).
Before the update to v20, this worked as expected. The relay light would turn green for half a second, then turn back to amber. Now, it only stays green for maybe a tenth of a second. We increased the sleep time to several seconds, but it is having no effect. It seems like the relay code is turning itself off. Any ideas about what could have happened?

Last edited by TheGrassyNull~ : 03-12-2010 at 04:23 PM.
Reply With Quote
  #2   Spotlight this post!  
Unread 03-12-2010, 09:49 PM
TubaMorg TubaMorg is offline
Programmermechanicalelect ricalcoach
AKA: Dan
FRC #1480 (Robatos Locos)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Houston
Posts: 450
TubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond repute
Re: cRIO upgrade v20 relay problems

99.99999999% of the time, programmers will correlate mysterious bugs with things like Windows updates, daylight savings time, tacos at lunch, and updating the cRio to v20. In actuality, the program was changed at around the same time and now it doesn't work. Post your code and we can fix it regardless of what version your cRio is running.

Without seeing your code, though, I might suggest that you use a timer to control time sensitive actions. It's not a good idea to pause your robot code. Imagine if you just passed out for .5 seconds then woke up. You would be confused. It is better practice to let your code cycle so that all the sensor and user input can be processed and acted upon. So for your relay, you would start the timer when the button is pushed, set the relay to kOn until the timer reaches your setpoint, then kOff.
__________________
I don't need a signature.

Last edited by TubaMorg : 03-12-2010 at 09:59 PM.
Reply With Quote
  #3   Spotlight this post!  
Unread 03-12-2010, 11:46 PM
MattD's Avatar
MattD MattD is offline
Registered User
AKA: Matthew Douglas
FRC #0228 (GUS Robotics)
Team Role: Alumni
 
Join Date: Feb 2006
Rookie Year: 2005
Location: Indianapolis, IN
Posts: 185
MattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to beholdMattD is a splendid one to behold
Send a message via AIM to MattD
Re: cRIO upgrade v20 relay problems

To elaborate on the previous post, the last update to WPILibJ enables the watchdog by default and sets the timeout to 0.1 seconds. Since your user program is sleeping the watchdog is not being fed and the output is disabled after the tenth of a second as described. I would recommend to use a timer or a separate thread for this rather than pause all of your code.
__________________
GUS Robotics Team 228

2010 WPI Engineering Inspiration Award
2010 WPI Regional Champions (Thanks 230 & 20!)
2010 CT VEX Champions
2010 CT VEX Innovate Award
2009 QCC VEX Champions
2009 CT Motorola Quality Award
2007 CT J&J Sportsmanship Award
2006 CT Best Website Award
Reply With Quote
  #4   Spotlight this post!  
Unread 03-22-2010, 10:24 AM
Lakedaimon's Avatar
Lakedaimon Lakedaimon is offline
Registered User
FRC #3012 (Spartans)
Team Role: Teacher
 
Join Date: Nov 2008
Rookie Year: 2003
Location: Cypress Lakes HS, Katy, TX
Posts: 23
Lakedaimon is an unknown quantity at this point
Re: cRIO upgrade v20 relay problems

So it seems that I was not blaming the problem on the change of phase of the moon after all. This did result from the update to v20. Thank you, MattD, for your cordial and knowledgeable response.
__________________
Firmware is the most expensive thing in the universe. - Jack G. Ganssle
Reply With Quote
  #5   Spotlight this post!  
Unread 03-22-2010, 11:22 AM
Lakedaimon's Avatar
Lakedaimon Lakedaimon is offline
Registered User
FRC #3012 (Spartans)
Team Role: Teacher
 
Join Date: Nov 2008
Rookie Year: 2003
Location: Cypress Lakes HS, Katy, TX
Posts: 23
Lakedaimon is an unknown quantity at this point
Re: cRIO upgrade v20 relay problems

Our code looks like this -

relay7.set(Relay.Value.kOn);
// delay half second
try { Thread.sleep(500);
} catch( InterruptedException e ){}
relay7.set(Relay.Value.kOff);

I think this should yield to the rest of the system and allow whatever needs to happen with the watchdog to happen, no?

Is there some code concerning the watchdog that we may not have changed like we should have?
__________________
Firmware is the most expensive thing in the universe. - Jack G. Ganssle
Reply With Quote
  #6   Spotlight this post!  
Unread 03-22-2010, 12:20 PM
Lakedaimon's Avatar
Lakedaimon Lakedaimon is offline
Registered User
FRC #3012 (Spartans)
Team Role: Teacher
 
Join Date: Nov 2008
Rookie Year: 2003
Location: Cypress Lakes HS, Katy, TX
Posts: 23
Lakedaimon is an unknown quantity at this point
Re: cRIO upgrade v20 relay problems

OK, I think the light bulb over my head is beginning to make buzzing noises and glow dimly.

We have not tried this yet (and please correct me if I am wrong), but it appears that the user watchdog is set to timeout after .1 seconds, and since our user code is sleeping for .5 seconds, nobody is kicking the dog, and it is therefore zapping us.

First, this evening we are going to try just disabling the user watchdog during init to see if that corrects the issue(?) Based on the results of that test, we will investigate changing the structure of our code to put some kind of dog-kicking mechanism into a separate thread, or setting the timeout on the watchdog to 1 second, or leave it disabled. (If leaving it disabled is verboten, PLEASE let me know!)

Assuming we are now merrily on our way, thanks for the input!
__________________
Firmware is the most expensive thing in the universe. - Jack G. Ganssle

Last edited by Lakedaimon : 03-22-2010 at 12:28 PM.
Reply With Quote
  #7   Spotlight this post!  
Unread 03-22-2010, 12:33 PM
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,069
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: cRIO upgrade v20 relay problems

Quote:
Originally Posted by Lakedaimon View Post
OK, I think the light bulb over my head is beginning to make buzzing noises and glow dimly.

We have not tried this yet (and please correct me if I am wrong), but it appears that the user watchdog is set to timeout after .1 seconds, and since our user code is sleeping for .5 seconds, nobody is kicking the dog, and it is therefore zapping us.

First, this evening we are going to try just disabling the user watchdog during init to see if that corrects the issue(?) Based on the results of that test, we will investigate changing the structure of our code to put some kind of dog-kicking mechanism into a separate thread, or setting the timeout on the watchdog to 1 second, or leave it disabled. (If leaving it disabled is verboten, PLEASE let me know!)

Assuming we are now merrily on our way, thanks for the input!
Sounds like you have it figured out. The best way to deal with this is to do your delaying asynchronously via a timer, thus letting your Watchdog get fed (not kicked! ) by your main thread of execution. But turning off the Watchdog or setting the timeout to something longer than your delay would also be technically correct (if a bit more unsafe). Making a separate thread to feed your Watchdog is not something that I would not recommend (having a safety mechanism in place that does nothing to ensure safety is arguably worse than having none at all).
Reply With Quote
  #8   Spotlight this post!  
Unread 03-22-2010, 01:04 PM
EricVanWyk EricVanWyk is offline
Registered User
no team
 
Join Date: Jan 2007
Rookie Year: 2000
Location: Boston
Posts: 1,597
EricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond repute
Send a message via AIM to EricVanWyk
Re: cRIO upgrade v20 relay problems

I know that in LV, there is a "Delay and Feed" VI that does what you are looking for. I'll assume there is an equivalent in Java.

Basically, it waits for the given amount of time while feeding the watchdog. No need for extra loops or yields or whatnot!
Reply With Quote
  #9   Spotlight this post!  
Unread 03-22-2010, 01:13 PM
TubaMorg TubaMorg is offline
Programmermechanicalelect ricalcoach
AKA: Dan
FRC #1480 (Robatos Locos)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Houston
Posts: 450
TubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond repute
Re: cRIO upgrade v20 relay problems

I agree with Jared that you should apply a timer to your timed functions (as mentioned previously). Your idea of starting another thread for the watchdog is interesting, but I'm not sure if it will work as the watchdog is attached to your RobotBase which is extended by IterativeRobot and SimpleRobot. It is, in general, ok to disable the watchdog to test problems, but the robot should be up on blocks. You cannot disable a runaway robot that is no longer listening to controls, which is the reason why the watchdog is there. Here is how we handle our kick timer (in stripped down code)

Code:
public class IRobot extends IterativeRobot
{
 
    Timer robotTime = new Timer();
    
    Joystick js_right = new Joystick(1);
    Joystick js_left = new Joystick(2);
    Solenoid latch = new Solenoid(1);
    Solenoid unlatch = new Solenoid(2);
    Solenoid kick1 = new Solenoid(3);
    Solenoid unkick1 = new Solenoid(4);

    public void robotInit()
    {

        this.getWatchdog().setEnabled(true);
        this.getWatchdog().setExpiration(.2);
        this.getWatchdog().feed();
        robotTime.reset();
        robotTime.stop();
    }

    
    public void disabledPeriodic()
    {
        this.getWatchdog().feed();
      
    
    /**
     * This function is called periodically during operator control
     */
    public void teleopPeriodic()
    {

       

        //***************Kicker Controls*****************
        if (!kicking && js_left.getTrigger())
        {
            kicking = true;
        }
        if (kicking)
        {
            kickTimer();
        }

    
    }

    public boolean kickTimer()
    {
        
        if (robotTime.get() == 0)
        {
            // KICK
            latch.set(false);
            unlatch.set(true);
            robotTime.start();
        } else if (robotTime.get() >= 0.5)
        {
            // RETRACT
            latch.set(true);
            unlatch.set(false);
            kick1.set(false);
            unkick1.set(true);
        }
        if (robotTime.get() >= 4)
        {
            // GET READY TO KICK AGAIN
            kick1.set(true);
            unkick1.set(false);
            kicking = false;
            robotTime.stop();
            robotTime.reset();
        }
        return kicking;
    }
It should be noted that the Timer object here is the one defined by the WPI library and NOT the one defined by java.util.
__________________
I don't need a signature.
Reply With Quote
  #10   Spotlight this post!  
Unread 03-22-2010, 01:17 PM
Michael DiRamio Michael DiRamio is offline
Registered User
FRC #1114 (Simbotics)
Team Role: Teacher
 
Join Date: Jan 2006
Rookie Year: 2006
Location: St. Catharines, Ontario, Canada
Posts: 39
Michael DiRamio has a reputation beyond reputeMichael DiRamio has a reputation beyond reputeMichael DiRamio has a reputation beyond reputeMichael DiRamio has a reputation beyond reputeMichael DiRamio has a reputation beyond reputeMichael DiRamio has a reputation beyond reputeMichael DiRamio has a reputation beyond reputeMichael DiRamio has a reputation beyond reputeMichael DiRamio has a reputation beyond reputeMichael DiRamio has a reputation beyond reputeMichael DiRamio has a reputation beyond repute
Re: cRIO upgrade v20 relay problems

It's also possible that an exception is being thrown by the wait.

It's a good idea to always output something in the catch statement just in case an exception is thrown.

Something like

Code:
try {
  // your code that may throw exception
} catch (Exception e) {
   System.err.println(e);  // this will print the stack trace of the exception
}
This way you'll be able to tell in the output if something wacky is happening.
Reply With Quote
  #11   Spotlight this post!  
Unread 03-23-2010, 02:02 PM
Lakedaimon's Avatar
Lakedaimon Lakedaimon is offline
Registered User
FRC #3012 (Spartans)
Team Role: Teacher
 
Join Date: Nov 2008
Rookie Year: 2003
Location: Cypress Lakes HS, Katy, TX
Posts: 23
Lakedaimon is an unknown quantity at this point
Re: cRIO upgrade v20 relay problems

Our test (disabling the user watchdog) did "correct" the issue. We are now looking at what our real fix will be. Thanks for all the input!

And FYI, if you look at my avatar, you will see that it is OK for me to refer to it as "kicking the dog", since I am a virtual dog in CD space.
__________________
Firmware is the most expensive thing in the universe. - Jack G. Ganssle
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
crio looses comm and code after V20 upgrade. ksanger Programming 5 03-07-2010 11:51 AM
cRIO v20 Update Problems PaulRevere Java 29 02-22-2010 11:48 AM
Relay problems DJ KELLEY NI LabVIEW 5 02-21-2010 01:53 PM
multiple cRIO relay (solenoid) modules? Alan Anderson FRC Control System 15 02-06-2010 05:41 PM
Relay Problems starsROBOTICS NI LabVIEW 2 01-30-2009 11:40 PM


All times are GMT -5. The time now is 08:34 AM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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