Go to Post ....a red-light-of-death. - Kevin Watson [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #14   Spotlight this post!  
Unread 06-05-2010, 19:42
Radical Pi Radical Pi is offline
Putting the Jumper in the Bumper
AKA: Ian Thompson
FRC #0639 (Code Red Robotics)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2010
Location: New York
Posts: 655
Radical Pi has a spectacular aura aboutRadical Pi has a spectacular aura aboutRadical Pi has a spectacular aura about
Re: Help with PSoC board programming please

switch is a bool variable. Did you declare it? dsio being unused is an effect of the = error because the compiler doesn't recognize that line as valid, so no go on using it.

Also, the logic on your version is bad. My version was writing the value of the digital in to a variable. Yours is using that value in a switch statement, which is used when you have different values to run between (a fancy if statement pretty much). Additionally, you are ending the switch without any code because of the ; at the end of the line. You then go onto write a block of code that will execute on every loop. Plus you throw a wait in there. not good. It will compile, but most likely will not run.

This is what I think you want:
Code:
void OperatorControl() {
DriverStationEnhancedIO &dsio = DriverStation::GetInstance()->GetEnhancedIO();
// moar code
if (dsio.GetDigital(1)) {
motor->Set(1.0);
Wait(1.0);
motor->Set(0.0);
}
Now, onto what you are actually doing. Assuming this is executing in the same task as the rest of the teleop code, by flipping the switch you are locking up the robot's controls for a whole second. That means you have no control over the robot for that second. And if you don't release the switch before the next loop of OperatorControl, you will be stuck for another second without control (this system usually loops on the order of milliseconds assuming no camera code). Also, if you are using the watchdog (which, considering what this code would do, I really hope you are), once you hit this code the watchdog will starve until the beginning of the next loop (or whenever you feed it).

If you absolutely need the 1 second run of the motor, I suggest you export the code for this to another task and communicate via a class variable
__________________

"To have no errors would be life without meaning. No strugle, no joy"
"A network is only as strong as it's weakest linksys"
Reply With Quote
 


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
Help with PSoC board wiring please krudeboy51 Electrical 1 04-05-2010 16:17
Attaching Psoc Board to breadboard nickcvet89 FRC Control System 2 10-03-2010 12:27
Windows "Malfunctioning USB Device" error with Psoc IO Board WarrenPW FRC Control System 2 11-02-2010 18:53
Wiring Switches to the PSoC board Raj1977 Electrical 13 07-02-2010 23:24
Help with programming new controllers, please. Oumonkey Programming 6 30-11-2006 21:53


All times are GMT -5. The time now is 14:24.

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