Thread: Random behavior
View Single Post
  #8   Spotlight this post!  
Unread 25-02-2006, 14:03
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: Random behavior

Quote:
Originally Posted by Alan Anderson
The call to Getdata() will change the value of autonomous_mode to reflect the state of the pin on the competition port. Without a dongle connected, the while loop in User_Autonomous_Code() will execute once and exit. Your main loop will end up calling Process_Data_From_Master_uP(), then User_Autonomous_Code(), repeatedly.
Remove the statement autonomous_mode = 1;. There are 2 ways to test autonomous code
1.You could test your code using a dongle (build instructions here ).
2. The quick and dirty solution is to your team number to 0000 by setting the dip switches on the OI to 0000 and tethering it to the Robot Controller. Warning: This will ALWAYS run autonomous. Run it on blocks so the robot doesn’t get away from you. Don’t leave the team number at 0000 because some unsuspecting team member may turn it on and the robot will attack them.

Quote:
Originally Posted by RedBarons
// Make sure we still enforce a 50ms loop
TMR1L = 0xF4;
TMR1H = 0x24;
Quote:
Originally Posted by PIC18F8722 manual pg169
A write to the high byte of Timer1 must also take place
through the TMR1H Buffer register. The Timer1 high
byte is updated with the contents of TMR1H when a
write occurs to TMR1L. This allows a user to write all
16 bits to both the high and low bytes of Timer1 at once.
I don't think this keeps a 50ms timer. TMR1H is a buffer register and only writes to the actual high byte of the register when TMR1L is written. I think you need to write to TMR1H first and TMR1L second.

It would be far easier to just increment a counter in the 26.2 ms area of the Autonomous loop like so:
Code:
static int auto_counter=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! */
        auto_counter++;
2 counts will give you ~50 ms and it will be synchronized to the rest of your autocode (timer interrupts are not synchronized to the 26.2ms auto loop)

If you still have this problem or any other problems, I will be at the Pittsburgh Regional which is your first regional (I assume you are on Team 63 Red Barons). I should be working at the Robot Inspection table.
__________________
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"