Go to Post I'm not certain that I agree with me on this reasoning, either. - Richard Wallace [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 17-09-2008, 18:36
Bryan Herbst's Avatar
Bryan Herbst Bryan Herbst is offline
Registered User
AKA: Bryan
FRC #2052 (KnightKrawler)
Team Role: Mentor
 
Join Date: Sep 2007
Rookie Year: 2007
Location: Minneapolis, Minnesota
Posts: 545
Bryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond repute
Robot not doing what we need it to, and printfs aren't working

So, first of all, our printf's aren't working. MPlab displays a "type qualifier mismatch in assignment" error. Any ideas why they aren't working? They also are not being displayed, which could be attributed to our next problem.

Our robot is not doing what we are telling it to do, at all.
We are running Kevin's code.
teleop.c below.

Code:
/*******************************************************************************
*
*	TITLE:		teleop.c 
*
*	VERSION:	0.1 (Beta)                           
*
*	DATE:		31-Dec-2007
*
*	AUTHOR:		R. Kevin Watson
*				kevinw@jpl.nasa.gov
*
*	COMMENTS:	This file best viewed with tabs set to four.
*
*				You are free to use this source code for any non-commercial
*				use. Please do not make copies of this source code, modified
*				or un-modified, publicly available on the internet or elsewhere
*				without permission. Thanks.
*
*				Copyright ©2007-2008 R. Kevin Watson. All rights are reserved.
*
********************************************************************************
*
*	Change log:
*
*	DATE         REV  DESCRIPTION
*	-----------  ---  ----------------------------------------------------------
*	31-Dec-2007  0.1  RKW Original
*
*******************************************************************************/

#include <stdio.h>
#include "ifi_frc.h"
#include "pwm.h"
#include "timers.h"
#include "interrupts.h"
#include "serial_ports.h"
#include "ifi_code.h"
#include "teleop.h"

/*******************************************************************************
*
*	FUNCTION:		Initialization()
*
*	PURPOSE:		This function is called once when the robot controller
*					is cold or warm booted. You should initialize your code
*					here.		
* 
*	CALLED FROM:	main() in ifi_frc.c
*
*	PARAMETERS:		None
*
*	RETURNS:		Nothing
* 
*	COMMENTS:
*
*******************************************************************************/
void Initialization(void)
{
	// Setup the digital I/O pins. Use "INPUT" to setup the pin
	// as an input and "OUTPUT" to setup the pin as an output.
	digital_io_01 = INPUT;
	digital_io_02 = INPUT;
	digital_io_03 = INPUT;
	digital_io_04 = INPUT;
	digital_io_05 = INPUT;
	digital_io_06 = INPUT;
	digital_io_07 = INPUT;
	digital_io_08 = INPUT;
	digital_io_09 = INPUT;
	digital_io_10 = INPUT;
	digital_io_11 = INPUT;
	digital_io_12 = INPUT;
	digital_io_13 = INPUT;
	digital_io_14 = INPUT;
	digital_io_15 = INPUT;
	digital_io_16 = INPUT;
	digital_io_17 = INPUT;
	digital_io_18 = INPUT;


	// Initialize the digital outputs. If the pin is configured
	// as an input above, it doesn't matter what state you
	// initialize it to here.
	rc_dig_out01 = 0;
	rc_dig_out02 = 0;
	rc_dig_out03 = 0;
	rc_dig_out04 = 0;
	rc_dig_out05 = 0;
	rc_dig_out06 = 0;
	rc_dig_out07 = 0;
	rc_dig_out08 = 0;
	rc_dig_out09 = 0;
	rc_dig_out10 = 0;
	rc_dig_out11 = 0;
	rc_dig_out12 = 0;
	rc_dig_out13 = 0;
	rc_dig_out14 = 0;
	rc_dig_out15 = 0;
	rc_dig_out16 = 0;
	rc_dig_out17 = 0;
	rc_dig_out18 = 0;

	// initialize timers and external interrupts here
	// (see timers.c/.h and interrupts.c/.h)


	printf("IFI User Processor Initialized ...\r\n");
}

