Go to Post It’s impossible to know who’s life you will change forever. Don’t miss an opportunity. I’m an optimist. Have a great season. This is the year. - Rich Kressly [more]
Home
Go Back   Chief Delphi > Technical > Technical Discussion
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
  #16   Spotlight this post!  
Unread 20-12-2004, 16:43
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,919
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: Rookie help

Variable declarations must be at the very beginning of a routine. I noted that above in an edit after my original post. Sorry about that.
Quote:
Originally Posted by doyler
Code:
/*******************************************************************************
* FUNCTION NAME: Process_Data_From_Master_uP
* PURPOSE: Executes every 17ms when it gets new data from the master 
* microprocessor.
* CALLED FROM: main.c
* ARGUMENTS: none
* RETURNS: void
*******************************************************************************/
void Process_Data_From_Master_uP(void)
{
static unsigned char servo1=0;
static unsigned char counter=0;
Getdata(&rxdata); /* Get fresh data from the master microprocessor. */
 
Default_Routine(); /* Optional. See below. */
 
/* Add your own code here. */
 
if (counter < 20) // about one 1/3 second in the slow loop
counter++;
else
{
counter = 0;
if (servo1 < 255)
	 servo1++; // servo1 will slowly step through each of it’s positions
else
	 servo1 = 0; // servo1 will quickly reset to the zero position
}
pwm03 = servo1;
 
printf("PWM OUT 7 = %d, PWM OUT 8 = %d\n",(int)pwm07,(int)pwm08); /* printf EXAMPLE */
 
Putdata(&txdata); /* DO NOT CHANGE! */
}
(sorry if i am being annoying, im just new at this)
You're not annoying. I like to help you get started.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 21-12-2004 at 16:40. Reason: Fixed incorrect comment. Slow loop = 59/sec in EDU 38 in FRC
  #17   Spotlight this post!  
Unread 20-12-2004, 16:54
doyler doyler is offline
Rookie / Programmer
#0900 (Infinity)
Team Role: Programmer
 
Join Date: Oct 2004
Rookie Year: 2005
Location: Durham
Posts: 87
doyler is an unknown quantity at this point
Re: Rookie help

Error - Source file 'C:\...\ifi_utilities.c' name exceeds file format maximum of 62 characters.


silly mplab

[edit]

hmm, do i need to install my usb to serial converter?

[/edit]
__________________
  #18   Spotlight this post!  
Unread 20-12-2004, 16:55
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,919
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: Rookie help

Quote:
Originally Posted by doyler
Error - Source file 'C:\...\ifi_utilities.c' name exceeds file format maximum of 62 characters.


silly mplab
Have that default code folder sitting on your desktop don't you?
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
  #19   Spotlight this post!  
Unread 20-12-2004, 16:56
doyler doyler is offline
Rookie / Programmer
#0900 (Infinity)
Team Role: Programmer
 
Join Date: Oct 2004
Rookie Year: 2005
Location: Durham
Posts: 87
doyler is an unknown quantity at this point
Re: Rookie help

yeah, but i have a keyspan usb -> serial

does xp not auto add it?

[edit]

Build Succeeded!

now to add it to the controler

[/edit]
__________________

Last edited by doyler : 20-12-2004 at 17:00.
  #20   Spotlight this post!  
Unread 20-12-2004, 17:02
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,919
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: Rookie help

Quote:
Originally Posted by doyler
yeah, but i have a keyspan usb -> serial

does xp not auto add it?
XP will. [edit2] But you probably have to install that particular device driver the first time. An install CD should have come with the converter, or you might be able to download the driver from keyspan.

Are you getting a download error using IFI_Loader?
Sometimes those adaptors auto connect to a different COM port than it advertises. You can run through and try all the possible COM ports in IFI_Loader by choosing "PortSettings" and COM1, try to download, then COM2, and try to download, etc.

[edit]
I misunderstood.
Do you have the controller or will you try that later?

For those of you reading along...
The error doyler got was because one of the path and filenames was too long for MPLAB to handle. Combined they cannot be more than 62 characters or so. The usual solution is to keep the directory for all your FIRST code at the top level of the C drive, i.e., "C:\FIRST" not on your desktop because that's really at "C:\Documents and Settings\doyler\Desktop\" which is already 41 characters long.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 20-12-2004 at 18:35.
  #21   Spotlight this post!  
Unread 20-12-2004, 18:43
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,919
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: Rookie help

Quote:
Originally Posted by doyler
keyspan usb -> serial
How about getting the driver from here?
http://www.keyspan.com/downloads/win/
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
  #22   Spotlight this post!  
Unread 21-12-2004, 14:21
doyler doyler is offline
Rookie / Programmer
#0900 (Infinity)
Team Role: Programmer
 
Join Date: Oct 2004
Rookie Year: 2005
Location: Durham
Posts: 87
doyler is an unknown quantity at this point
Re: Rookie help

2 questions
For that code do i have to plug them into certain pwm outs?
Also, will my code just start?
__________________
  #23   Spotlight this post!  
Unread 21-12-2004, 14:43
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,919
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: Rookie help

Quote:
Originally Posted by doyler
2 questions
For that code do i have to plug them into certain pwm outs?
Also, will my code just start?
It assumes one servo is attached to pwm 3. You can change this to any other pwm.
Code:
pwm03 = servo1;

The code should start immediately after the download has completed.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
  #24   Spotlight this post!  
