Page 241 - Making PIC Microcontroller Instruments and Controllers
P. 241

PnoJECt  3


                   i*i!{ml&$gffi    This is a stand-alone  program  tor finding ihe  exact servo
                    settingsto determinelhe  open and close  positlons  ol the  gates (Cont  nued)
                    lJon  PoRTE.2                        leave  low  for  write
                    AtcoNl=t6000  00111                  set  A  to  D  control  reqister
                    PAUSE 5OO                            pause  for  .5  sec  for  LcD


                    TRISC =  %00000000                                 ouLpuEs  ror  senos
                    PoRTC  .  %00000000
                    PORTD  -  %00000000                  PoRTD is  all   ourputs   for  LcD
                    POR'E =  %00000000                   PORTE  is  all   outpuLs  for.  IJCD
                    t cDouf  $FE,  1,   \cDEARz          clear   display   and  show  CLEAR
                    DEFINE ADC BITS  8                   se!  nunber  of  birs  in  result
                    DEFINE  ADC  CI|oCK  3               se!  internal   clock  source
                                                          (  3=rc)
                    DEFINE  A.DC  SA,UPITEI'S  50        set  sanplins  tlne  in  us
                    FOTO  VAR  BYTE                      creale  advaL  to  store  result
                    POI1  VAR  BYTE                      creare  adval  to  store  result

                    IOOP r
                      rrcDouT  sFE. s80, DEC3 PO:ro,  z  DEc3  Po4[1'z   \
                      ADCIN  O.  POBO
                      aDclN   1,  Pc|lll
                      POto=PCfro  +  23                  so  actual  pulse  is  displayed
                                                          (arbitrary   value)
                      PUtTSOLT PORTC.1,  POTO
                      PAUSE  FOT1                        pause  1/60  seconds  (appror

                      PUnSOttr  PORTC.0,
                      PIUSE  PdFl                        pause  1/60  seconds,  (appro:

                    GOIO  t  OOP
                    END                                  we  always  end  with  end

                     Noted  for lhe record: in FLI'IABA systems,  the se  o center is defined as a 1.52 milli-
                   seconds wide  pulse  delivered  about 60 times  a second. The  positional  range is about
                   0.75 milliseconds  on either side ofrhar. Other manufacturers  speciiy other values around
                   1.5 milliseconds,  so it is woth  it to check exactly what  your servos need. Develop the
                   habit of working to accurate  parameters  irnd looking things up for yourself.
                     In the prcceding program, the pulses  to both connectols J7 an(l J8 use the same
                   wlue,  POT'.  Doing I  rhis way allows us to hook a se  o up to either connector, and
                   tbe operation will  be the same, Or both servos  can be connected  at the same time and
                   you can  find the end  positions  for both with thi s  program.  Both servos will  not have the
                   same  value for the open  and close  positions  for the  respecrive  gates  unless  you can
                  make  the linkages absolutely  identtcal. POTI contmh rfr? d€ld) between the  pulses.  We
                  want to find the sho  est and longest delays that  give us smooth se  o operation,  and
                  then use the average.
   236   237   238   239   240   241   242   243   244   245   246