/*******************************************************************************
*
*	FUNCTION:		Teleop_Init()
*
*	PURPOSE:		This is where you put code that needs to execute
*					just once at the start of teleoperation mode.		
* 
*	CALLED FROM:	main() in ifi_frc.c
*
*	PARAMETERS:		None
*
*	RETURNS:		Nothing
* 
*	COMMENTS:		While in this mode, all operator interface data is valid
*					and all robot controller outputs are enabled.
*
*******************************************************************************/
void Teleop_Init(void)
{

}

/*******************************************************************************
*
*	FUNCTION:		Teleop()
*
*	PURPOSE:		This is where you put code that you want to execute while
*					your robot is in teleoperation mode. While in teleoperation
*					mode, this function is called every	26.2ms after new data
*					is received from the master processor.		
* 
*	CALLED FROM:	main() in ifi_frc.c
*
*	PARAMETERS:		None
*
*	RETURNS:		Nothing
* 
*	COMMENTS:		While in this mode, all operator interface data is valid
*					and all robot controller outputs are enabled.
*
*******************************************************************************/
void Teleop(void)
{
	if (p1_sw_trig == 1) {
	mechanum(); //execute mechanum code
	}
	else {
	tank();
	}

	Update_OI_LEDs();	// located in ifi_code.c
	button_map(); //button mapping
	cannon();
}

/*******************************************************************************
*
*	FUNCTION:		Teleop_Spin()
*
*	PURPOSE:		While in teleoperation mode, this function is called
*					continuously between calls to Teleop().		
* 
*	CALLED FROM:	main() in ifi_frc.c
*
*	PARAMETERS:		None
*
*	RETURNS:		Nothing
* 
*	COMMENTS:		While in this mode, all operator interface data is valid
*					and all robot controller outputs are enabled.
*
*******************************************************************************/
void Teleop_Spin(void)
{

}


void mechanum()
{
      signed double wFL, wFR, wRL, wRR, velocity, rotation, strafe, wMax;

    velocity = (((int)p1_y) - 127);
    rotation = (((int)p1_x) - 127);
    strafe = (((int)p2_x) - 127);
   
    wFL = velocity - rotation - strafe;
    wFR = velocity + rotation + strafe;
    wRL = velocity - rotation + strafe;
    wRR = velocity + rotation - strafe;


    pwm01 = (int)wFL + 127;
    pwm02 = 127 - (int)wFR;
    pwm03 = (int)wRL + 127;
    pwm04 = 127 - (int)wRR;   


//printf("PWMS- pwm01: %d , pwm02: %d , pwm03: %d , pwm04: %d \r \n", pwm01, pwm02, pwm03, pwm04);
//printf("Wheels- FL: %d FR: %d RL: %d RR: %d \r \n", wFL, wFR, wRL, wRR);
//printf("Port 1 Y: %d , Port 1 X: %d , Port 2 X: %d \r", p1_y, p1_x, p2_x);
}

void button_map() 
{
	if (p3_sw_trig == 1) {
		relay1_fwd = 1;		
		relay1_rev = 0;
		}
	if (p3_sw_top == 1) {
		if (glow_state == 1) {
			glow_state = 0;
			relay2_fwd = 0;
			relay2_rev = 0;
			}
		else {
			glow_state = 1;
			relay2_fwd = 1;
			relay2_rev = 0;
		}
	}
}

void cannon() 
{
pwm05 = (p3_y/4);
}

void tank()
{
  p1_x = 255 - p1_y;
  p1_y = 255 - pwm05;
}
For testing, we added the mechanum/tank drive switch, and the robot did nothing in tank drive mode, and wouldn't stop going in mechanum mode. It also wouldn't switch out of mechanum mode.
__________________
Team 2052- KnightKrawler
Mentor and volunteer

Last edited by Bryan Herbst : 17-09-2008 at 18:40.
  #2   Spotlight this post!  
Unread 17-09-2008, 22:11
whitetiger0990's Avatar
whitetiger0990 whitetiger0990 is offline
Registered User
no team
Team Role: Programmer
 
Join Date: Mar 2006
Rookie Year: 2006
Location: Earth
Posts: 157
whitetiger0990 is a glorious beacon of lightwhitetiger0990 is a glorious beacon of lightwhitetiger0990 is a glorious beacon of lightwhitetiger0990 is a glorious beacon of lightwhitetiger0990 is a glorious beacon of light
Re: Robot not doing what we need it to, and printfs aren't working

