Yep, you got it. But no point in setting bits 1&2... they're read only.
This is what I use to set the 16F887 to 8MHz.:
OSCCON = %01110001 'Set Osc to 8MHz.
And don't forget to add to your define list: DEFINE OSC 8
For external xtal you will need a 20MHz crystal connected to OSC1 & OSC2 (RA7, RA6) and a small capacitor from each pin to ground. The recommended capacitor size will be in the xtal data sheet, but is typically a couple dozen pF or less.
steve
Last edited by Byte_Butcher; - 4th April 2010 at 02:45. Reason: don't forget to add DEFINE OSC 8
When bumping up to 8MHz try
That should give you 5uS trigger. I was doing 4.Code:pulsout trigfront,1
For external OSC I like ceramic resonators, good and bad to everything but with these you do not have to mess with capacitors, that is why I like them.
http://www.allelectronics.com/make-a...ATORS/-/1.html
The two outside pins will go to RA6 and RA7, the center to the zero rail (ground).
The problem with the 44 pin demo board is Micro Chip did not "ground" the via between RA6 and RA7, so you will have to run a jumper if you go this route.
![]()
Dave
Always wear safety glasses while programming.
Bed time here on the east coast.
I tried both
OSCCON = %01110111
and
OSCCON = %01110001
I got the PIC to read the PWM signal from the radio channel 3 by doubling the threshold for differentiation. I can toggle between PIC and radio control.
But I have not been able to get the HPWM to behave. I tried using the original duty cycle. This made the wheels go backwards very fast no matter what was in the HPWM command. I tried doubling the duty cycle (to account for cutting in half the clock rate and the wheels did not turn at all. The Electronic Speed Control wants this PWM signal to arrive at 50 hz. In fact it is probably at 489Hz (according to page 87 of MicroEngineering Labs' PICBASIC PRO book). I'll put a 'scope on it tomorrow.
I think the book says that HPWM channel, 127, 50 will be a square wave of 489Hz. Does that agree with you guys' thinking?
I also have not gotten the PING echos to mean anything. The little red lights on the SRF05s are blinking. But my code is not making sense of the echo responses. I thought that all I would need to do was to double the expected echo pulse duration numbers.
Ken
Darn,
I thought the SRF05 was the same thing as the PING. Now I see that the SRF05 takes a different trigger pulse.
So it looks like I just wasted your time on that part.
I guess on the good side rmteo noticed another possible problem.
I wonder if a While/Wend loop using PWM would be the answer?
Dave
Always wear safety glasses while programming.
Originally Posted by Kenjones1935 View Post
The Electronic Speed Control wants this PWM signal to arrive at 50 hz.
I was not clear in my last posting. The Electronic Speed Control PWM specification is for a single positive pulse no less than 1ms and no more than 2ms once per 20 ms, ie 50 pulses per second. The one to two millisecond pulse width is divided into 256 parts. 1.5 ms corresponds to 128 which corresponds to neutral in a servo.
Neutral is steering straight on a steering servo. Neutral is stopped on a wheel driving servo.
I discovered that using HPWM with the 4mhz default oscillator a pulse width of 100 to 110 gets the behavior of 'neutral' on my car. For example "HPWM 1, 100, 50" turns the front wheels of my car to straight. See the attached picture. Channel 2 is the HPWM version of neutral. Channel 3 is what the radio receiver sends.
Ken
I have found a way to make short, 10 to 80 usec pulses while using the 4mhz oscillator. The SRF05 proximity detector wants at least 10 usec. If I give it super long pulses catching the following echo measurement can be a problem for PULSIN.
Sooo the following makes an 80 usec positive pulse.
SYMBOL trigright = PORTB.0
LOW trigright
HIGH trigright
HIGH trigright
HIGH trigright
LOW trigright.
One thing at a time.
Ken
Bookmarks