Go to Post Jon is very right, going forward I have a hard time envisioning any future Championship Chairman's award winners without a significant social media presence. It's just too big of an avenue to be ignored. - Karthik [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 02-02-2008, 14:09
Philz20 Philz20 is offline
MGSH Coder
FRC #2526 (Team 2526)
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2008
Location: Maple Grove, MN
Posts: 6
Philz20 is an unknown quantity at this point
IR Remote Programming

I'm trying to clarify something. During hybrid mode, we are able to use the IR remote by RoboCoach right? If so, do I need to program my autonomous to recognize IR commands, or does having it in the user_routines.c file the correct way how to do it?
__________________
Philip Kirshbaum
Maple Grove Senior High
Head of Programming and Control Systems, Team 2526
  #2   Spotlight this post!  
Unread 02-02-2008, 14:12
jacobhurwitz jacobhurwitz is offline
Registered User
FRC #0449 (Blair Robot Project)
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Maryland
Posts: 45
jacobhurwitz has a spectacular aura aboutjacobhurwitz has a spectacular aura aboutjacobhurwitz has a spectacular aura about
Re: IR Remote Programming

Quote:
Originally Posted by Philz20 View Post
I'm trying to clarify something. During hybrid mode, we are able to use the IR remote by RoboCoach right? If so, do I need to program my autonomous to recognize IR commands, or does having it in the user_routines.c file the correct way how to do it?
After you train the IR board (see the manual for details), it's simple. The board uses four digital inputs, and each input is 1 if it's respective trained signal is being received, 0 otherwise.

I forget the exact digital input numbers, though, and I don't have our code right now. (It's in the hallway being tested.)

EDIT: Apparently, the digital input numbers are just the four digital inputs into which you plug the IR board.

Last edited by jacobhurwitz : 02-02-2008 at 14:16. Reason: talked to another programmer
  #3   Spotlight this post!  
Unread 02-02-2008, 14:19
Philz20 Philz20 is offline
MGSH Coder
FRC #2526 (Team 2526)
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2008
Location: Maple Grove, MN
Posts: 6
Philz20 is an unknown quantity at this point
Re: IR Remote Programming

Quote:
Originally Posted by jacobhurwitz View Post
After you train the IR board (see the manual for details), it's simple. The board uses four digital inputs, and each input is 1 if it's respective trained signal is being received, 0 otherwise.

I forget the exact digital input numbers, though, and I don't have our code right now. (It's in the hallway being tested.)

EDIT: Apparently, the digital input numbers are just the four digital inputs into which you plug the IR board.
I'm pretty sure you read my post wrong. The IR remote is programmed, but I am talking about the actual code as in C.
__________________
Philip Kirshbaum
Maple Grove Senior High
Head of Programming and Control Systems, Team 2526
  #4   Spotlight this post!  
Unread 02-02-2008, 14:22
jacobhurwitz jacobhurwitz is offline
Registered User
FRC #0449 (Blair Robot Project)
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Maryland
Posts: 45
jacobhurwitz has a spectacular aura aboutjacobhurwitz has a spectacular aura aboutjacobhurwitz has a spectacular aura about
Re: IR Remote Programming

Quote:
Originally Posted by Philz20 View Post
I'm pretty sure you read my post wrong. The IR remote is programmed, but I am talking about the actual code as in C.
If you connected the IR board to digital inputs 1-4, then in the code, you use: rc_dig_in01, rc_dig_in02, rc_dig_in03, rc_dig_in04. If the button that you trained first is pressed, rc_dig_in01 is 1. Otherwise, it's 0. The second button is rc_dig_in02, etc.
  #5   Spotlight this post!  
Unread 02-02-2008, 14:22
psy_wombats's Avatar
psy_wombats psy_wombats is offline
Registered User
AKA: A. King
FRC #0467 (Duct Tape Bandits)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Shrewsbury MA
Posts: 95
psy_wombats has a spectacular aura aboutpsy_wombats has a spectacular aura aboutpsy_wombats has a spectacular aura about
Re: IR Remote Programming

It would be understandable to misinterpret the first post, I'm not quite sure myself what you mean. If you want your autonomous to react to IR signals, then, yes, your autonomous code will have to change depending on that signal. I'd think a few IFs in the autonomous would suffice. But what exactly are you trying to say?
  #6   Spotlight this post!  
