![]() |
Should this code be working? - Beginner
URGENT:
Code:
package edu.wpi.first.wpilibj.templates;Compressor Relay/Spike Currently, the driving is working and the motors are working but the compressor/relay/spike aren't working. Can someone also explain this: Sometimes when I edit the compressor object and do something like (2,1) as parameters, it says output not updated often enough repeatedly. When I do 1,1 - the program starts with no errors and everything works except compressor and relay/spike. When I do 1,2 --> IT ALSO works except compressor/relay/spike.... I double checked with the electrical team and they say the port numbers should be 1,1 but I'm not sure. I tested with 2,1 - 1,1 - 1,2 and nothing worked. For some port numbers, it would say output not updated enough and some combinations it wouldn't. Does that mean it does connect to compressor or is a connection loose? I'm thinking of switching over to iterative because it might be a bit easier. |
Re: Should this code be working? - Beginner
You are telling the compressor to use Relay 1, and also allocate Relay 1 as an individual relay. You need to make sure they are using different relays. The code will cause an exception if you allocate a relay twice, which will cause the print of output not updated enough repeatedly. If you scroll back to the beginning, you would see the exception message and traceback.
Make sure to pay attention to the constructors you are using. Relay(1,1) allocates Relay 1 on Digital Module 1. Relay(2,1) allocates Relay 1 on Digital Module 2 (which you more then likely don't have). Relay(1,2) allocates Relay 2 on Digital Module 1. Compressor(1,1) allocates a digital input for the pressure switch on digital input 1 and and a relay on relay 1, using the default digital module (1). The compressor monitors the pressure switch on the digital input that you specify, and only turns on the compressor when the pressure is low. You need the pressure switch connected for the compressor to come on. Additionally, the start method should not be called in a loop. It creates it's own look in a new task. You should move it before the while loop in teleop. |
Re: Should this code be working? - Beginner
Do you think if I get this fixed, the code should work?
What if I do: Compressor compressor1 = new Compressor(1,1); //# Relay spike = new Relay (1,2); //# |
Re: Should this code be working? - Beginner
Quote:
You can look at the relay LEDs on the Digital Sidecar to see if the code is working, even if there isn't a relay connected. |
Re: Should this code be working? - Beginner
So it's now just the matter of getting the constructor parameters correct?
|
| All times are GMT -5. The time now is 22:33. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi