|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
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 ![]() |
|
#2
|
|||||
|
|||||
|
Re: Autonomous Library!
Quote:
![]() Good luck. Sounds like a great project also ![]() Last edited by Raven_Writer : 04-12-2003 at 08:00. Reason: Stupid editing of mine |
|
#3
|
|||
|
|||
|
Re: Autonomous Library!
Quote:
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
|
||||
|
||||
|
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! |
|
#5
|
||||
|
||||
|
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 |
|
#6
|
||||
|
||||
|
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. |
|
#7
|
|||
|
|||
|
Re: Autonomous Library!
Quote:
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
|
||||
|
||||
|
Re: Autonomous Library!
Thanks, I'll work on integrating it later.
|
|
#9
|
||||
|
||||
|
Re: Autonomous Library!
Ok, I am a little confused. I thought the EDU RC dosn't have an auto mode.
|
|
#10
|
||||
|
||||
|
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. |
|
#11
|
||||
|
||||
|
Re: Autonomous Library!
Quote:
-Kevin |
|
#12
|
||||
|
||||
|
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...
|
|
#13
|
||||
|
||||
|
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 |
|
#14
|
|||
|
|||
|
Re: Autonomous Library!
Quote:
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
|
||||
|
||||
|
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;
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? |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |