Дистанционно пилотируемые летательные аппараты
 
[Most Recent Entries] [Calendar View] [Friends View]

Monday, June 27th, 2005

    Time Event
    12:25a
    Для тех, кто ценит настоящее программирование
    Этот текст управляет всеми рулевыми машинками ДПЛА на нижнем уровне.
    Это левый и правый элероны, руль высоты, газ, гиростабилизатор ТРАЛа и другие, если надо будет. Руль направления на наших самолётах не используется.
    Программа работает по самому высокому приоритету по прерываниям от Таймера 0 (программирование по событиям:). Управляющее воздействие -- это длительность установки бита, непосредственно идущего на рулевую машинку, в высокий уровень.
    Комментарии на английском, поскольку программа продавалась за границу. Учатся люди, хе-хе... Не всё же по окошкам мышкой чиркать, надо и головой кумекать.

    asm
    ; get the servo cnfg and clear all the servo bits on the output port
    mov r0, #_|NServoCnfg ;1
    movx a, @r0 ;2
    mov B, a ; save the cnfg in B ;1
    cpl a ; invert the cnfg ;1
    anl _|ServoLevels, a ; clears all the bits connected to servoes ;1
    ; get the pattern of the new servo bit and put it out
    mov DPTR, #_|ServoOn ;2
    mov r0, #_|NumServo ; address of NumServo ;1
    movx a, @r0 ; NumServo itself ;2
    movc a, @a+DPTR ; the next servo On could be ;2
    anl a, B ; filter through the cnfg ;1
    orl _|ServoLevels, a ; output the resulting pattern ;1
    ; increment and limit NumServo
    movx a, @r0 ; NumServo itself ;2
    mov B, a ; save current NumServo for a while in B ;1
    inc a ;1
    anl a, #00000111b ; limit NumServo "no more than 7" ;1
    movx @r0, a ; save the new NumServo for the next time ;2
    ; get the servo command and load the timer
    mov a, #2 ; while NumServo is in B ;1
    mul aB ; 2*NumServo (Words!) ;1
    add a, #_|Servo ; points to the new servo command ;1
    mov r0, a ;1
    movx a, @r0 ; Lo of the new servo command ;2
    inc r0 ; points to Hi ;1
    clr TR0 ;1
    mov TL0, a ;1
    movx a, @r0 ; Hi of the new servo command ;2
    mov TH0, a ;1
    setb TR0 ;1
    end;//asm

    Что есть что:

    var // byte addressing!
    //data for the servo control
    NumServo:Byte;//the index of the current servo (we work with)
    Servo:array[0..7]of Word;//the control words for loading in the T0 for the timing of the pulse durations:
    NServoCnfg:Byte; //servos connected are marked as "1", not connected - as "0"
    var
    ServoLevels:Byte absolute P2; // Bits for output on the servo port

    TR0, TH... -- стандартные идентификаторы mcs51 для Таймера 0.

    Господ "программистов" просят... Ну, как обычно...

    {+}

    << Previous Day 2005/06/27
    [Calendar]
    Next Day >>

ДПЛА.ру   About LJ.Rossia.org