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;
WaitTimeUp btfss PIR1,CCP1IF
goto WaitTimeUp
bcf PIR1,CCP1IF
bsf STATUS,RP0
bsf PIE1,CCP1IE; enable CCP1 interupt
bcf STATUS,RP0
movlw B'11000000'
movwf INTCON; enable Peripheral interupts
Pommie said: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
Or you can enable interruptsCode:WaitTimeUp btfss PIR1,CCP1IF goto WaitTimeUp bcf PIR1,CCP1IF
And have an interrupt handler.Code:bsf STATUS,RP0 bsf PIE1,CCP1IE; enable CCP1 interupt bcf STATUS,RP0 movlw B'11000000' movwf INTCON; enable Peripheral interupts
HTH
Mike.
Dan East said:When I hear RLE I think of it as a lossless compression algorithm.
Dan East
Pommie said:And when I hear East I think of it as a direction on a compass!
Your point?
Dan East said:Pommie said:And when I hear East I think of it as a direction on a compass!
Your point?
That googling for RLE will tell him everything he needs to know about implementing RLE image compression, which I don't think will help him with his current project. So either RLE can be used in an obscure way to describe the algorithm you're talking about, or you are mistaken in referring to it as RLE in the first place.
Pommie said:BTW, if what I described is not RLE, then what is RLE?
Electrix said:Hey Mike.. i'm a bit confused.. after generating the 100th of a second time base.. how do you record the time.. i mean say 1010 is for 1 sec.. how do i know this without the rotational sensor (i'm sorry i dont know whether ur advice is with using a rotat sensor) . One way i thought was by using the RB4-RB7 change on pin interrupts and then recording time.. is this what you had in mind ?
Pommie said:If your remote control is 4 push buttons on RB4-7 then, after a reset, you would wait for a non zero value to indicate a button has been pressed. You would then start to count 100th by checking the PIR1,CCP1IF. You carry on checking the buttons and counting until either the buttons change or you reach a count of 4095 (1111 1111 1111). You then store the Button state and the count into memory and start again with the new buttons value. Carry on until the memory is full.
Mike.
movlw B'00001011'
movwf T1CON; enable timer 1
movlw low(10000)
movwf CCPR1L
movlw high(10000)
movwf CCPR1H
movlw B'00001011'; enable special event trigger on CCP1
movwf CCP1CON;
Operand of HIGH operator was larger than H'FFFF'
Electrix said:Please explain the meaning of this as 10000 in dec is equal to 2710 in hex.... also help me solve this problem.
Thanks
eblc1388 said:Electrix said:Please explain the meaning of this as 10000 in dec is equal to 2710 in hex.... also help me solve this problem.
Thanks
What about 10000 in HEX? Does the assembler knows that 10000 is decimal?
Have you used the "R=DEC" option in the assembler list directive?
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;
WaitTimeUp btfss PIR1,CCP1IF
goto WaitTimeUp
bcf PIR1,CCP1IF
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?