Go to Post Hype levels are reaching critical levels... - wjd13 [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 14-09-2004, 18:10
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
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,756
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: Saving a variable in between runs.

Quote:
Originally Posted by 527Paranoia
Does the EDU bot have the same functionality with using the EEPROM memory?
Yes. The Microchip PIC is the same in both and that's what's providing the functionality.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
  #2   Spotlight this post!  
Unread 15-09-2004, 15:48
Rickertsen2 Rickertsen2 is offline
Umm Errr...
None #1139 (Chamblee Gear Grinders)
Team Role: Alumni
 
Join Date: Dec 2002
Rookie Year: 2002
Location: ATL
Posts: 1,421
Rickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant future
Send a message via AIM to Rickertsen2 Send a message via Yahoo to Rickertsen2
Re: Saving a variable in between runs.

There were a few bugs in my original code. If anybody is interested i will post the working version.
__________________
1139 Alumni
  #3   Spotlight this post!  
Unread 15-09-2004, 16:35
pi_guy578 pi_guy578 is offline
Programmer/Electrician
AKA: Jake
FRC #0578 (Blue Lightning)
Team Role: Programmer
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Fairport
Posts: 48
pi_guy578 has a spectacular aura aboutpi_guy578 has a spectacular aura about
Send a message via AIM to pi_guy578
Re: Saving a variable in between runs.

Am I mistaken by saying if you initialize a static variable such as static int inBetween and it will store the varaible into the program, instead of the RAM. That is the ANSI C standard AFAIK, I'm not sure if its different on PIC chips... Can someone clarify?

Jake
  #4   Spotlight this post!  
Unread 15-09-2004, 16:45
colt527 colt527 is offline
Registered User
AKA: Ken Colton
FRC #0527
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Long Island
Posts: 123
colt527 is a splendid one to beholdcolt527 is a splendid one to beholdcolt527 is a splendid one to beholdcolt527 is a splendid one to beholdcolt527 is a splendid one to beholdcolt527 is a splendid one to beholdcolt527 is a splendid one to behold
Send a message via AIM to colt527
Re: Saving a variable in between runs.

Quote:
Originally Posted by pi_guy578
Am I mistaken by saying if you initialize a static variable such as static int inBetween and it will store the varaible into the program, instead of the RAM. That is the ANSI C standard AFAIK, I'm not sure if its different on PIC chips... Can someone clarify?

Jake
Yes this is all well and good if you variable is not going to change in mid run, then use that same value again in the next rounds. This EEPROM is used for people who need to dynamically change variables and use them at a different time.

I'm using it to store p1_x values that a gyro calculated to make it go strait. Then next time I hit forward on the joystick it would start off with the calculated p1_x value instead of default 127. This (hopefully) will eliminate any beggining turning while the gyro is building up error.
__________________
Mentor, Team 527 -- Plainedge Red Dragons
FIRST Volunteer
SUNY Stony Brook Computer Science 2010
kcolton@gmail.com

Last edited by colt527 : 15-09-2004 at 16:49.
  #5   Spotlight this post!  
Unread 15-09-2004, 17:16
pi_guy578 pi_guy578 is offline
Programmer/Electrician
AKA: Jake
FRC #0578 (Blue Lightning)
Team Role: Programmer
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Fairport
Posts: 48
pi_guy578 has a spectacular aura aboutpi_guy578 has a spectacular aura about
Send a message via AIM to pi_guy578
Re: Saving a variable in between runs.

Quote:
Originally Posted by 527Paranoia
Yes this is all well and good if you variable is not going to change in mid run, then use that same value again in the next rounds. This EEPROM is used for people who need to dynamically change variables and use them at a different time.

I'm using it to store p1_x values that a gyro calculated to make it go strait. Then next time I hit forward on the joystick it would start off with the calculated p1_x value instead of default 127. This (hopefully) will eliminate any beggining turning while the gyro is building up error.
As far as I can tell it would make no difference then b/c the program memory is also an EEPROM (or similar, can't remember) except the storing is auto handled instead of doing it manually using the user EEPROM where you can make errors.
  #6   Spotlight this post!  
Unread 15-09-2004, 17:20
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
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,756
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: Saving a variable in between runs.

Quote:
Originally Posted by pi_guy578
Am I mistaken by saying if you initialize a static variable such as static int inBetween and it will store the varaible into the program, instead of the RAM. That is the ANSI C standard AFAIK, I'm not sure if its different on PIC chips... Can someone clarify?

Jake
There are three basic types of storage available to you on the PIC.

1) "static int x;" uses RAM or data space just as "int x;" does. You can change the value of x from within your program while it's executing (e.g. "x=y+2;"), but the value only lasts as long as the RC is on. All data is lost or returns to initialized values when the RC is turned off or reset.

2) "rom const int x=10;" uses ROM or program space. You cannot change the value of x from within your program as it's running (the compiler will reject "x=y+2;" as an error). The value at program load is permanent and unchanging, only by downloading a new program can x be modified. I believe this is what you were thinking of.

3) EEPROM requires special read/write commands to access as noted above. The value can be changed from within the program while it's running and the latest value is still there after the RC has been turned off or reset. This retention of a changable value is the reason people go to so much trouble to use the EEPROM r/w commands.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 15-09-2004 at 17:41.
  #7   Spotlight this post!  
Unread 16-09-2004, 18:29
pi_guy578 pi_guy578 is offline
Programmer/Electrician
AKA: Jake
FRC #0578 (Blue Lightning)
Team Role: Programmer
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Fairport
Posts: 48
pi_guy578 has a spectacular aura aboutpi_guy578 has a spectacular aura about
Send a message via AIM to pi_guy578
Re: Saving a variable in between runs.

Quote:
Originally Posted by Mark McLeod
"static int x;" uses RAM or data space just as "int x;" does. You can change the value of x from within your program while it's executing (e.g. "x=y+2;"), but the value only lasts as long as the RC is on. All data is lost or returns to initialized values when the RC is turned off or reset.
Whoops, my mistake, a static variable stays initialized between function calls but not neccessarily program runs.
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
MPLAB Variable Simulator? Chris_Elston Programming 3 18-02-2004 12:08
Interrupt Handlers and Variable Scope kaszeta Programming 2 14-02-2004 18:30
variable? manodrum Programming 11 01-04-2003 17:20
Dashboard programs and the char variable Ian W. Programming 13 26-06-2002 02:07
what teams have a variable transmissions? Greg Perkins Technical Discussion 4 06-03-2002 06:10


All times are GMT -5. The time now is 20:04.

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