Go to Post when you think you are here to compete against other teams, thats when bad things start happening... - KenWittlief [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 Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 17-02-2013, 11:36
tuXguy15's Avatar
tuXguy15 tuXguy15 is offline
Team Mentor
AKA: Devin Kolarac
FRC #2559 (Normality Zero)
 
Join Date: Apr 2012
Rookie Year: 2012
Location: Harrisburg, PA
Posts: 127
tuXguy15 is an unknown quantity at this point
Exclamation Photo Switch!

Hello, this is team 2559 and we are trying to set up a photo switch that was used for the line tracker back in 2011. Can anyone help. We are trying to program it in java to activate a pneumatic pump when there the sensor isn't detecting anything. Can you help? We really need to try to get this done since we are out of time and some other teams are coming to our school to practice. Thanks in advanced!
Reply With Quote
  #2   Spotlight this post!  
Unread 17-02-2013, 17:52
alexhenning alexhenning is offline
WPILib Developer
FRC #0348
 
Join Date: Apr 2010
Rookie Year: 2003
Location: MA
Posts: 49
alexhenning will become famous soon enough
Re: Photo Switch!

What issues are you having? Is it wired correctly? Do you have code problems?

A quick search found a few resources that might help:
- http://www.chiefdelphi.com/forums/sh...ad.php?t=89840
- http://www.team2648.com/photoswitches.html
- The Netbeans plugin has the 2011 example code.

Take a look at these and if you have specific questions, post back and I'll try to help.
Reply With Quote
  #3   Spotlight this post!  
Unread 17-02-2013, 21:43
tuXguy15's Avatar
tuXguy15 tuXguy15 is offline
Team Mentor
AKA: Devin Kolarac
FRC #2559 (Normality Zero)
 
Join Date: Apr 2012
Rookie Year: 2012
Location: Harrisburg, PA
Posts: 127
tuXguy15 is an unknown quantity at this point
Re: Photo Switch!

It is a programming problem we have. So what we are trying to do is when there is light we want it to activate our solenoid and when it is dark we want it to close our solenoid. Our solenoid isn't spring resettable this year so here is what i have so far.

================================================== ==========
package edu.wpi.first.wpilibj.templates;

import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.Solenoid;

public class test extends IterativeRobot {

DigitalInput lightsensor = new DigitalInput(2);
Solenoid solenoid5 = new Solenoid(5);
Solenoid solenoid6 = new Solenoid(6);

public void teleopInit() {
solenoid5.set(true)
solenoid6.set(false)
}

public void teleopPeriodic() {
if(lightsensor.getAnalogTriggerForRouting() == false) {
solenoid5.set(false);
solenoid6.set(true);
}else{
solenoid5.set(true);
solenoid6.set(false);
}
}
================================================== ==========
So part of this code works, When the sensor is tripped it reads dark and solenoid 5 is set false and 6 is set true, but when it sees light again it doesnt reset.
Reply With Quote
  #4   Spotlight this post!  
Unread 17-02-2013, 22:49
alexhenning alexhenning is offline
WPILib Developer
FRC #0348
 
Join Date: Apr 2010
Rookie Year: 2003
Location: MA
Posts: 49
alexhenning will become famous soon enough
Re: Photo Switch!

You should replace the line:
if(lightsensor.getAnalogTriggerForRouting() == false) {
with
if(lightsensor.get() == false) {

getAnalogTriggerForRouting() is not what you want to use to get the value of a digital input. The get method returns whether or not it is actually triggered.
Reply With Quote
  #5   Spotlight this post!  
Unread 18-02-2013, 09:48
tuXguy15's Avatar
tuXguy15 tuXguy15 is offline
Team Mentor
AKA: Devin Kolarac
FRC #2559 (Normality Zero)
 
Join Date: Apr 2012
Rookie Year: 2012
Location: Harrisburg, PA
Posts: 127
tuXguy15 is an unknown quantity at this point
Re: Photo Switch!

Ok thanks! I will try this later on this afternoon and let you know how it works out.
Reply With Quote
  #6   Spotlight this post!  
Unread 18-02-2013, 15:58
tuXguy15's Avatar
tuXguy15 tuXguy15 is offline
Team Mentor
AKA: Devin Kolarac
FRC #2559 (Normality Zero)
 
Join Date: Apr 2012
Rookie Year: 2012
Location: Harrisburg, PA
Posts: 127
tuXguy15 is an unknown quantity at this point
Re: Photo Switch!

This didn't work. Is there a different way?
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


All times are GMT -5. The time now is 10:13.

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