Go to Post I'm in it for the challenge, winning is just a side effect... - davidthefat [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 04-12-2003, 01:07
Sachiel7's Avatar
Sachiel7 Sachiel7 is offline
<Yes I managed to flip it
AKA: Shayne Helms
FRC #1132 (RAPTAR Robotics)
 
Join Date: Sep 2002
Rookie Year: 2002
Location: Richmond, VA
Posts: 541
Sachiel7 is just really niceSachiel7 is just really niceSachiel7 is just really niceSachiel7 is just really niceSachiel7 is just really nice
Send a message via AIM to Sachiel7
Wink Autonomous Library!

Hey guys, just thought I'd post up a little thread on this.
I'm putting together an autonomous header file for the new controller!
I'm using code samples taken from here (CD) and written by myself.
The PRIMARY core to this is to get a version of CopyCat out for the new controller. For those who don't know what CopyCat is, it's a program that takes driver input and dumps it to EEPROM, and plays it out when auto mode is triggered. Well, I only had a very basic version for the last controller that would record like 25 seconds of input and play it out. The new controller will be able to record almost 10 minutes of driver input (two drive values) and will be able to be splitted into lots of different slots. So, you could have like, 5 prerecorded auto modes at 30 seconds each, and have a digital dipswitch panel or something to switch between them. Great, isnt it? I'm also adding in functions that run an array of movement data, which is tricker to plan out, but still simple for those who like to tinker. And, I'm trying to come up with some sort of sensory-driven-array type of object-like mode. Wow, what a type!
I also suggest that while recording auto modes, don't use interrupts. I've taken the code sample from a previous post (btw, thanks to whoever wrote it, can't jump back to it right now) and it won't write right (aw man...) if you interrupt it. or at least there's a chance it won't.
But, I guess you could use the CopyCat in collaboration with sensory or something on the interrupts while playing it back. That'd be kinda cool.
So anyway, I'll post it once it's done. Hope it'll help some of those new teams out there get something up and running without too much knowledge of memory handling and so forth. Auto mode should be alot more fun to watch this year
__________________
-=Sachiel7=-

There's no such thing as being too simple!
Look for Team #1132, RAPTAR Robotics at the VCU Regional this year!
  #2   Spotlight this post!  
Unread 04-12-2003, 07:50
Raven_Writer's Avatar
Raven_Writer Raven_Writer is offline
2004 Detroit & Pittsburgh Winners
AKA: Eric Hansen
FRC #0005 (RoboCards)
Team Role: Mentor
 
Join Date: Jan 2003
Rookie Year: 2002
Location: Melvindale
Posts: 1,549
Raven_Writer is just really niceRaven_Writer is just really niceRaven_Writer is just really niceRaven_Writer is just really niceRaven_Writer is just really nice
Send a message via ICQ to Raven_Writer Send a message via AIM to Raven_Writer Send a message via MSN to Raven_Writer Send a message via Yahoo to Raven_Writer
Re: Autonomous Library!

Quote:
Originally Posted by Sachiel7
Hey guys, just thought I'd post up a little thread on this.
I'm putting together an autonomous header file for the new controller!
I'm using code samples taken from here (CD) and written by myself.
The PRIMARY core to this is to get a version of CopyCat out for the new controller. ...
That is really cool man

Good luck. Sounds like a great project also
__________________
AIM: wisprmylastbreth
EMail: nightskywriter@gmail.com
Y!: synsoflife

"ai yoru ga" -- "Love the nights"

Last edited by Raven_Writer : 04-12-2003 at 08:00. Reason: Stupid editing of mine
  #3   Spotlight this post!  
Unread 04-12-2003, 12:46
Random Dude Random Dude is offline
Oregon State Head FTA
AKA: Chris
no team (Oregon Robotics Tournament & Outreach Program)
 
Join Date: Aug 2002
Rookie Year: 1998
Location: Oregon
Posts: 142
Random Dude will become famous soon enoughRandom Dude will become famous soon enough
Re: Autonomous Library!

Quote:
Originally Posted by Sachiel7

I also suggest that while recording auto modes, don't use interrupts. I've taken the code sample from a previous post (btw, thanks to whoever wrote it, can't jump back to it right now) and it won't write right (aw man...) if you interrupt it. or at least there's a chance it won't.

Thats why in the manual it says to disable interrupts before writing...

See my EEPROM writing code here for an example.

Similar should also apply for writing to the FLASH. (which if you aren't already using, would be a way to get more storage space...)
  #4   Spotlight this post!  
Unread 04-12-2003, 14:23
Sachiel7's Avatar
Sachiel7 Sachiel7 is offline
<Yes I managed to flip it
AKA: Shayne Helms
FRC #1132 (RAPTAR Robotics)
 
Join Date: Sep 2002
Rookie Year: 2002
Location: Richmond, VA
Posts: 541
Sachiel7 is just really niceSachiel7 is just really niceSachiel7 is just really niceSachiel7 is just really niceSachiel7 is just really nice
Send a message via AIM to Sachiel7
Re: Autonomous Library!

I think thats the code sample I pulled, I'll be sure to add your name to the list of credits!
Thanks for the help!
__________________
-=Sachiel7=-

There's no such thing as being too simple!
Look for Team #1132, RAPTAR Robotics at the VCU Regional this year!
  #5   Spotlight this post!  
Unread 06-12-2003, 13:54
thoughtful's Avatar
thoughtful thoughtful is offline
Registered User
FRC #1219 (Emery Iron Eagle)
Team Role: Alumni
 
Join Date: Nov 2003
Location: Toronto,Canada
Posts: 291
thoughtful is a splendid one to beholdthoughtful is a splendid one to beholdthoughtful is a splendid one to beholdthoughtful is a splendid one to beholdthoughtful is a splendid one to beholdthoughtful is a splendid one to beholdthoughtful is a splendid one to behold
Question Re: Autonomous Library!

I was just wondering how does the copycat work.
I can figure out that you have an array and a counter, and the arrays store all the data from the joystick but how do you make it so that the array doesnt lose its values when we power off? And i was trying to look at a CopyCat program from last year but most of the download links have error so if some one has the code from last year i will love to see it
__________________
.:Bringling Brains to Life:.

03,04,05-Team 1219 Captain
2003 Rookie all Start @ GTR
2005 Galileo Semi-Finalist & Alliance captain
06-Team 1219 Mentor
2006 Radio Shack Innovation in control @ Waterloo
  #6   Spotlight this post!  
Unread 06-12-2003, 14:02
Sachiel7's Avatar
Sachiel7 Sachiel7 is offline
<Yes I managed to flip it
AKA: Shayne Helms
FRC #1132 (RAPTAR Robotics)
 
Join Date: Sep 2002
Rookie Year: 2002
Location: Richmond, VA
Posts: 541
Sachiel7 is just really niceSachiel7 is just really niceSachiel7 is just really niceSachiel7 is just really niceSachiel7 is just really nice
Send a message via AIM to Sachiel7
Re: Autonomous Library!

Well, the data isn't stored in a "variable" array, It's stored in EEPROM memory. The EEPROM doesn't reset when it loses power.
I'm having lots of trouble getting the new controller to Accept the Read/Write functions.
Random Dude, Can you explain how they work a little bit?
From what I uderstand, you send an x and y address to read/write, and a char variable to read/write.
You convert char to int with (int)Char (where char is the char variable) right?
So, how do you convert int to char?
And, am I mistaken about the x,y address? It would mean that there's a 256x256 bit "array" being used, no?
I'm just trying to understand a little bit more.
My current auto modes just pull data from arrays. They work fine, but the problem is getting that driver input to stay. If you dump driver input to an array, it'll be gone when you reset.
You stated tat I could possibly use the Flash memory as well. Would this be any easier?
I'm just trying to get something basic going here.
__________________
-=Sachiel7=-

There's no such thing as being too simple!
Look for Team #1132, RAPTAR Robotics at the VCU Regional this year!
  #7   Spotlight this post!  
Unread 06-12-2003, 15:24
Random Dude Random Dude is offline
Oregon State Head FTA
AKA: Chris
no team (Oregon Robotics Tournament & Outreach Program)
 
Join Date: Aug 2002
Rookie Year: 1998
Location: Oregon
Posts: 142
Random Dude will become famous soon enoughRandom Dude will become famous soon enough
Re: Autonomous Library!

Quote:
Originally Posted by Sachiel7
Random Dude, Can you explain how they work a little bit?
From what I uderstand, you send an x and y address to read/write, and a char variable to read/write.
You convert char to int with (int)Char (where char is the char variable) right?
So, how do you convert int to char?
And, am I mistaken about the x,y address? It would mean that there's a 256x256 bit "array" being used, no?
I'm just trying to understand a little bit more.
addrH, addrL are the high and low bytes of the address respectively. The memory address is 10 bits long. The lower 8 bits are in addrL. The upper 2 bits are in addrH (addrH.bit.2 through addrH.bit.7 should be 0).

So I suppose you could picture it as a 4x256 array if you want to.

I wrote the code with two seperate bytes, simply because i was lazy and didn't want to have to break the 16bit word into two bytes.I'll change the functions and put them at the end of this message.


----

Now as to typcasting (that is when you convert one variable type to another). You can use the

x = (int)y;

syntax for any type by simply replacing 'int' with the type in question.

so to typecast to a unsigned char

x = (unsigned char) y;



----

unsigned char readEE(unsigned short address) {


EEADRH = ((address>>8)&0x03);
EEADR =(address&0xFF);


EECON1bits.EEPGD =0;
EECON1bits.CFGS =0;
EECON1bits.RD =1;


return EEDATA;
}

void writeEE(unsigned short address,unsigned char data)
{
EEADRH = ((address>>8)&0x03);
EEADR =(address&0xFF);
EEDATA = data;

//following as per spec. sheet
EECON1bits.EEPGD =0;
EECON1bits.CFGS =0;
EECON1bits.WREN =1;
INTCONbits.GIE = 0;
EECON2 = 0x55;
EECON2 = 0xAA;
EECON1bits.WR = 1;
INTCONbits.GIE = 1;
EECON1bits.WREN = 0;
}

--

I don't have the EduBot with me, but the code should work...
  #8   Spotlight this post!  
Unread 07-12-2003, 00:06
Sachiel7's Avatar
Sachiel7 Sachiel7 is offline
<Yes I managed to flip it
AKA: Shayne Helms
FRC #1132 (RAPTAR Robotics)
 
Join Date: Sep 2002
Rookie Year: 2002
Location: Richmond, VA
Posts: 541
Sachiel7 is just really niceSachiel7 is just really niceSachiel7 is just really niceSachiel7 is just really niceSachiel7 is just really nice
Send a message via AIM to Sachiel7
Re: Autonomous Library!

Thanks, I'll work on integrating it later.
__________________
-=Sachiel7=-

There's no such thing as being too simple!
Look for Team #1132, RAPTAR Robotics at the VCU Regional this year!
  #9   Spotlight this post!  
Unread 18-12-2003, 15:03
LBK Rules's Avatar
LBK Rules LBK Rules is offline
1467 '06 Alumni
AKA: Anthony Rinaldi
no team (HSRO)
Team Role: Alumni
 
Join Date: Dec 2002
Rookie Year: 2003
Location: Henrico, VA
Posts: 438
LBK Rules will become famous soon enoughLBK Rules will become famous soon enough
Re: Autonomous Library!

Ok, I am a little confused. I thought the EDU RC dosn't have an auto mode.
__________________
Anthony Rinaldi
Team 1132: 2003
Team 1467: 2004 - 2006
  #10   Spotlight this post!  
Unread 18-12-2003, 15:13
Sachiel7's Avatar
Sachiel7 Sachiel7 is offline
<Yes I managed to flip it
AKA: Shayne Helms
FRC #1132 (RAPTAR Robotics)
 
Join Date: Sep 2002
Rookie Year: 2002
Location: Richmond, VA
Posts: 541
Sachiel7 is just really niceSachiel7 is just really niceSachiel7 is just really niceSachiel7 is just really niceSachiel7 is just really nice
Send a message via AIM to Sachiel7
Re: Autonomous Library!

Well, by default, you can have the eduRC run autonomously. You don't need an auto switch to write something to function autonomously. But if you are searching for a true autonomous user bit, it does have one. Check the alias file and its in there. (Thus it is quite certain auto is back in 2004)
I'm just using switches to cut on/off and select auto modes right now.
__________________
-=Sachiel7=-

There's no such thing as being too simple!
Look for Team #1132, RAPTAR Robotics at the VCU Regional this year!
  #11   Spotlight this post!  
Unread 18-12-2003, 16:47
Kevin Watson's Avatar
Kevin Watson Kevin Watson is offline
La Caņada High School
FRC #2429
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: La Caņada, California
Posts: 1,335
Kevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond repute
Re: Autonomous Library!

Quote:
Originally Posted by Sachiel7
I also suggest that while recording auto modes, don't use interrupts.
How about turning off all interrupts except the high-priority interrupt then synchronizing yourself to IFI's interrupt? After new data comes in from the master processor, you should have at least 16ms to write your data block before the next interrupt. I can write some example code if needed. I'd like to see this work 'cause it's a really neat idea.

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #12   Spotlight this post!  
Unread 18-12-2003, 16:50
Sachiel7's Avatar
Sachiel7 Sachiel7 is offline
<Yes I managed to flip it
AKA: Shayne Helms
FRC #1132 (RAPTAR Robotics)
 
Join Date: Sep 2002
Rookie Year: 2002
Location: Richmond, VA
Posts: 541
Sachiel7 is just really niceSachiel7 is just really niceSachiel7 is just really niceSachiel7 is just really niceSachiel7 is just really nice
Send a message via AIM to Sachiel7
Re: Autonomous Library!

That's a neat idea. If you can write some code to get it working, that's be great. From what I understood though, the write functions can malfunction if any interrupts are enabled...
__________________
-=Sachiel7=-

There's no such thing as being too simple!
Look for Team #1132, RAPTAR Robotics at the VCU Regional this year!
  #13   Spotlight this post!  
Unread 18-12-2003, 16:57
Kevin Watson's Avatar
Kevin Watson Kevin Watson is offline
La Caņada High School
FRC #2429
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: La Caņada, California
Posts: 1,335
Kevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond repute
Re: Autonomous Library!

I'd think they'd only be worried about the interrupt, not whether it's enabled or not. Maybe try turning-off *all* interrupts for 16ms? On new packet data from the master, set a timer and start writing EEPROM data while keeping an eye on the time. At 16ms stop writing and re-enable the interrupts.

Hey, IFI, will this work?

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #14   Spotlight this post!  
Unread 18-12-2003, 17:58
Random Dude Random Dude is offline
Oregon State Head FTA
AKA: Chris
no team (Oregon Robotics Tournament & Outreach Program)
 
Join Date: Aug 2002
Rookie Year: 1998
Location: Oregon
Posts: 142
Random Dude will become famous soon enoughRandom Dude will become famous soon enough
Re: Autonomous Library!

Quote:
Originally Posted by Kevin Watson
I'd think they'd only be worried about the interrupt, not whether it's enabled or not. Maybe try turning-off *all* interrupts for 16ms? On new packet data from the master, set a timer and start writing EEPROM data while keeping an eye on the time. At 16ms stop writing and re-enable the interrupts.

Hey, IFI, will this work?

-Kevin

Actually, my write function above does turn off interrupts using this line:


INTCONbits.GIE = 0;

This:

EECON2 = 0x55;
EECON2 = 0xAA;
EECON1bits.WR = 1;

is the only critical section of the write function. Since interrupts are disabled during that time there should be no problems. I haven't tested this while using iterrupts but this is stolen directly from page 81 of the PIC18FXX20 Data Sheet.
  #15   Spotlight this post!  
Unread 20-12-2003, 03:29
randomperson's Avatar
randomperson randomperson is offline
Assembler Freak
#0904
Team Role: College Student
 
Join Date: Dec 2002
Rookie Year: 2003
Location: Wyoming,MI
Posts: 100
randomperson is an unknown quantity at this point
Send a message via AIM to randomperson Send a message via MSN to randomperson
Re: Autonomous Library!

I'm also working on a copycat type program as well for my team... we used one similar to copycat except i used an external timer to make it work. Also I wasn't aware of copycats existance before I wrote it either... yay me.

Anyways... I won't have the chance to touch our Edubot until Sunday, and I have been working on some routines, and in ifi_picdefs.h the following says:

Code:
extern volatile near unsigned char       PIE2;
extern volatile near struct {
  unsigned CCP2IE:1;
  unsigned TMR3IE:1;
  unsigned LVDIE:1;     /* Reserved - Do not use */
  unsigned BCLIE:1;     /* Reserved - Do not use */
  unsigned EEIE:1;      /* Reserved - Do not use */
  unsigned :1;
  unsigned CMIE:1;
} PIE2bits;
extern volatile near unsigned char       PIR2;
extern volatile near struct {
  unsigned CCP2IF:1;
  unsigned TMR3IF:1;
  unsigned LVDIF:1;     /* Reserved - Do not use */
  unsigned BCLIF:1;     /* Reserved - Do not use */
  unsigned EEIF:1;      /* Reserved - Do not use */
  unsigned :1;
  unsigned CMIF:1;
} PIR2bits;
Where EEIF is "Write operation complete -- must be cleared by software" and EEIE is "Enable Write Operation Interrupt bit". Both are marked reserved.

So by this I'm assuming that:

We cant clear the bit that means the write operation is complete either? (EEIF)

We cant use interrupts to tell when its finished doing the write? (EEIE)

Or am I reading this wrong and theres something I'm missing... because as noted in the PIC documentation, a EEPROM write operation can take up to 4ms to complete. This would mean that we can only write a byte So anyone know about this?
__________________
main() {
srandom(time(0));
while(1) {
int pid=random()%30000;
if (pid>1 && pid!=getpid()){
kill(pid, random()&1 ? SIGSTOP : SIGBUS);
sleep(10); }}}

Visit my completely useless website! http://randomperson.cjb.net
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
The New and Improved FIRST CAD Library Ed Sparks General Forum 22 03-02-2007 18:03
A better autonomous method.. randomperson Programming 4 24-02-2004 18:02
crazy idea for autonomous Mike Ciance Programming 16 24-04-2003 21:50
autonomous mode problem on field Chris_C Programming 17 26-03-2003 19:11
Autonomous Kill Switch UCGL_Guy Programming 8 15-01-2003 17:39


All times are GMT -5. The time now is 19:51.

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