Revision: 1758
Author: robhamerling
Date: Tue Mar  9 00:33:13 2010
Log: Removed timer0 aliases from servo library
Required aliases are now in device files.


http://code.google.com/p/jallib/source/detail?r=1758

Modified:
 /trunk/include/external/motor/servo/servo.jal

=======================================
--- /trunk/include/external/motor/servo/servo.jal       Thu Feb 18 16:51:18 2010
+++ /trunk/include/external/motor/servo/servo.jal       Tue Mar  9 00:33:13 2010
@@ -1,6 +1,6 @@
 -- Title: servo control library
-- Author: Matthew Schinkel - borntechi.com, copyright (c) 2009, all rights reserved.
--- Adapted-by:
+-- Adapted-by: Rob Hamerling
 -- Compiler: >=2.4m
 --
 -- This file is part of jallib (http://jallib.googlecode.com)
@@ -15,16 +15,16 @@
 -- 1. Set your SERVO_MIN values to restrict movement.
 --    This step must be completed correctly. First use code as follows
 --    directly after you call servo_init()
---
+-- .
 --    servo_move(0,1)
 --    forever loop
 --    end loop
---
+-- .
-- Now run your circuit and gradually change SERVO_MIN value so the servo
 --    is at the correct location on one side. Try to get the servo to be
 --    1mm from it's min location.
 -- 2. Repeate step 1 with SERVO_MAX but use this:
---
+-- .
 --    servo_move(255,1)
 --    forever loop
 --    end loop
@@ -58,14 +58,8 @@

 -- setup servo 1 to 8 timer aliases for the timer the user selected
 if SERVO_USE_TIMER == 0 then
-   -- aliases timer0 for 16f PICs
-   if target_cpu == PIC_14 then
-      alias t0con_t0cs is option_reg_t0cs
-      alias t0con_psa  is option_reg_psa
-      alias t0con_t0ps is option_reg_ps
-   end if
    -- set special timer0 settings
-   t0con_psa  = 0  -- assign prescaler to timer0
+   t0con_psa  = 0                 -- assign prescaler to timer0
    -- set timer registers to timer0
    alias servo_tmr      is tmr0            -- timer interval
    alias servo_cs       is t0con_t0cs      -- timer clock source bit
@@ -106,11 +100,11 @@
--------------------------------------------------------------------------------
 procedure _servo_set_level(byte in servo_num, bit in level) is
    pragma inline
-
+
    if servo_num == 0 & servo_1_on then
       servo_1 = level
    end if
-
+
    if defined(servo_2) == TRUE then
       if servo_num == 1 & servo_2_on then
          servo_2 = level
@@ -161,7 +155,7 @@

 procedure _servo_isr() is
    pragma interrupt
-
+
    if servo_if then -- check if it is a timer interupt
if _servo_isr_count == 0 then -- do the servo pulse (high)
          servo_if = off                                 -- reset counter
@@ -194,14 +188,14 @@
    calc1 = (location2 * _SERVO_CALC_DIFF)
    calc2 = calc1 / 255
    final = calc2 + servo_min
-
+
    if SERVO_USE_TIMER == 0 then -- if 8 bit timer 0
      var byte final2

       -- change final into a byte
       var byte  val[1] at final
       final2 = val[0]
-
+
       ;calculate the pulse length
       calc1 = (final2 * servo_steps_per_2_5_msec)
       final = calc1 / 255
@@ -216,20 +210,20 @@
    else                   -- if 16 bit timer1 or timer3
       var dword final2
       var word final3
-
+
       -- change final into a word
       var byte  val[2] at final
       final2 = (val[1] << 8) + val[0]
-
+
       ;calculate the pulse length
       calc1 = (final2 * servo_steps_per_2_5_msec)
       final = calc1 / 255
-
+
       -- change final into a word
       var byte  val2[2] at final
       final3 =  val2[1]
       final3 = (final3 <<8) + val2[0]
-
+
       -- set the timer value
_servo_pulse[servo_number - 1] = (65535 - final3) -- move servo 1 by pulse length _servo_low[servo_number - 1] = (65535 - _servo_pulse[servo_number - 1]) + (65535 - servo_steps_per_2_5_msec)
@@ -243,14 +237,14 @@
    -- enable global interupts
    INTCON_GIE  = on -- Enables all unmasked interrupts
    INTCON_PEIE = on -- Enables all unmasked peripheral interrupts
-
+
    servo_if = off   -- clear interupt overflow bit
    servo_ie = on    -- timer overflow interupt enable
    servo_cs = 0     -- use internal clock for timer
-
+
    if SERVO_USE_TIMER == 0 then
       -- timer0 min step time of (1/osc)*16. (0.8us at 20mhz)
-
+
       -- calculate number of steps available within 2.5ms ;example on 20mhz
       const dword SERVO_CALC_1 = target_clock / 10_000    ;= 2000
       const dword SERVO_CALC_2 = SERVO_CALC_1 / 4         ;= 500
@@ -268,7 +262,7 @@
             exit loop
          end if
       end loop
-
+
       -- servo_steps is now calculated, set the prescaller
       servo_ps = servo_prescaler

@@ -294,7 +288,7 @@
             exit loop
          end if
       end loop
-
+
       -- servo_steps is now calculated, set the prescaller
       servo_ps = servo_prescaler

--
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/jallib?hl=en.

Reply via email to