Unread 21-12-2004, 14:47
doyler doyler is offline
Rookie / Programmer
#0900 (Infinity)
Team Role: Programmer
 
Join Date: Oct 2004
Rookie Year: 2005
Location: Durham
Posts: 87
doyler is an unknown quantity at this point
Re: Rookie help

I charged my battery and the chargers light turned green
I plugged it in, the battery power and fault status lights blinked, but then nothing

[edit]
now battery power, program state, and fault status are blinking green while pwn in/radio is a constant red

is this good?
[/edit]
__________________
  #25   Spotlight this post!  
Unread 21-12-2004, 14:49
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,919
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: Rookie help

Quote:
Originally Posted by doyler
I charged my battery and the chargers light turned green
I plugged it in, the battery power and fault status lights blinked, but then nothing

[edit]
now battery power, program state, and fault status are blinking green while pwn in/radio is a constant red

is this good?
[/edit]
Very good.
Now press the Prog button to get a solid orange LED.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
  #26   Spotlight this post!  
Unread 21-12-2004, 14:51
doyler doyler is offline
Rookie / Programmer
#0900 (Infinity)
Team Role: Programmer
 
Join Date: Oct 2004
Rookie Year: 2005
Location: Durham
Posts: 87
doyler is an unknown quantity at this point
Re: Rookie help

Ok it works
Now i just need to learn how, why, and how to change it

First off:
How would i make the program loop somewhat faster
__________________

Last edited by doyler : 21-12-2004 at 14:56.
  #27   Spotlight this post!  
Unread 21-12-2004, 14:59
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,919
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: Rookie help

Quote:
Originally Posted by doyler
How would i make the program loop somewhat faster
Also, what will the servo do when the program executes so i know i did it right
The first sound you heard was the servo moving to it's "0" position.
The servo will then take 1.4 minutes to move very slowly through a 60 degree turn before it quickly whips back to the "0" position and repeats.

You can speed this up by changing the delay we built in.
Code:
if (counter < 20) // about 1/3 second in the slow loop for one ~60/255 degree turn
Make it "counter < 2" and it'll take about 17ms to complete a cycle.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 21-12-2004 at 16:44. Reason: mixed up my numbers: Slow loop = 59/sec in EDU 38 in FRC
  #28   Spotlight this post!  
Unread 21-12-2004, 15:04
doyler doyler is offline
Rookie / Programmer
#0900 (Infinity)
Team Role: Programmer
 
Join Date: Oct 2004
Rookie Year: 2005
Location: Durham
Posts: 87
doyler is an unknown quantity at this point
Re: Rookie help

Code:
static unsigned char servo1=0;
static unsigned char counter=0;
Ok, so theses make two variables, 1 is the servos position(?) and the other is the counter right

(i will go through it step by step)
__________________
  #29   Spotlight this post!  
Unread 21-12-2004, 15:17
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,919
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: Rookie help

Quote:
Originally Posted by doyler
Code:
static unsigned char servo1=0;
static unsigned char counter=0;
Ok, so theses make two variables, 1 is the servos position(?) and the other is the counter right

(i will go through it step by step)
Let me know if it worked as expected above.

Yes, servo1 is the position you set for the servo to move to. You can actually set it to any value you like. For instance if you have an RC unit, you could use that to move the servo.

The variable "servo1" could be completely replaced in this code sample with the system variable "pwm03" if you wanted. It isn't strictly needed, but it does make it easy to switch to a different pwm without having to change all your code.

This routine (Process_Data_From_Master_uP) in the default code is called the slow loop. It executes about 59 times per second (in the EDU, FRC is 38 times per sec.), because that's how fast the radio packets come in. We're using that characteristic of the loop to make "counter" a cheap timer. Each loop equals 1/59 second, so "counter<59" , for example, will equal one second.

[edit]
P.S.
You can also change "servo1++;" to something like "servo1 += 5;" to make the servo move faster still. But be careful that the logic of the check "if (servo1 < 255)" catches servo1 before it tries to become larger than 255. When that happens servo1 cannot hold a value larger than 255, so it will suddenly become a completely unexpected value.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 21-12-2004 at 16:46. Reason: mixed up my numbers: Slow loop = 59/sec in EDU 38 in FRC
  #30   Spotlight this post!  
Unread 21-12-2004, 15:21
doyler doyler is offline
Rookie / Programmer
#0900 (Infinity)
Team Role: Programmer
 
Join Date: Oct 2004
Rookie Year: 2005
Location: Durham
Posts: 87
doyler is an unknown quantity at this point
Re: Rookie help

Yes, it worked

So 38 is 1 second?
Then why is 2 faster then 20

I understand the variables part (except for the counter which is covered in the below code)

Code:
if (counter < 2) // about half a second in the slow loop for one 60/255 degree turn (2 = 7 seconds, 20=2 minutes)
counter++;
I know counter++ just adds one to the variable counter, but i dont understand how the counter itself works

[edit]
i dont understand your edit fully
[/edit]
__________________

Last edited by doyler : 21-12-2004 at 15:27.
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
Rookie 2005 Nats Qualification? Alexander McGee Championship Event 2 27-10-2004 10:14
Senior Project 05: Mini competition to help fundraise for local rookie teams Alex Cormier Fundraising 0 07-10-2004 15:58
Rookie Regionals rachakate Regional Competitions 5 24-03-2004 00:01
I want to have a rookie nationals! Tton Championship Event 5 23-04-2003 14:46


All times are GMT -5. The time now is 14:00.

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