Unread 02-02-2008, 14:26
Philz20 Philz20 is offline
MGSH Coder
FRC #2526 (Team 2526)
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2008
Location: Maple Grove, MN
Posts: 6
Philz20 is an unknown quantity at this point
Re: IR Remote Programming

That's all I needed to know. My IR board code is currently in Default_Routine under user_routines.c, so from what I'm hearing, it needs to go under User_Autonomous_Code under user_routines_fast.c. Is that correct?

Edit: The PWM cables are currently conncected to the digital 15-18.
__________________
Philip Kirshbaum
Maple Grove Senior High
Head of Programming and Control Systems, Team 2526
  #7   Spotlight this post!  
Unread 02-02-2008, 14:27
psy_wombats's Avatar
psy_wombats psy_wombats is offline
Registered User
AKA: A. King
FRC #0467 (Duct Tape Bandits)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Shrewsbury MA
Posts: 95
psy_wombats has a spectacular aura aboutpsy_wombats has a spectacular aura aboutpsy_wombats has a spectacular aura about
Re: IR Remote Programming

That would be correct. Otherwise it would respond in teleoperated.
  #8   Spotlight this post!  
Unread 02-02-2008, 14:44
Philz20 Philz20 is offline
MGSH Coder
FRC #2526 (Team 2526)
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2008
Location: Maple Grove, MN
Posts: 6
Philz20 is an unknown quantity at this point
Re: IR Remote Programming

I'm having a huge programming error as I'm trying to do this right now. Please check the category User_Autonomous_code to see if I did something wrong. The error was the line "void Process_Data_From_Local_IO(void)" which I made no changes to.

Quote:
/************************************************** *****************************
* FILE NAME: user_routines_fast.c <FRC VERSION>
*
* DESCRIPTION:
* This file is where the user can add their custom code within the framework
* of the routines below.
*
* USAGE:
* You can either modify this file to fit your needs, or remove it from your
* project and replace it with a modified copy.
*
* OPTIONS: Interrupts are disabled and not used by default.
*
************************************************** *****************************/

#include "ifi_aliases.h"
#include "ifi_default.h"
#include "ifi_utilities.h"
#include "user_routines.h"
#include "user_Serialdrv.h"
#include "gyro.h"


/*** DEFINE USER VARIABLES AND INITIALIZE THEM HERE ***/
int Timer=0;
char STAGE=INITIAL_FORWARD;

/************************************************** *****************************
* FUNCTION NAME: InterruptVectorLow
* PURPOSE: Low priority interrupt vector
* CALLED FROM: nowhere by default
* ARGUMENTS: none
* RETURNS: void
* DO NOT MODIFY OR DELETE THIS FUNCTION
************************************************** *****************************/
#pragma code InterruptVectorLow = LOW_INT_VECTOR
void InterruptVectorLow (void)
{
_asm
goto InterruptHandlerLow /*jump to interrupt routine*/
_endasm
}


/************************************************** *****************************
* FUNCTION NAME: InterruptHandlerLow
* PURPOSE: Low priority interrupt handler
* If you want to use these external low priority interrupts or any of the
* peripheral interrupts then you must enable them in your initialization
* routine. Innovation First, Inc. will not provide support for using these
* interrupts, so be careful. There is great potential for glitchy code if good
* interrupt programming practices are not followed. Especially read p. 28 of
* the "MPLAB(R) C18 C Compiler User's Guide" for information on context saving.
* CALLED FROM: this file, InterruptVectorLow routine
* ARGUMENTS: none
* RETURNS: void
************************************************** *****************************/
#pragma code
#pragma interruptlow InterruptHandlerLow save=PROD /* You may want to save additional symbols. */

void InterruptHandlerLow ()
{
unsigned char int_byte;
if (INTCON3bits.INT2IF && INTCON3bits.INT2IE) /* The INT2 pin is RB2/DIG I/O 1. */
{
INTCON3bits.INT2IF = 0;
}
else if (INTCON3bits.INT3IF && INTCON3bits.INT3IE) /* The INT3 pin is RB3/DIG I/O 2. */
{
INTCON3bits.INT3IF = 0;
}
else if (INTCONbits.RBIF && INTCONbits.RBIE) /* DIG I/O 3-6 (RB4, RB5, RB6, or RB7) changed. */
{
int_byte = PORTB; /* You must read or write to PORTB */
INTCONbits.RBIF = 0; /* and clear the interrupt flag */
} /* to clear the interrupt condition. */
else
{
CheckUartInts(); /* For Dynamic Debug Tool or buffered printf features. */
}
}


