Ok Im getting confused here on why standard code for working servos does not work
OK here is the info on PULSEOUT strait from the PBP 2.6 manual
Now when I used a 12F675 with Internal OSC, it ran at 4mhz Approx (I thought) and the servo worked fine using any number between 100 and 200.
PULSOUT Pin,Period
Generates a pulse on Pin of specified Period. The pulse is generated
by toggling the pin twice, thus the initial state of the pin determines the
polarity of the pulse. Pin is automatically made an output. Pin may be
a constant, 0 - 15, or a variable that contains a number 0 - 15 (e.g. B0) or
a pin name (e.g. PORTA.0).
The resolution of PULSOUT is dependent upon the oscillator frequency. If
a 4MHz oscillator is used, the Period of the generated pulse will be in
10us increments. If a 20MHz oscillator is used, Period will have a 2us
resolution.
Defining an OSC value has no effect on PULSOUT. The
resolution always changes with the actual oscillator speed.
‘ Send a pulse 1mSec long (at 4MHz) to PortB.0
PULSOUT PORTB.0,100
Using a 12F683, Using the same Code as the 675 Chip and using Internal OSC, Code does not work, unless range is 5 - 55 ? so is the 683 internal OSC running at 8mhz?
The same code on a 18F4550 has the same effect as the 683 chip.
Here is my code for the 12F675 (I used last year, no problems)
Now here is the Code for the 683 (works from 5 - 55)Code:DEFINE ADC_BITS 10 ' A/D number of bits DEFINE ADC_CLOCK 1 ' Use A/D internal RC clock DEFINE ADC_SAMPLEUS 50 ' Set sampling time in us Res Var Word ' A/D converter result TRISIO.0 = 1 ' RA0 (AN0) is input TRISIO.5 = 0 ' PortB is output AGAIN: ADCIN 0, Res ' Read Channel 0 data res = (res / 654) + 100 '654 = 100 to 200 PULSOUT GPIO.5, res ' Send a pulse PAUSE 20 ' Wait 20 ms GOTO AGAIN
NOTE: I have the POT range from 0 - 255 and a seperate PIC with a LCD to tell me the number from the POT
Code:DEFINE ADC_BITS 10 ' A/D number of bits DEFINE ADC_CLOCK 1 ' Use A/D internal RC clock DEFINE ADC_SAMPLEUS 50 ' Set sampling time in us Res Var Word ' A/D converter result TRISIO.0 = 1 ' RA0 (AN0) is input TRISIO.5 = 0 ' PortB is output AGAIN: ADCIN 0, Res ' Read Channel 0 data res = res / 255 ' 0 to 255 PULSOUT GPIO.5, res ' Send a pulse PAUSE 20 ' Wait 20 ms GOTO AGAIN
And last but not least here is the code for the 18F4550
This has the display attaced to read the servo numbers being used, it also has a loop for jitter correction.
Same problem though, works from 5 - 55
Code:INCLUDE "LCD_D.bas" INCLUDE "ADC_Default.bas" TRISA = 1 ' PORTA is input TRISD = 0 ' PORTD is output TRISB = 0 ' PORTB is output LCDOUT $FE, 1 ' Clear LCD PAUSE 250 ' Wait 0.5sec for LCD to initialize Position Var WORD : Position = 0 X VAR BYTE Mainloop: ADCIN 0, Position ' Read ADC Channel 0 (0 - 1024)X64 position = (position / 256) ' 0 - 255 LCDOUT $FE, 2 LCDOUT $FE, $80 LCDOUT "Servo Position = ", DEC3 position For X = 0 to 4 ' Helps with jitters PULSOUT PORTB.0, Position ' Change Servo to this Position PAUSE 20 ' Wait 20 ms Next X GOTO mainloop ' Repeat END
So what am I missing/doing wrong.
I would like to use the original 100 - 200 code so that I may get a resolution of 100 with the servo
And Lastly a NOTE: when I used the 100 - 200 code with the 12F675, there was never a problem with jitters!



you have allowed BEFORE resetting is a bit short for LCD to power-up ... after having tested dozens of LCD's I generally set it to 700-800 ms ... to be sure. 

Bookmarks