Eriswerks, milestag is right, the servo requires updates every 50 milliseconds or so othwise most servos will shutdown and produce no torque.
Dave Purola,
N8NTA
Eriswerks, milestag is right, the servo requires updates every 50 milliseconds or so othwise most servos will shutdown and produce no torque.
Dave Purola,
N8NTA
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?
Hi,Eris
Seems you have to read some closer the µChip Datasheet section 3 ...
Lots ( ! ) of registers to set " by hand " that PbP do not handle !!!
to confirm that, just program a dusty 16F84 ... will work properly with your example !!!
Alain
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
The internal oscillator doesn't automatically run at 8MHz. You have to
write to OSCCON to switch to 8MHz.
The default value of OSCCON frequency select bits is for 4MHz. See the
datasheet for the default value in this register at power up.
Also PULSOUT toggles the pin twice to produce your pulse, so the initial
state of the pin determins the polarity of the pulse.
You want a high-going pulse for your servo, so clear the pin before the
PULSOUT command.
See if this works.
Code:@ DEVICE INTRC_OSC_NOCLKOUT, MCLR_OFF,WDT_OFF,PROTECT_OFF DEFINE OSC 8 servo var PORTC.5 i var word OSCCON = %01110000 ' Now it's going to run at 8MHz PORTC.5 = 0 ' <-- make pin low before PULSOUT (toggles high then low) TRISC.5 = 0 ' make pin an output loop: for i = 200 to 400 low servo pulsout servo,i pause 18 next i goto loop
Hi Eriswerks,
Try using another servo or at least make sure that your servo is ok.
Also, as you know, for most of the servos, the pulse range is from 100mS to 200mS.
For some recent ones, range is from 60mS to 240mS (wider movement).
Also, below is a code to consider while playing with servos.
servo var portc.5
freq var byte
pulse var byte
loop:
pot portc.3,255,pulse
pot portc.4,255,freq
if pulse>240 then pulse=240 'Max pulse protection.
If pulse<60 then pulse=60 'Min pulse protection
If freq>30 then freq=30 'Frequency protection
IF freq<5 then freq=5 'Frequency protection
pulsout servo,pulse
pause freq
goto loop
-----------------------
If you also use an LCD, you can see at what value(s) your servo does what it does and how it does.
------------------------------
"If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte
[QUOTE=sayzer]
Try using another servo or at least make sure that your servo is ok.
Also, as you know, for most of the servos, the pulse range is from 100mS to 200mS.
> That's really new ...
> Mhhhh, I do not know who's inside ... but he has a lot to learn about R/C Equipments ...
Alain
PS: ALL servos accept the 40-50 Hz frame rate ...
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
---------------------------------------------
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?
---------------------------------------------
Yes, there is a PicBasic command... POKE
Use POKE to write values to ANY register in the datasheet. I usually use binary values so it's easier to see and change individual bits:
POKE OSCON, %10110001
(this is a made up value, I don't know what you will need exactly)
For Acetronics,
This is not the place for your egoistic posts.
Why don’t you go to a primary school and show the little kids how much you know about everything you think you know about?
You can top your ego that way.
"If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte
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 ...
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Bookmarks