The way this sort of data is normally stored is using Run Length Encoding (google RLE). Every command is stored as 2 bytes, a direction and a distance.
As you are using a Pic that does not have EEPROM, you have to store your data in ram. I would suggest using the 96 bytes in page 1. As you only need 4 bits for your direction data, then you could use 12 bits for distance. So each byte pair would contain LRFBdddd dddddddd. For, Left, Right, Forward and Back and the distance (or time) could be up to 4096 counts. If you settle for a resolution of 100th of a second, then your time count could be over 40 seconds.
For example,
0010 0000 1100 0100 = move forward for 1 second.
1000 0000 0001 1011 = turn left for 0.27 seconds.
Etc.
This would give you 48 commands that could be recorded. I’m not sure how good the repeatability would be with just time. As has previously been mentioned, counting pulses from the wheels would be much more accurate.
As for generating the 100th of a second time base, the simplest way is to use the Special Event Trigger of CCP1. You initialise it like this,
Code:
movlw B'00001011'
movwf T1CON; enable timer 1
movlw low(50000)
movwf CCPR1L
movlw high(50000)
movwf CCPR1H
movlw B'00001011'; enable special event trigger on CCP1
movwf CCP1CON;
The 50,000 in the above code is the crystal frequency/4/100. 50,000 is for a 20MHz crystal, for a 4MHz crystal it would be 10,000.
You can test for time up in one of two ways,
By Polling. CCP1IF will be set every 100th of a second. You can test it by
Code:
WaitTimeUp btfss PIR1,CCP1IF
goto WaitTimeUp
bcf PIR1,CCP1IF
Or you can enable interrupts
Code:
bsf STATUS,RP0
bsf PIE1,CCP1IE; enable CCP1 interupt
bcf STATUS,RP0
movlw B'11000000'
movwf INTCON; enable Peripheral interupts
And have an interrupt handler.
HTH
Mike.