![]() |
Solenoid Breakout Code Help
Hi CD!
I was wondering if anyone could take 5 minutes and briefly review our code for the Solenoid Breakout attached to the NI Module 9472. We code in C++ using Windriver Workbench. Thanks in advance! #include "WPIlib.h" #include "compressor.h" class RobotDemo : public SimpleRobot { RobotDrive Frankbot; // robot drive system Joystick leftjoy; Joystick rightjoy; Joystick joystick3; Relay Pulley; Relay piston1; Relay Arm; // PistonHelper Relay PistonHelper; //Actual Arm // Jaguar Winch; public: RobotDemo(void): Frankbot(1, 2), //these are the PWM ports leftjoy(1), rightjoy(2), joystick3(3), Pulley(2), piston1(4), Arm (5), PistonHelper (8) // Winch (4) { // usermessages = DriverStationLCD::GetInstance(); // Camera->WriteResolution(AxisCamera::kResolution_160x120 ); // Camera->WriteCompression(20); // Camera->WriteWhite // Balance(AxisCameraParams::kWhiteBalance_FixedIndoo r); // Camera->WriteMaxFPS(30); // Camera = &AxisCamera::GetInstance(); // myRobot.SetExpiration(0.1); // test } void Autonomous(void) { Compressor *c = new Compressor(1, 1); c->Start(); } void OperatorControl(void) { Solenoid*solenoidOne; Solenoid*solenoidTwo; solenoidOne = new Solenoid(8,1); solenoidTwo = new Solenoid (8,8); int up = 4; int down = 5; int WinchIn = 2; int WinchOut = 1; int ArmIn = 1; int ArmOut = 2; int On = 6; int Off = 3; int ArmUp = 2; int ArmDown = 1; int Sol1 = 3; int Sol2 = 4; static float speedModifier = 1.00; // static float winchspeed = 1.00; Compressor *c = new Compressor(1, 1); c->Start(); Frankbot.SetSafetyEnabled(true); while (IsOperatorControl()) { if(leftjoy.GetRawButton(Sol1)){ solenoidOne->Set(true); solenoidTwo->Set(false); } else{ solenoidOne->Set(false); solenoidTwo->Set(true); } } } }; START_ROBOT_CLASS(RobotDemo); |
Re: Solenoid Breakout Code Help
You should upload it to Pastebin or something similar for easier interpreting. It's hard to keep of brackets without any spacing.
|
Re: Solenoid Breakout Code Help
Aside from the brackets is there anything else, i've been playing around with this code and i cant seem to get it to work at all, Thank You
|
Re: Solenoid Breakout Code Help
Quote:
|
Re: Solenoid Breakout Code Help
Hint: surround your code with [ code] and [ /code] tags. It'll preserve whitespace that way.
Code:
solenoidOne = new Solenoid(8,1);Code:
if(leftjoy.GetRawButton(Sol1)){ |
Re: Solenoid Breakout Code Help
the 8 is supposed to represent the slot we put the NI 9472 into, and yeah we are using a double solenoid
class RobotDemo : public SimpleRobot { RobotDrive Frankbot; // robot drive system Joystick leftjoy; Joystick rightjoy; Joystick joystick3; Jaguar Flipper; Relay piston1; Relay Arm; // PistonHelper Relay PistonHelper; //Actual Arm Solenoid sol1; Solenoid sol2; // Jaguar Winch; public: RobotDemo(void): Frankbot(1, 2), //these are the PWM ports leftjoy(1), rightjoy(2), joystick3(3), Flipper(7), piston1(6), Arm (5), PistonHelper (8), sol1(3, 1), sol2(3, 2) public: RobotDemo(void): sol1(3, 1), sol2(3, 2) if(leftjoy.GetRawButton(sol)){ sol1.Set(true); sol2.Set(false); } else if(leftjoy.GetRawButton(sol4)){ sol2.Set(true); sol1.Set(false); } else { sol1.Set(false); sol2.Set(false); } i made some adjustments, but the code still doesnt work |
Re: Solenoid Breakout Code Help
I think you're working from documentation that is out of date by many years.
Quote:
Slot 8 of an 8-slot cRIO is always empty. |
Re: Solenoid Breakout Code Help
Quote:
|
Re: Solenoid Breakout Code Help
Quote:
|
| All times are GMT -5. The time now is 02:35. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi