mixing joy stick


Closed Thread
Results 1 to 18 of 18

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    Never had a Tank before. But it sounded like an interesting way to spend the evening.
    It might do it all. Or it might blow a loogie.
    What!?! You live in CA. and never had a tank?
    Slick bit of code...not nearly enough colons in there, but slick nonetheless... I'm hanging on to it for future use.

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Here ya go ski. Is this better ...
    Code:
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :DeadBandX  CON 10      ; center mechanical Dead Area                      :
    :DeadBandY  CON 5                                                          :
    :JoyX       VAR BYTE    ; A/D values from joystick                         :
    :JoyY       VAR BYTE                                                       :
    :TrimX      VAR BYTE                                                       :
    :TrimY      VAR BYTE                                                       :
    :Xcorr      VAR WORD    ; corrected values (x-128)                         :
    :Ycorr      VAR WORD    ;   puts center at 0,0                             :
    :Left       VAR WORD    ; Left Track                                       :
    :Right      VAR WORD    ; Right Track                                      :
    :LeftDir    VAR BIT     ; Tread directions  1 = backwards                  :
    :RightDir   VAR BIT                                                        :
    :                                                                          :
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    :Main:                                                                     :
    :    ADCIN 0, JoyX                            ; get Joystick values        :
    :    ADCIN 1, JoyY                                                         :
    :    ADCIN 2, TrimX                           ; Joystick Center trims      :
    :    ADCIN 3, TrimY                           ;  set to 128 if not used    :
    :                                                                          :
    :    Xcorr = JoyX - 128 + (TrimX >> 3) - 16   ; adjust center position to 0:
    :    Ycorr = JoyY - 128 + (TrimY >> 3) - 16                                :
    :    IF ABS(Xcorr) < DeadBandX THEN Xcorr = 0 ; center deadband            :
    :    IF ABS(Ycorr) < DeadBandY THEN Ycorr = 0 ;                            : 
    :                                                                          :
    :    Left  = Ycorr + Xcorr                    ; Mix Tread speeds           :
    :    Right = Ycorr - Xcorr                                                 :
    :                                                                          :
    :    LeftDir = Left.15                        ; Tread Direction            :
    :    RightDir = Right.15                      ;  1 = backwards             :
    :                                                                          :
    :    Left = ABS(Left)                         ; make values positive       :
    :    Right = ABS(Right)                                                    :
    :                                                                          :
    :    if Left > 127 then Left = 127            ; Clamp max outputs          :
    :    if Right > 127 then Right = 127          ;                            : 
    :                                                                          :
    :    ; Drive motors here                                                   :
    :    ; LeftDir indicates the direction of the Left tread                   :
    :    ; Left is the Speed of the motor 0 - 127                              :
    :    ; Same for Right Track                                                :
    :GOTO Main                                                                 :
    ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    Still compiles.
    DT

Similar Threads

  1. Parallax Memory Stick Datalogger using SPI
    By djmachine in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 26th March 2009, 03:04
  2. Mixing basic and assembly
    By ManInMotion in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 23rd September 2008, 09:48
  3. Displaying messages with only 7 (or 4) LEDs on a stick...
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 20th May 2007, 08:35
  4. PBP and assembler mixing - weird goings-on?
    By Giulio in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 13th November 2006, 21:17
  5. USB memory stick
    By Demon in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 12th July 2005, 20:57

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts