Go to Post It's more of a "gracious professionalism" thing. - Matt Leese [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 12-01-2003, 20:26
Phil Roth Phil Roth is offline
Registered User
#0011 (BASF)
 
Join Date: Jan 2003
Location: Mt. Olive New Jersey
Posts: 31
Phil Roth is an unknown quantity at this point
Send a message via AIM to Phil Roth Send a message via Yahoo to Phil Roth
Saving Data to EEPROM

I need to write about 2KB of data in the EEPROM. The PBASIC IDE seems to locate the program at 7FFh and it builds downward. The PIC in the robot controller has 8KB x 2 banks. Does anyone know how to access this additional memory???. And Oh by the way...Is this legal???..

Is there a restriction to having multiple SERIN and SEROUT commands within a single program??. Our code need hi-performance during autonomous mode and it would be better to run in a tight loop with seperate SERIN and SEROUT commands rather than settings flags all over the place to determine what part of the code we're in.
  #2   Spotlight this post!  
Unread 12-01-2003, 20:33
rbayer's Avatar Unsung FIRST Hero
rbayer rbayer is offline
Blood, Sweat, and Code
no team (Teamless Orphan)
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Minnetonka, MN
Posts: 1,087
rbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of light
Send a message via AIM to rbayer
First, you can only access the bank you are currently running in. Normally this is slot0, but you can change that with the RUN command.

As for multiple serin/serouts, it's perfectly legal. However, if you write your code well, you don't need more than one of each. Truly, you don't.

You are correct that the program starts from the bottom and builds up. If you want to put data into the top portion, there are a couple of ways to do it:
1. use the DATA command. This will load data into EEPROM when you first send the program to the RC. Useful for tables, etc.
2. use the WRITE command. This will let you change an EEPROM location at run-time.
Be warned, however, that the life cycle of an EEPROM location is only ~100k writes. At 40 loops/sec, this gives approx. 41 minutes of runtime before you can no longer use that particular location. If you have less than 64 bytes of data to store, use scratchpad RAM instead as it has unlimited reads and writes. The PUT and GET command let you access this.
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php
  #3   Spotlight this post!  
Unread 12-01-2003, 20:41
Phil Roth Phil Roth is offline
Registered User
#0011 (BASF)
 
Join Date: Jan 2003
Location: Mt. Olive New Jersey
Posts: 31
Phil Roth is an unknown quantity at this point
Send a message via AIM to Phil Roth Send a message via Yahoo to Phil Roth
EEPROM Storage

Thanks for the speedy reply. Assuming the program starts at 7FFH, I should be able to set a pointer up @ 800H and then use WRITEs to access the memory. Hopefully the PBASIC compiler won't mirror these addresses and overwrite the program. By the way I tried using RobotEMU and could not get the PWMs to update from the X-Axis controls...What's up with that???. I just downloaded the source code to check it out.

Last edited by Phil Roth : 12-01-2003 at 20:43.
  #4   Spotlight this post!  
Unread 12-01-2003, 20:44
rbayer's Avatar Unsung FIRST Hero
rbayer rbayer is offline
Blood, Sweat, and Code
no team (Teamless Orphan)
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Minnetonka, MN
Posts: 1,087
rbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of light
Send a message via AIM to rbayer
Remember that the program starts at the bottom and builds up. 7FF is the last location, so you can't set anything above that. You should therefore start your EEPROM access at location 0. That way, there is little to no chance of overwriting your program area.

If you could send me an email describing your RoboEmu problem along with the code you were trying to run, I'd appreciate it.
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php
  #5   Spotlight this post!  
Unread 13-01-2003, 00:23
Dave Flowerday Dave Flowerday is offline
Software Engineer
VRC #0111 (Wildstang)
Team Role: Engineer
 
Join Date: Feb 2002
Rookie Year: 1995
Location: North Barrington, IL
Posts: 1,366
Dave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond repute
Quote:
Originally posted by rbayer
However, if you write your code well, you don't need more than one of each. Truly, you don't.
It seems to me that it would be advantageous and more efficient to have 2 different loops - one for autonomous and one for normal driver control. My reasoning is that these two situations will have two very different sets of input - in fact, in autonomous mode, the only reason you'd be doing a SERIN at all is 1) to prevent the RC from resetting the BASIC Stamp and 2) to check the autonomous mode bit. Beyond that, the code should be reacting to sensors and/or time if using dead reckoning. The other loop obviously would be primarily reacting to the driver input with possible assistance from sensors.

Any thoughts?
  #6   Spotlight this post!  
