We’ve tried wiring the photosensors for threeish days now, and we can’t get a feedback when their wired to the cRIO. Are there any wiring diagrams that anyone has confirmed to work?
How have you wired the power supply to the sensors? The ones used last year required 10.5 volts to work. They worked best wired to the pneumatics module, to assure either 12 or 24 volts being supplied. You only have to wire the output to one of the digitial inputs on the DSC.
Does that help?
If they’re typical of the kind of photosensors often used in FRC, the wiring is simple. Power and common to the sensor comes from a 20 Amp breaker on the Power Distribution Board; the same branch can supply many sensors or other custom circuits. Signal from the sensor goes to the Signal pin of any Digital Input on the Digital Sidecar. That’s it.
Well, I think we tried that. that may mean that the problem lays in the programming.
Usining java, you get to them with the DigitalInput class, right?
can someone tell me if this looks right for making a command be executed whenever three cameras are set off?
DigitalInput camera1, camera2, camera3;
InternalButton button1;
public OI(){
camera1 = new DigitalInput(1);
camera2 = new DigitalInput(2);
camera3 = new DigitalInput(3);
boolean C1 = camera1.get();
boolean C2 = camera2.get();
boolean C3 = camera3.get();
if (C1 && C2 && C3){
button1.setPressed(true);
} else {
button1.setPressed(false);
}
button1.whenPressed(new ThreeCameras());
}
I don’t think the code you have written will work the way you want. The photo sensors are only read once when OI class is created. Is that what you intended? Or did you want the sensors being read during the entire time the robot is operated? I’m going to assume the latter is what you want.
In your main robot class find teleopPeriodic function. In there put calls to read the photo sensors and if all 3 are true start your command. You can do something similar for autonomousPeriodic if you want your command to run in autonomous mode. The *Periodic funcs get called repeatedly while the robot is running. I didn’t test this code. You might want to post further programming questions on the Java section of the forum.
public class YourRobotClass {
DigitalInput camera1, camera2, camera3;
public YourRobotClass() {
camera1 = new DigitalInput(1);
camera2 = new DigitalInput(2);
camera3 = new DigitalInput(3);
}
public void teleopPeriodic() {
Scheduler.getInstance().run();
boolean C1 = camera1.get();
boolean C2 = camera2.get();
boolean C3 = camera3.get();
if (C1 && C2 && C3) {
Command c = new ThreeCameras();
c.start();
}
SmartDashboard.putBoolean("c1", C1);
SmartDashboard.putBoolean("c2", C2);
SmartDashboard.putBoolean("c3", C3);
}
}
Have you read this doc? I found a hint for what you wanted to do on pages 31-36. The examples are in C++ but same thing applies for Java.
http://firstforge.wpi.edu/sf/docman/do/listDocuments/projects.wpilib/docman.root.c_and_java_documentation
Have you seen the youtube videos about using CommandBased templates?
http://www.youtube.com/user/BradAMiller/videos
In the example projects in Netbeans you can open GearsBot sample and see lots of examples of a what a CommandBased robot can do.
Have you also checked that you are getting signals when an object you want to detect is passed in front of the sensors? Not sure if you are using the same model as last year, but those had led lights that changed color to indicate if the sensor was detecting anything or not. And they had to be calibrated.
-Maciej
that may just fix it. I’ll find out tommarow night.
Well, C1, C2, and C3 are being read repetitivly now, but the cameras aren’t actually giving back any signal.
It is wired as follows:
Blue to (-) in PD
Brown to (+) in PD
White to a signal in PWM
PWM to Digital IO on the sidecar
It’s not working. Should the signal have a ground or something?
What kind of a voltage output should we expect to read from the signal on a multimeter?
The photosensor does not output a voltage. It uses its NPN transistor driver to either pull the output wire to ground or to leave it alone. You need to connect it to a pullup resistor in order to be able to measure anything with a voltmeter.
Fortunately, the DIO signal pins on the Digital Sidecar provide exactly the pullup resistor you need. If the photosensor output is connected to a DIO signal pin, you will read 5 volts when the output is inactive, and 0 volts when it is active. (The white wire will be active when an object is detected.)
Have you tried adjusting the set screws on the photo sensors? Or checked what colors the leds are showing to verify the sensor works and is detecting things? You are using the 42EF-D1NAK-A2 ClearSight RightSight correct? I looked up the part on rockwell’s website and found installation instructions. Click on the ‘library’ link and search for something like ‘42EF’. It mentions calibrating the sensor and describes what the led colors mean. If the leds are working then you know you have the sensor calibrated right and should get output on the signal line.
I also remember getting a data sheet with the sensors last year tho I could not find it on Rockwell’s site. Try searching the forums, I found lots of hits from last year, like this one for example:
http://www.chiefdelphi.com/forums/showthread.php?t=88548&highlight=photo+sensors
ok so you put the blue that is negative - and brown is positive + into the power distrabution board with a 20 amp breaker, the you connect the white wire to the white wire on a pwm and hook it up to the sicard
in other words
Blue -> ( - )
Brown -> PWR
White or Black -> SIG