It seems to me that the most important feature that must be continuously timed in my RC car in autonomous control is the 50 pulses per second Pulse Width Modulated simulation of the RC Receiver to Electronic Speed Control signal. Doing this job in background with one Interrupt sounds correct.
The oscillator seen by TMR0 with pre-scaler runs at 1000000Hz
The pre-scaler 1:256 cuts that down to 3906.25. ie 4kHz.
A post-scaler of 1:64 cuts this down to 61.035Hz. Close enough is my guess. I don't have a grip on how to code this yet. Do I at least understand the concept?
-----------------------another way---------------
Bruce suggests counting up to 20,000 in bits of 1 microsecond. That should be easy enough with a 16 bit register built from TMR1H and TMR1L.
------------now how do I get only one PWM pulse?----------------
Page 135 of the PBP manual seems to indicate that the command:
PWM Pin,Duty,Cycle
will produce "Cycle" number of pulses. It says, "This PWM cycle is repeated "Cycle" times." It also says that, "If a 4mHz oscillator is used, each "Cycle" is about 5ms long."
This seems to mean that the following command:
PWM 1, 75, 1
would produce one pulse about 1.5msec long. This is the neutral pulse for a ESC.
If this is true then writing a routines to control the drive wheels and the steering servo will not be difficult at all.
What do you think?
Ken




Bookmarks