The only uncommented printf is: printf("IFI User Processor Initialized ...\r\n");

The other ones are commented out. Does that error have a line number with it?
__________________
print$q=chr(ord($q)+$1)while("7443-0201-8465130105-12-03135-82482113-06-7672-070208-0613-70"=~/(-?\d\d)/g);
  #3   Spotlight this post!  
Unread 17-09-2008, 22:15
Bryan Herbst's Avatar
Bryan Herbst Bryan Herbst is offline
Registered User
AKA: Bryan
FRC #2052 (KnightKrawler)
Team Role: Mentor
 
Join Date: Sep 2007
Rookie Year: 2007
Location: Minneapolis, Minnesota
Posts: 545
Bryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond repute
Re: Robot not doing what we need it to, and printfs aren't working

All of them give the error (when they are uncommented)

I commented most of them out when I started running into the error, as commenting them out gave me less errors, and made me happier. I kept t one so I knew when I had fixed it (which hasn't happened, of course).
__________________
Team 2052- KnightKrawler
Mentor and volunteer
  #4   Spotlight this post!  
Unread 17-09-2008, 22:21
whitetiger0990's Avatar
whitetiger0990 whitetiger0990 is offline
Registered User
no team
Team Role: Programmer
 
Join Date: Mar 2006
Rookie Year: 2006
Location: Earth
Posts: 157
whitetiger0990 is a glorious beacon of lightwhitetiger0990 is a glorious beacon of lightwhitetiger0990 is a glorious beacon of lightwhitetiger0990 is a glorious beacon of lightwhitetiger0990 is a glorious beacon of light
Re: Robot not doing what we need it to, and printfs aren't working

Which line does it say that error is on?
__________________
print$q=chr(ord($q)+$1)while("7443-0201-8465130105-12-03135-82482113-06-7672-070208-0613-70"=~/(-?\d\d)/g);
  #5   Spotlight this post!  
Unread 17-09-2008, 23:47
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,590
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: Robot not doing what we need it to, and printfs aren't working

In your tank function, you don't set any PWM values, therefore the PWMs will still be what they were before the function was called. When you first turn the robot on, it won't move. Once the PWMs get set in the mecanum function, they will continue with the same value once you start calling the tank function again.

In the mecanum function, the calculations can very easily overflow a char. You'll need to protect against that. I don't know if that is the only problem, but it will definitely cause you problems.
  #6   Spotlight this post!  
Unread 18-09-2008, 02:29
AustinSchuh AustinSchuh is offline
Registered User
FRC #0971 (Spartan Robotics) #254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Feb 2005
Rookie Year: 1999
Location: Los Altos, CA
Posts: 803
AustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond repute
Re: Robot not doing what we need it to, and printfs aren't working

Quote:
Originally Posted by whitetiger0990 View Post
Which line does it say that error is on?
And while you are at it, can you post the entire error message(s)?
  #7   Spotlight this post!  
Unread 18-09-2008, 08:24
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,862
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Robot not doing what we need it to, and printfs aren't working

Your print statements have mixed types where you attempt to print unsigned char (e.g., pwm01) and double (wFL) types as ints (%d). Typecast the arguments (int).

Statements such as:
pwm01 = (int)wFL + 127;
start with a double, typecast it to int, then assign it to unsigned char
as opposed to keeping your calculation as double then typecasting the result to unsigned char.
Are you doing that to speed things up? Just curious, not a problem.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 18-09-2008 at 08:37.
  #8   Spotlight this post!  
Unread 19-09-2008, 15:24
Bryan Herbst's Avatar
Bryan Herbst Bryan Herbst is offline
Registered User
AKA: Bryan
FRC #2052 (KnightKrawler)
Team Role: Mentor
 
Join Date: Sep 2007
Rookie Year: 2007
Location: Minneapolis, Minnesota
Posts: 545
Bryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond reputeBryan Herbst has a reputation beyond repute
Re: Robot not doing what we need it to, and printfs aren't working

Quote:
Originally Posted by whitetiger0990 View Post
Which line does it say that error is on?
The printf line (unsure specific number, but that line).



I don't have the entire error anymore, but it said the error was "type qualifier mismatch in assignment" on the printf line in teleop.c.

Quote:
In your tank function, you don't set any PWM values, therefore the PWMs will still be what they were before the function was called. When you first turn the robot on, it won't move. Once the PWMs get set in the mecanum function, they will continue with the same value once you start calling the tank function again.

In the mecanum function, the calculations can very easily overflow a char. You'll need to protect against that. I don't know if that is the only problem, but it will definitely cause you problems.
I'm really not terribly worried about the tank function, but thanks for pointing that out. We will try this if we can't get mechanum to work.

That being said, this is almost the exact same mechanum code we used at the competition. It should work, but it isn't.

How would we stop it from overflowing the chars?

Quote:
Your print statements have mixed types where you attempt to print unsigned char (e.g., pwm01) and double (wFL) types as ints (%d). Typecast the arguments (int).

Statements such as:
pwm01 = (int)wFL + 127;
start with a double, typecast it to int, then assign it to unsigned char
as opposed to keeping your calculation as double then typecasting the result to unsigned char.
Are you doing that to speed things up? Just curious, not a problem.
On our last bot, we had some issues with the robot spitting out relatively random PWM values (usually like -16573 or something). We fixed those (from what I remember) by adding the int typecasts. This may be the same issue, but I can't find out because the printfs aren't working.
__________________
Team 2052- KnightKrawler
Mentor and volunteer
  #9   Spotlight this post!  
Unread 21-09-2008, 20:58
The Lucas's Avatar
The Lucas The Lucas is offline
CaMOElot, it is a silly place
AKA: My First Name is really "The" (or Brian)
FRC #0365 (The Miracle Workerz); FRC#1495 (AGR); FRC#4342 (Demon)
Team Role: Mentor
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Dela-Where?
Posts: 1,564
The Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond repute
Send a message via AIM to The Lucas
Re: Robot not doing what we need it to, and printfs aren't working

Quote:
Originally Posted by Tanis View Post
So, first of all, our printf's aren't working. MPlab displays a "type qualifier mismatch in assignment" error. Any ideas why they aren't working? They also are not being displayed, which could be attributed to our next problem.

Our robot is not doing what we are telling it to do, at all.
We are running Kevin's code.
teleop.c below.
"type qualifier mismatch in assignment" is usually a warning not an error. Are you sure it is giving you an error? If it is just a warning sometimes it is OK to ignore it.

If the prinfts are still not working after ignoring the warnings, try printing something simple like printf("Hello World"); Also your wFL values are floats so use %f instead of %d.

Quote:
Originally Posted by Tanis View Post
Code:
*
*	AUTHOR:		R. Kevin Watson
*				kevinw@jpl.nasa.gov
*
*	COMMENTS:	This file best viewed with tabs set to four.
*
*				You are free to use this source code for any non-commercial
*				use. Please do not make copies of this source code, modified
*				or un-modified, publicly available on the internet or elsewhere
*				without permission. Thanks.
*
*				Copyright ©2007-2008 R. Kevin Watson. All rights are reserved.
*
********************************************************************************
Just a reminder to everyone, please do not post copies of Kevin's code (as the license says). It makes supporting his code difficult. I know the IFI code is old now but we should still be careful about this.
__________________
Electrical & Programming Mentor ---Team #365 "The Miracle Workerz"
Programming Mentor ---Team #4342 "Demon Robotics"
Founding Mentor --- Team #1495 Avon Grove High School
2007 CMP Chairman's Award - Thanks to all MOE members (and others) past and present who made it a reality.
Robot Inspector
"I don't think I'm ever more ''aware'' than I am right after I burn my thumb with a soldering iron"
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
Need some help with arm not working... neilcooper Programming 3 15-03-2008 06:16
If the computer and internet was not invented, what would you be doing right now? Bharat Nain Chit-Chat 55 03-06-2006 11:55
my comp is not working right and i need help Timmyd Chit-Chat 17 07-11-2005 23:39
Camera not working when connected to robot MarkVH Programming 5 14-02-2005 15:40
Robot Controller Not Working !?!?! Team1425 Electrical 3 24-01-2004 20:52


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

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