/************************************************** *****************************
* FUNCTION NAME: User_Autonomous_Code
* PURPOSE: Execute user's code during autonomous robot operation.
* You should modify this routine by adding code which you wish to run in
* autonomous mode. It will be executed every program loop, and not
* wait for or use any data from the Operator Interface.
* CALLED FROM: main.c file, main() routine when in Autonomous mode
* ARGUMENTS: none
* RETURNS: void
************************************************** *****************************/
void User_Autonomous_Code(void)
{
/* Initialize all PWMs and Relays when entering Autonomous mode, or else it
will be stuck with the last values mapped from the joysticks. Remember,
even when Disabled it is reading inputs from the Operator Interface.
*/
pwm01 = pwm02 = pwm03 = pwm04 = pwm05 = pwm06 = pwm07 = pwm08 = 127;
pwm09 = pwm10 = pwm11 = pwm12 = pwm13 = pwm14 = pwm15 = pwm16 = 127;
relay1_fwd = relay1_rev = relay2_fwd = relay2_rev = 0;
relay3_fwd = relay3_rev = relay4_fwd = relay4_rev = 0;
relay5_fwd = relay5_rev = relay6_fwd = relay6_rev = 0;
relay7_fwd = relay7_rev = relay8_fwd = relay8_rev = 0;
STAGE=INITIAL_FORWARD;
Timer=0;
while (autonomous_mode) /* DO NOT CHANGE! */
{
if (statusflag.NEW_SPI_DATA) /* 26.2ms loop area */
{
Getdata(&rxdata); /* DO NOT DELETE, or you will be stuck here forever! */

/* Add your own autonomous code here. */
{
static char latch=0, IR_cmd=0;
unsigned char sensorReading;

//**** Check the IR Sensor for a new command
sensorReading = PORTJ>>4; // Combined digital inputs 15-18

if (latch == 1)
{
if (sensorReading == 0)
{
latch = 0; // Take only the 1st reading to avoid being caught by a half & half state of the IR sensor
}
}
else if (sensorReading != 0)
{
latch = 1;

if (sensorReading == 8) IR_cmd = 1;
else if (sensorReading == 4) IR_cmd = 4;
else if (sensorReading == 2) IR_cmd = 2;
else if (sensorReading == 1) IR_cmd = 3;

printf("IR_cmd = %d\r\n", IR_cmd);
}

switch(IR_cmd)
{
case 0:
break;

case 1:
pwm01 = 127;
pwm02 = 127;
break;

case 2:
pwm01 = 254;
pwm02 = 0;
break;

case 3:
pwm01 = 0;
pwm02 = 254;
break;

case 4:
pwm01 = 254;
pwm02 = 254;
}

if (user_display_mode != 0) /* User Mode is On */
{
User_Mode_byte = sensorReading; //Show on the OI digital display
}

Process_Gyro_Data(); /* Gyro ADC Update*/

switch (STAGE) {
case INITIAL_FORWARD:
if (Timer < 114) {
pwm01=pwm02=pwm03=pwm04=255;
} else {
STAGE=INITIAL_LEFT_TURN;
}
break;
case INITIAL_RIGHT_TURN:
if (Timer < 200) {
pwm01=pwm03=0;
pwm02=pwm04=255;
} else {
STAGE=FORWARD;
}
break;
case INITIAL_LEFT_TURN:
if (Timer < 25) {
pwm01=pwm03=255;
pwm02=pwm04=0;
} else {
//STAGE=FORWARD;
STAGE=0;
}
break;
case FORWARD:
if (Timer < 50) {
pwm01=pwm02=pwm03=pwm04=255;
} else {
STAGE=BACKWARD;
}
break;
case BACKWARD:
if (Timer < 400) {
pwm01=pwm03=0;
pwm02=pwm04=0;
} else {
STAGE=FORWARD;
}
break;
default:
pwm01=pwm02=pwm03=pwm04=127;
break;
}

Generate_Pwms(pwm13,pwm14,pwm15,pwm16);

Putdata(&txdata); /* DO NOT DELETE, or you will get no PWM outputs! */
Timer++;
}
}
}

/************************************************** *****************************
* FUNCTION NAME: Process_Data_From_Local_IO
* PURPOSE: Execute user's realtime code.
* You should modify this routine by adding code which you wish to run fast.
* It will be executed every program loop, and not wait for fresh data
* from the Operator Interface.
* CALLED FROM: main.c
* ARGUMENTS: none
* RETURNS: void
************************************************** *****************************/
void Process_Data_From_Local_IO(void)
{
/* Add code here that you want to be executed every program loop. */

Process_Gyro_Data(); /* Gyro ADC Update*/

}

/************************************************** *****************************
* FUNCTION NAME: Serial_Char_Callback
* PURPOSE: Interrupt handler for the TTL_PORT.
* CALLED FROM: user_SerialDrv.c
* ARGUMENTS:
* Argument Type IO Description
* -------- ---- -- -----------
* data unsigned char I Data received from the TTL_PORT
* RETURNS: void
************************************************** *****************************/

void Serial_Char_Callback(unsigned char data)
{
/* Add code to handle incomming data (remember, interrupts are still active) */
}


/************************************************** ****************************/
/************************************************** ****************************/
/************************************************** ****************************/
__________________
Philip Kirshbaum
Maple Grove Senior High
Head of Programming and Control Systems, Team 2526
  #9   Spotlight this post!  
Unread 02-02-2008, 14:49
psy_wombats's Avatar
psy_wombats psy_wombats is offline
Registered User
AKA: A. King
FRC #0467 (Duct Tape Bandits)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Shrewsbury MA
Posts: 95
psy_wombats has a spectacular aura aboutpsy_wombats has a spectacular aura aboutpsy_wombats has a spectacular aura about
Re: IR Remote Programming

Check your braces over by the next function up, the void User_Autonomous_Code(void). The compiler errors aren't very helpdul with line numbers. I strongly suspect this is the case.
  #10   Spotlight this post!  
Unread 02-02-2008, 15:15
Philz20 Philz20 is offline
MGSH Coder
FRC #2526 (Team 2526)
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2008
Location: Maple Grove, MN
Posts: 6
Philz20 is an unknown quantity at this point
Re: IR Remote Programming

The braces were removed, but it's still giving me the syntax error.
__________________
Philip Kirshbaum
Maple Grove Senior High
Head of Programming and Control Systems, Team 2526
  #11   Spotlight this post!  
Unread 02-02-2008, 15:24
psy_wombats's Avatar
psy_wombats psy_wombats is offline
Registered User
AKA: A. King
FRC #0467 (Duct Tape Bandits)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Shrewsbury MA
Posts: 95
psy_wombats has a spectacular aura aboutpsy_wombats has a spectacular aura aboutpsy_wombats has a spectacular aura about
Re: IR Remote Programming

Alright, giving this code closer inspection. You need one more brace to close the random brace hovering below the /* Add your own autonomous code here */ line, not removing the braces at the bottom. Or just eliminate that brace. That should fix the problem. Indentation is a good thing!
  #12   Spotlight this post!  
Unread 02-02-2008, 19:02
Eric Finn's Avatar
Eric Finn Eric Finn is offline
Registered User
FRC #0166 (Chop Shop)
Team Role: College Student
 
Join Date: May 2006
Rookie Year: 2005
Location: Merrimack, NH
Posts: 101
Eric Finn has a spectacular aura aboutEric Finn has a spectacular aura about
Send a message via AIM to Eric Finn
Re: IR Remote Programming

To avoid this problem in the future, I suggest using an editor with brace/parenthesis highlighting and block collapsing, such as Notepad++, which supports C, among other languages.
__________________
It always takes longer than you expect, even when you take into account Hofstadter's Law.
--Hofstadter's Law

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
Remote sportman3333333 Control System 2 27-01-2008 12:41
Remote programming box Ben Englert Programming 4 23-02-2006 22:56
Remote Network Ryan F. IT / Communications 12 01-07-2004 15:06
Remote Remote Kickoff for Southern California ChrisH Southern California Regional Robotics Forum 0 05-01-2004 12:36
Remote Remote Kick off at University High School George1902 Off-Season Events 4 04-01-2004 21:05


All times are GMT -5. The time now is 19:06.

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