Go to Post Does FIRST know about some rare inverted mushroom that I do not? - sanddrag [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 09-02-2008, 13:10
Lilor Lilor is offline
Registered User
FRC #2595
 
Join Date: Feb 2008
Location: Los Angeles, Ca
Posts: 5
Lilor is an unknown quantity at this point
hybrid programming?

Alright we are a rookie team and don't have a real programmer helping us. We got this sample code from Timville, for hybrid but it doesn't work in our program. Can someone please tell us what is wrong with this code, the bold part is the part we don't know if it is wrong:


************************************************** *****************************
* 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"


/*** DEFINE USER VARIABLES AND INITIALIZE THEM HERE ***/


/************************************************** *****************************
* 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;

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! */


void Initialization()
{
bMotorReflected[port2] = true; //Reflect Motor
frcDigitalIODirection[pio3] = dirInput; //IR Output 1 on Digital IO 3
frcDigitalIODirection[pio4] = dirInput; //IR Output 2 on Digital IO 4
frcDigitalIODirection[pio5] = dirInput; //IR Output 3 on Digital IO 5
frcDigitalIODirection[pio6] = dirInput; //IR Output 4 on Digital IO 6
}

task Autonomous()
{
int IRswitch0;
int IRswitch1;
int IRswitch2;
int IRswitch3;

while(true)
{
IRswitch0 = frcDigitalIOValue[pio3]; //Update Variables
IRswitch1 = frcDigitalIOValue[pio4]; //So we can see status in the Debugger
IRswitch2 = frcDigitalIOValue[pio5];
IRswitch3 = frcDigitalIOValue[pio6];

if(IRswitch0 == 1) //If Switch 1 is pressed (it pulses, doesn't remain on)
{
motor[port1] = 50;
motor[port2] = 50;
}

if(IRswitch1 == 1) //If Switch 2 is pressed
{
motor[port1] = 0;
motor[port2] = 0;
}

if(IRswitch2 == 1) //If Switch 3 is pressed
{
motor[port1] = -50;
motor[port2] = 50;
}

if(IRswitch3 == 1) //If Switch 4 is pressed
{
motor[port1] = 50;
motor[port2] = -50;
}
}
}


/* Add your own autonomous code here. */

Generate_Pwms(pwm13,pwm14,pwm15,pwm16);

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

/************************************************** *****************************
* 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. */

}

/************************************************** *****************************
* 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) */
}


/************************************************** ****************************/
/************************************************** ****************************/
/************************************************** ****************************/


We seriously need help. We have no other help in programming, other than chiefdelphi.com
  #2   Spotlight this post!  
Unread 09-02-2008, 13:20
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: hybrid programming?

Uh, that looks like RobotC syntax... If you're getting syntax errors or undefined function sort of things, that's why. You may have to start from scratch, or look for sample code for normal C.
  #3   Spotlight this post!  
Unread 11-02-2008, 14:12
timville's Avatar
timville timville is offline
Registered User
AKA: Timothy Friez
FRC #1185 (X-Bots)
Team Role: Alumni
 
Join Date: Mar 2007
Rookie Year: 2003
Location: Pittsburgh
Posts: 18
timville is an unknown quantity at this point
Send a message via AIM to timville
Re: hybrid programming?

Yep, you're trying to use ROBOTC code in MPLAB, which just won't work.

Download ROBOTC: http://www.robotc.net/ifi/frc/
__________________
2003 - Rookie All-Stars Awards - #1185 (Pittsburgh)
2004-2008 FIRST Volunteer - Ref/Head Ref (Pittsburgh)
2002-2007 FIRST Lego League Volunteer - Head Ref (Pittsburgh)
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
Help needed in autonomous programming for hybrid mode Team_STORM Programming 3 21-01-2008 19:11
Hybrid mode? Mrtrom General Forum 20 21-01-2008 07:11
Hybrid Question master_nickz General Forum 3 19-01-2008 00:24
Hybrid mode question. ks_mumupsi Rules/Strategy 13 14-01-2008 22:43
Hybrid mode issue Los Frijoles General Forum 2 07-01-2008 18:52


All times are GMT -5. The time now is 09:54.

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