Unread 13-01-2003, 00:33
rbayer's Avatar Unsung FIRST Hero
rbayer rbayer is offline
Blood, Sweat, and Code
no team (Teamless Orphan)
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Minnetonka, MN
Posts: 1,087
rbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of light
Send a message via AIM to rbayer
If you need sensors, you're going to need to get them via Serin. Also, at 62500 baud, taking in one byte is not much faster than taking in the full set as each byte takes only .0001 seconds per byte. On the other hand, I suppose it could shave a ms or two off your loop time...

Anyway, does anybody know if doing another shiftout will let you choose new variables to serin? If it doesn't, you're going to be stuck bringing in the same variables in both places anyways. I really have no idea whether this works or not and am too busy with RoboEmu and school stuff to check right now. If nobody has an answer by tomorrow night, I'll hook up an RC and give it a try.

--Rob
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php
  #7   Spotlight this post!  
Unread 13-01-2003, 00:51
Dave Flowerday Dave Flowerday is offline
Software Engineer
VRC #0111 (Wildstang)
Team Role: Engineer
 
Join Date: Feb 2002
Rookie Year: 1995
Location: North Barrington, IL
Posts: 1,366
Dave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond repute
Quote:
Originally posted by rbayer
If you need sensors, you're going to need to get them via Serin.
Good point. However, once you have that information you'll want to do two very different things with it. Are you thinking of doing the serin command, then branching to one section or another depending on the value of the autonomous mode bit? I guess that would be fine, but I don't see how that is necessarily better.
Quote:
Anyway, does anybody know if doing another shiftout will let you choose new variables to serin?
I don't know off hand, but assuming it does then it would only make more sense to have two separate serin commands depending on which mode you're in...
  #8   Spotlight this post!  
Unread 13-01-2003, 09:34
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,559
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Quote:
Originally posted by rbayer
Anyway, does anybody know if doing another shiftout will let you choose new variables to serin?
We have also thought of this, but have not tried it, yet. If they really mean initialize the master uP, then it probably wouldn't work in competition, becasue I would guess that you would lose radio communication.

Back to the original question, make sure you use write sparingly. EEPROMs only have a limited number of write cycles. The highest I've seen for consumer level EEPROMS is 1 million (and it's most often less). If you write during each program loop, you will wear out the EEPROM after 200 2 minute matches. While this may seem like a lot, when you consider debugging, and demos, you will definelty wear it out by the end.
  #9   Spotlight this post!  
Unread 13-01-2003, 11:33
Phil Roth Phil Roth is offline
Registered User
#0011 (BASF)
 
Join Date: Jan 2003
Location: Mt. Olive New Jersey
Posts: 31
Phil Roth is an unknown quantity at this point
Send a message via AIM to Phil Roth Send a message via Yahoo to Phil Roth
EEPROM, SERIN and other stuff

Our application only writes to EEPROM during a setup/calibration procedure for autonomous mode, so we won't come close to the 10,000 cycle limit. Has anyone simply tried to set a WORD ptr to the second bank, I.E. 800H and then use that area. for example to write 0 - FFh at locations 800h - 8FFh.

EE_pointer VAR word
EE_pointer = 2048

for( x = 0 to 255 )
WRITE EE_pointer, x
EE_pointer = EE_pointer + 1
x=x+1
next

I'm aware of the 10MS delays that may be needed between writes. I think the controller has flash anyway and should be able to take hi speed loads.

During autonomous operation we need loop execution time < 15 MS to keep up with sensor feedback and filtering. The only way to do this is with a completely seperate loop aside from main. This is easier for us instead of having a common entry/exit point and using flags to get to the autonomous code. It's just another way of doing it.
  #10   Spotlight this post!  
Unread 13-01-2003, 11:46
rbayer's Avatar Unsung FIRST Hero
rbayer rbayer is offline
Blood, Sweat, and Code
no team (Teamless Orphan)
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Minnetonka, MN
Posts: 1,087
rbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of light
Send a message via AIM to rbayer
You're not going to get a 15ms loop. Ever. At 9600 baud, the radios have to transmit ~26 bytes each loop between OI and RC. This takes around 21ms alone! Add on an ms or two for your serins from the master uP and you're looking at a minimum loop time of around 25ms.

Second, you've got a number of problems with the code you posted. Too many to mention, in fact. For starters, your FOR syntax is wrong.

Moving on: no, you cannot access the other banks simply by making the pointer point past the end of your current slot. Directly from the Parallax documentation: "WRITE only works with current program slot on BS2e and BS2sx." We have a 2sx. A 2p, on the other hand, could write to other program slots, but that's another story altogether.

