Go to Post edit: laptop. yeah as a programmer to not put this in I should be taken out the back and "decompiled". - Stuart [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

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 12-02-2010, 01:57
nathanww nathanww is offline
Hacker
FRC #1678 (Citrus Circuits)
Team Role: Programmer
 
Join Date: Dec 2008
Rookie Year: 2007
Location: Davis, CA
Posts: 224
nathanww is just really nicenathanww is just really nicenathanww is just really nicenathanww is just really nice
Motor declarations break analog module

In which team 1678 continues our saga of stumbling across every frustrating bug that exists:

Today I finished tracking down an error that was causing the analog module on our robot to not function correctly(about 90% of the time when you booted the robot, the analog inputs would be unreadable and it would spew "invalid parameter" errors from low-level analog functions). After replacing the hardware(didn't help), testing with sample code(made the errors go away), cutting out various functions(didn't help), reimaging the cRIO(didn't help), and finally going through and commenting/uncommenting everything line-by-line, I discovered that the cause was actually the declarations of the speed controller classes(victors and jaguars) that we were using to control our kicker and climbing mechanisms.


I really have no idea how this could be causing low-level errors in the analog code, but tests confirmed that this is indeed the case. Even more bizzarrely, the RobotDrive class that we have configured for 4-motor tank drive doesn't interfere with the analog system at all!

Does anyone know what might be going on? Right now, we have to choose between using sensors and using motors.
__________________
Get yer robot source code here!
Reply With Quote
  #2   Spotlight this post!  
Unread 12-02-2010, 08:31
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Motor declarations break analog module

Which slots do you have the cRIO modules installed in?

Show us the part of the code that makes things break. Try to isolate it to something simple so we aren't too distracted by anything irrelevant.
Reply With Quote
  #3   Spotlight this post!  
Unread 12-02-2010, 17:42
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,748
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Motor declarations break analog module

Without viewing the code I'm just guessing, but in my experience, when commenting out code which initializes something and noting bizarre side-effects, it is often useful to look at your compiler warnings or at the code directly for uninitialized variables. The compiler tends to allocate stack variables one after the other except that the optimizer may scramble the order or double up variable declarations. Anyway, if you have an uninitialized variable, these allocations can give your code different behaviors based upon the value that other function calls leave on the stack.

Greg McKaskle
Reply With Quote
  #4   Spotlight this post!  
Unread 12-02-2010, 22:17
nathanww nathanww is offline
Hacker
FRC #1678 (Citrus Circuits)
Team Role: Programmer
 
Join Date: Dec 2008
Rookie Year: 2007
Location: Davis, CA
Posts: 224
nathanww is just really nicenathanww is just really nicenathanww is just really nicenathanww is just really nice
Re: Motor declarations break analog module

Our compiler doesn't give us any warnings about uninitiialized variables, do you think it would be worth tracking everything down just to make sure?

Our robot has an analog module on slot 1, a digital module hooked to the sidecar on slot 4, and a relay module and pneumatics bumper on slot 8.

The code we're using(without the irrelevant things that don't make it break) is :
Code:
class testRobot : public IterativeRobot
{
	
	//set up roller
	Victor *rollerMotor;
	RobotDrive *testDrive;
	Victor *kickerWinch;
	Jaguar *armWinch;
	AnalogChannel *pot;
        Gyro *angle;
	
public:

	testRobot(void)	{
	
		kickerWinch=new Victor(3);	
		armWinch=new Jaguar(1); //TODO:Fix this so we're using both motorz
		rollerMotor=new Victor(4);
		testDrive=new RobotDrive(5,6,7,8);
		angle=new Gyro(1);
		pot=new AnalogChannel(3);
		

	}
...
void RobotInit(void) {
		testDrive->SetInvertedMotor(RobotDrive::kFrontLeftMotor,true);
		testDrive->SetInvertedMotor(RobotDrive::kFrontLeftMotor,true);
		pot->SetAverageBits(30);
		
	}
...
void DisabledPeriodic(void)  {
		GetWatchdog().Feed();
		printf(" pot=%f\n ",pot->GetAverageVoltage());
	
	}
__________________
Get yer robot source code here!
Reply With Quote
  #5   Spotlight this post!  
Unread 12-02-2010, 23:10
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,561
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Motor declarations break analog module

Why did you choose to set the average bits to 30? By my calculations, you'll get a new value every 4 hours or so (if the FPGA even supports a value that large). A more reasonable value is 10, which will get you updates at about 50hz.

If you actually wanted it to average 30 samples, you should set the average bits to 5, since 2^5 is 32.

Last edited by Joe Ross : 12-02-2010 at 23:16.
Reply With Quote
  #6   Spotlight this post!  
Unread 12-02-2010, 23:37
nathanww nathanww is offline
Hacker
FRC #1678 (Citrus Circuits)
Team Role: Programmer
 
Join Date: Dec 2008
Rookie Year: 2007
Location: Davis, CA
Posts: 224
nathanww is just really nicenathanww is just really nicenathanww is just really nicenathanww is just really nice
Re: Motor declarations break analog module

I beleieve the person who put that in thought that 30 bits=30 samples, or she might have just been testing an extreme amount because we were having problems with noise on the input. I have to check with her, though. In any case, the FPGA seems to be limiting it to a more reasonable number since the update rate is at least 10 hz.
__________________
Get yer robot source code here!
Reply With Quote
  #7   Spotlight this post!  
Unread 14-02-2010, 22:59
nathanww nathanww is offline
Hacker
FRC #1678 (Citrus Circuits)
Team Role: Programmer
 
Join Date: Dec 2008
Rookie Year: 2007
Location: Davis, CA
Posts: 224
nathanww is just really nicenathanww is just really nicenathanww is just really nicenathanww is just really nice
Re: Motor declarations break analog module

And it is fixed!

What happened, we believe, was that the 30-bit averaging, combined with the motor stuff, was using too much FPGA memory and the errors that we were getting were the result of an out-of-memory condition. The system now works after we reduced the averaging bits to 10.
__________________
Get yer robot source code here!
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Open motor reference on Slot 6 DIO Module trilogy2826 NI LabVIEW 2 27-01-2009 08:42
spring break thatphotochick Chit-Chat 6 29-03-2006 17:41
Taking apart the motor control module Adam Y. FIRST Tech Challenge 1 15-04-2005 14:02
Module 7 gear -- fischer price motor archiver 2001 6 23-06-2002 22:55
DC Motor current to an Analog Input junkyarddawg Motors 43 04-04-2002 15:53


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

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