Go to Post I <3 statistics. - Barry Bonzack [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 03-01-2008, 21:37
EHaskins EHaskins is offline
Needs to change his user title.
AKA: Eric Haskins
no team (CARD #6 (SCOE))
Team Role: College Student
 
Join Date: Jan 2006
Rookie Year: 2006
Location: Elkhorn, WI USA
Posts: 998
EHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond repute
Send a message via MSN to EHaskins
Interrupt issue with new code

I've been trying to write the drive code for my current prototype drive, but I'm having issues.

This is the setup:
Hardware:
BaneBots gearbox connected to pwm01
Banebots encoder kit and encoder divider board installed on the gearbox.
Divider direction connected to rc_dig_in07
Divider speed connected to rc_dig_in03

Software:
Kevin's new code
In "interrupts.h"
#define ENABLE_INT_3_6 un-commented
In "teleop.c"
"Initialize_Int_3_6();" added to Initialization() where comments indicate.
Code:
void Teleop(void)
{
	static int i, j;
	i ++;
	j ++;

	if (i > 20)
	{
		printf("Encoder 1 Direction = %d\r\n", (int)ENCODER_ONE_DIRECTION);
		printf("Encoder 1 = %d\r\n\r\n", (int)Encoder_One_Count());
		i = 0;
	}

             //Run motor to demomstrate proper functioning
	if (j < 100)
	{
		Motor(1, 50);//in drive.c
	}
	else if (j < 150)
	{
		Motor(1, 0);
	}
	else if (j < 250)
	{
		Motor(1, -50);
	}
	else if (j < 300)
	{
		Motor(1, 0);
	}
	else
	{
		j = 0;
	}
	//Update_OI_LEDs();	// located in ifi_code.c
}
In "interrupts.c"
Call to "Encoder_One_Tick()"(in Drive.c) added in Int_3_Handler

EDIT: I attached the drive.c/.h files
The Direction displays correctly, but the count is always 0.

I'm sure I forgot something really simple, but I can't figure it out.

I'll send the complete project to anyone who wants to look at it.
Attached Files
File Type: c drive.c (854 Bytes, 80 views)
File Type: h drive.h (220 Bytes, 70 views)
__________________
Eric Haskins KC9JVH
  #2   Spotlight this post!  
Unread 04-01-2008, 01:32
billbo911's Avatar
billbo911 billbo911 is offline
I prefer you give a perfect effort.
AKA: That's "Mr. Bill"
FRC #2073 (EagleForce)
Team Role: Mentor
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Elk Grove, Ca.
Posts: 2,350
billbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond repute
Re: Interrupt issue with new code

Quote:
Originally Posted by EHaskins View Post
I've been trying to write the drive code for my current prototype drive, but I'm having issues.

This is the setup:
Hardware:
BaneBots gearbox connected to pwm01
Banebots encoder kit and encoder divider board installed on the gearbox.
Divider direction connected to rc_dig_in07
Divider speed connected to rc_dig_in03

Software:
Kevin's new code
In "interrupts.h"
#define ENABLE_INT_3_6 un-commented
In "teleop.c"
"Initialize_Int_3_6();" added to Initialization() where comments indicate.
Code:
void Teleop(void)
{
	static int i, j;
	i ++;
	j ++;

	if (i > 20)
	{
		printf("Encoder 1 Direction = %d\r\n", (int)ENCODER_ONE_DIRECTION);
		printf("Encoder 1 = %d\r\n\r\n", (int)Encoder_One_Count());
		i = 0;
	}

             //Run motor to demomstrate proper functioning
	if (j < 100)
	{
		Motor(1, 50);//in drive.c
	}
	else if (j < 150)
	{
		Motor(1, 0);
	}
	else if (j < 250)
	{
		Motor(1, -50);
	}
	else if (j < 300)
	{
		Motor(1, 0);
	}
	else
	{
		j = 0;
	}
	//Update_OI_LEDs();	// located in ifi_code.c
}
In "interrupts.c"
Call to "Encoder_One_Tick()"(in Drive.c) added in Int_3_Handler

EDIT: I attached the drive.c/.h files
The Direction displays correctly, but the count is always 0.

I'm sure I forgot something really simple, but I can't figure it out.

I'll send the complete project to anyone who wants to look at it.
I think you are right. The error looks simple to me as well. I think the reason you aren't seeing the count change is because the code in your ISR to do the increment/decrement is commented out. It looks like it should work correctly if the whack whacks and whack star and star whacks were removed.

Code:
void Encoder_One_Tick(void)
{
	//if (ENCODER_ONE_DIRECTION)
	//{
		_countOne ++;
	/*}
	else
	{
		_countOne --;
	}*/
}
__________________
CalGames 2009 Autonomous Champion Award winner
Sacramento 2010 Creativity in Design winner, Sacramento 2010 Quarter finalist
2011 Sacramento Finalist, 2011 Madtown Engineering Inspiration Award.
2012 Sacramento Semi-Finals, 2012 Sacramento Innovation in Control Award, 2012 SVR Judges Award.
2012 CalGames Autonomous Challenge Award winner ($$$).
2014 2X Rockwell Automation: Innovation in Control Award (CVR and SAC). Curie Division Gracious Professionalism Award.
2014 Capital City Classic Winner AND Runner Up. Madtown Throwdown: Runner up.
2015 Innovation in Control Award, Sacramento.
2016 Chezy Champs Finalist, 2016 MTTD Finalist
  #3   Spotlight this post!  
Unread 04-01-2008, 02:57
EHaskins EHaskins is offline
Needs to change his user title.
AKA: Eric Haskins
no team (CARD #6 (SCOE))
Team Role: College Student
 
Join Date: Jan 2006
Rookie Year: 2006
Location: Elkhorn, WI USA
Posts: 998
EHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond repute
Send a message via MSN to EHaskins
Re: Interrupt issue with new code

Quote:
Originally Posted by billbo911 View Post
I think you are right. The error looks simple to me as well. I think the reason you aren't seeing the count change is because the code in your ISR to do the increment/decrement is commented out. It looks like it should work correctly if the whack whacks and whack star and star whacks were removed.

Code:
void Encoder_One_Tick(void)
{
	//if (ENCODER_ONE_DIRECTION)
	//{
		_countOne ++;
	/*}
	else
	{
		_countOne --;
	}*/
}

I commented that out when I realized I was having issues. The Bolded line is not commented out.
__________________
Eric Haskins KC9JVH
  #4   Spotlight this post!  
Unread 04-01-2008, 03:25
Kevin Watson's Avatar
Kevin Watson Kevin Watson is offline
La Caņada High School
FRC #2429
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: La Caņada, California
Posts: 1,335
Kevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond repute
Re: Interrupt issue with new code

Quote:
Originally Posted by EHaskins View Post
I'm sure I forgot something really simple, but I can't figure it out.
No, I suspect it's the bug mentioned in this post:

http://www.chiefdelphi.com/forums/sh...0&postcount=78

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #5   Spotlight this post!  
Unread 04-01-2008, 21:42
EHaskins EHaskins is offline
Needs to change his user title.
AKA: Eric Haskins
no team (CARD #6 (SCOE))
Team Role: College Student
 
Join Date: Jan 2006
Rookie Year: 2006
Location: Elkhorn, WI USA
Posts: 998
EHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond repute
Send a message via MSN to EHaskins
Re: Interrupt issue with new code

Quote:
Originally Posted by Kevin Watson View Post
No, I suspect it's the bug mentioned in this post:

http://www.chiefdelphi.com/forums/sh...0&postcount=78

-Kevin
I have corrected that, but it still isn't working. Any ideas?

EDIT: I tried changing to interrupt 1, but still nothing.
__________________
Eric Haskins KC9JVH

Last edited by EHaskins : 04-01-2008 at 21:46.
  #6   Spotlight this post!  
Unread 04-01-2008, 23:25
Kevin Watson's Avatar
Kevin Watson Kevin Watson is offline
La Caņada High School
FRC #2429
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: La Caņada, California
Posts: 1,335
Kevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond repute
Re: Interrupt issue with new code

If it'll help, here's the latest code with encoder support:

http://kevin.org/frc/ifi_frc_encoder_beta.zip

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #7   Spotlight this post!  
Unread 05-01-2008, 00:27
EHaskins EHaskins is offline
Needs to change his user title.
AKA: Eric Haskins
no team (CARD #6 (SCOE))
Team Role: College Student
 
Join Date: Jan 2006
Rookie Year: 2006
Location: Elkhorn, WI USA
Posts: 998
EHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond reputeEHaskins has a reputation beyond repute
Send a message via MSN to EHaskins
Re: Interrupt issue with new code

Quote:
Originally Posted by Kevin Watson View Post
If it'll help, here's the latest code with encoder support:

http://kevin.org/frc/ifi_frc_encoder_beta.zip

-Kevin
Works great. I would have liked to know what I missed, but this works.

Thanks!
__________________
Eric Haskins KC9JVH
Closed Thread


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
Issue with downloading code to the 2007 RC thefro526 Programming 3 10-02-2007 17:26
Trying to follow C18 interrupt context code... dcbrown Programming 5 21-12-2006 09:01
interrupt in default code Gal Longin Programming 5 04-02-2006 20:10
Interrupt timer, executing code asap? SeanCassidy Programming 10 07-03-2004 01:47
EDU Interrupt and Timer Template Code Kevin Watson Robotics Education and Curriculum 2 14-12-2003 16:28


All times are GMT -5. The time now is 10:57.

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