--Rob
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php
  #11   Spotlight this post!  
Unread 13-01-2003, 13:13
Phil Roth Phil Roth is offline
Registered User
#0011 (BASF)
 
Join Date: Jan 2003
Location: Mt. Olive New Jersey
Posts: 31
Phil Roth is an unknown quantity at this point
Send a message via AIM to Phil Roth Send a message via Yahoo to Phil Roth
Sorry, I think my point was mis-interpreted. The FOR loop was only a quick example of accessing memory and this is not the actual code. Please excuse the syntax errors, I guess my years of 'C' coding have polluted my recollection of BASIC.

As for the timing, there will be only 1 WRITE and 1 SERIN for each loop, along with some other stuff. We also don't need any SEROUTs during calibration, only the SERIN with 2 or 4 arguments, and modifying the shift macros reduces the number of arguments passed. We are presently executing loops @ 12.7MS.

In closing, the 9600 baudrate is easily changed to 38400. I'm not looking for a debate here...just some advise...Chill man...No need to reply.

Thank's for the "moving on:" answer, I'll have to find a way to get memory some other way.
  #12   Spotlight this post!  
Unread 13-01-2003, 13:35
rbayer's Avatar Unsung FIRST Hero
rbayer rbayer is offline
Blood, Sweat, and Code
no team (Teamless Orphan)
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Minnetonka, MN
Posts: 1,087
rbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of light
Send a message via AIM to rbayer
I know you told me not to reply and to "chill," but you're not going to get off that easily!

You are definately going to have to explain your alleged 13ms loop as the lowest I can get is almost exactly 26. Here's the relevant code:

all CONs at 0 except PB_MODE

MainLoop:

Serin COMA\COMB, INBAUD, [PB_mode]

test=test+1

if test<1000 then no_done
debug "Done", cr
no_done


Serout USERCPU, OUTBAUD, [255,255,127]

Goto MainLoop:


Guess what? After exactly 26 seconds (that's 26ms *1000 loops), "done" pops up. Send me some code that's smaller and faster than that and you have my congrats. Especially if it can actually do something.
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php
  #13   Spotlight this post!  
Unread 13-01-2003, 13:52
Phil Roth Phil Roth is offline
Registered User
#0011 (BASF)
 
Join Date: Jan 2003
Location: Mt. Olive New Jersey
Posts: 31
Phil Roth is an unknown quantity at this point
Send a message via AIM to Phil Roth Send a message via Yahoo to Phil Roth
Sorry to be so vague, I may have said too much already and need the biggest competitive edge as possible. Maybe we can get together in Houston during the competition to talk about it. If I can't find 1600 bytes of non-volitile memory, it's a moot point anyway about the speed.
  #14   Spotlight this post!  
Unread 13-01-2003, 14:22
Unsung FIRST Hero
Mike Betts Mike Betts is offline
Electrical Engineer
no team
Team Role: Engineer
 
Join Date: Dec 2001
Rookie Year: 1995
Location: Homosassa, FL
Posts: 1,442
Mike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond repute
Hey Rob... Some people have to learn the hard way...
__________________
Mike Betts

Alumnus, Team 3518, Panthrobots, 2011
Alumnus, Team 177, Bobcat Robotics, 1995 - 2010
LRI, Connecticut Regional, 2007-2010
LRI, WPI Regional, 2009 - 2010
RI, South Florida Regional, 2012 - 2013

As easy as 355/113...
  #15   Spotlight this post!  
Unread 13-01-2003, 14:27
rbayer's Avatar Unsung FIRST Hero
rbayer rbayer is offline
Blood, Sweat, and Code
no team (Teamless Orphan)
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Minnetonka, MN
Posts: 1,087
rbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of light
Send a message via AIM to rbayer
Quote:
Originally posted by Mike Betts
Hey Rob... Some people have to learn the hard way...
lol. I guess I should just give up on this thread. Oh well... At least I've got a 2.5 editor to keep me occupied for awhile...
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php
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
read/write EEPROM on 18F8520 WizardOfAz Programming 39 22-03-2004 13:32
Competition Scouting pauluffel Scouting 31 09-01-2003 00:34
Robot Scouting Database archiver 2001 10 24-06-2002 03:00
Limiting PWM in pbasic archiver 2001 4 24-06-2002 00:38
Possible Configuration to keep things cheap archiver 1999 8 23-06-2002 23:03


All times are GMT -5. The time now is 13:16.

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