More thoughts on the subject
Looking through the 16F690 datasheet for anything I might have missed, I found this little nugget:
The output of the 8 MHz HFINTOSC and 31 kHz
LFINTOSC connects to a postscaler and multiplexer
(see Figure 3-1). The Internal Oscillator Frequency
select bits, IRCF<2:0> (OSCCON<6:4>), select the
frequency output of the internal oscillators. One of eight
frequencies can be selected via software.
So, it seems like in order to make sure that the PIC is running at 8MHz, I should be telling it to use HFINTOSC and not LFINTOSC, and according to the diagram mentioned I should be setting the frequency select bits to 111.
How do I go about doing that in PicBasic? Is it actually necessary to do so, or does the "intrc_osc_noclkout" that's in the include file for this chip have me covered already? I've also found mentions of putting "OSCCON = $70" in the code to set 8MHz, but I can't seem to find any real documentation on it. Is this controlling the frequency select bits? If so, do I still need to specify HFINTOSC somewhere?
Sorry for the deluge of questions...
Damn you, inanimate object
Thanks for your suggestions. I've whittled down the code to the bare essentials:
@ DEVICE MCLR_OFF,WDT_OFF,PROTECT_OFF
servo var PORTC.5
loop:
pulsout servo,150
pause 18
goto loop
That's the entirety of it, no configuration or anything left out. That ought to center it and hold it there so long as the PIC is powered, but once again it moves all the way to one extreme and stays. I tried other pulsout values from 1 to 2000 just for the fun of it, but I keep getting the same result.
The only thing I can think of is that the internal timer is in its LFINTOSC mode, which is 31kHz and would probably cause any pulse I care to send to look the same to the servo. There must be some language in PicBasic to tell the PIC to which frequency to set the internal oscillator, but I haven't been able to find it.
What am I (still) doing wrong here?
The important thing is to speak ...
Sayzer,
If you want to know, I do not do care about my EGO ... no time for that.
I'd just like you NOT to tell wrong things to those who do not know ...
It's difficult enough to learn pic's programming ... try not to add your own errors nor misunderstandings ... verify first !!!
Alain
Engineer, 30 years of DiY R/C, ... and always doubting ...
no public apologies needed ...
[QUOTE=sayzer]Acetronics,
I would like to apologize for the things I said.
...
Hi, Sayzer
that's kind from you ,
the only important thing is you've learnt something useful ... I don' like this teaching method ... but I'm pretty sure you will always remember about PULSOUT resolution.
a good joke is my favourite method for students to keep things in mind.
That's the only real important thing....; may be ... life respect too, but it's not the right place to discuss it here.
Alain
Update: absolutely no progress
I've tried all the tips you guys gave, and have also been trying any and all PicBasic servo control code I could find on the net, but something is still not right. I've tried four different servos that I know to be functional. I've tried a 16F690 and a 16F628A, with the internal oscillator and with an external 4MHz crystal. I've tried changing the pulsewidths and pauses to every reasonable and many unreasonable numbers. I've switched breadboards. I'm shopping around for a goat to sacrifice to the PIC.
Here's what I'm trying to use now, with a 16F628a:
trisb = 0
cont var byte
cont = 0
led var PORTB.1
hither:
low led
for cont = 0 to 50
pulsout PORTB.0,110
pause 18
next cont
goto yon
yon:
high led
for cont = 0 to 50
pulsout PORTB.0,190
pause 18
next cont
goto hither
It is a slightly modified version of some code from the rentron site, which was meant for a 16F84. My include file (not the whole thing of course) looks like:
device pic16F628A, xt_osc, wdt_on, mclr_on, lvp_off, protect_off
My LED does flash convincingly, but still my servo heads to one extreme and stays there. This is keeping me awake at night now. What mistakes might I still be making? Does anyone know of an example of a working servo controller written in PicBasic, including a circuit diagram and not intended for a 16F84? I just need something functional to build on.
You're probably sick of this thread by now, but any help would be appreciated.
Walkaround highly requested ...
Hi, Eris
Bad news ... I copied and pasted your code, just changed portB N°s as required here ... put a 6LR1 cell ( there's a regulator on the board !!! ) and a futaba servo.
Every thing goes as you programmed it : the led blinks and the windscreen wiper does its job ...
The problem is not ( no more ... humour ) in your code ...
So, What to do ??? ...
First verify your servo supply ( good common ground w/Pic ... enough current to feed the servo ...)
Second verify the signal lead of the servo ... servo behaviour smells no received signal !!!
In that way I would recommend you !!! SOFORT !!! to add a 1k resistor between Portb.0 and your servo connector.
I keep the line
Alain