Project Weekly Progress Report
 

 Project Title:

                                                         Microcontroller Implementation of a Small Robot Arm Controller

                                                                               Week of:  January 25th, 2000

                                                                                            Engineers:
                                                                               Megan Bern and Ritesh Patel

                                                                       Advisor’s Signature:  _________________

                                                                                         Grade:  _______

                                   =================================================================
 
 

Objective:

        For the week of February 1st, 2000, our objective was to retest the interface hardware that converted the D/A converter output to the power amplifier and continue writing code for the digital filter.

Progress:

Hardware:

         The circuit for the D/A to power amplifier conversion is shown in Figure 1.  The parameters of the circuit were measured to verify that they were close to being exact values.  This was done because of the previous results recorded for this circuit.  The measured values for these parameters are listed in Table 1.

Table 1:
Measured Parameter Values

     R1=1,001W
     R2=1,002W
         R3=100,090W
       R4=99,980W
       R5=99,950W
         R6=100,370W
        R7=200,250W

Figure 1:
D/A Converter to Power Amplifier Design Interface

 
 

The inputs and outputs of the circuit were measured.  The new recorded values are listed in Table 2.

Table 2:
Inputs vs. Outputs for D/A to AMP

Potentiometer          Calculated        Experimental

                                                              5.00V                     5.00V              5.0000V
                                                              3.75V                     2.50V              2.5037V
                                                              2.50V                     0.00V              0.0087V
                                                              1.25V                    -2.50V             -2.4857V
                                                              0.00V                    -5.00V             -4.978V
 

        These values are much better than the previous week.  The maximum difference is 22mV.  Three op-amps would give a maximum error of 60mV.  The maximum difference is within the maximum error.  The final schematics that will be used for interface the potentiometer and the power amplifier to the EMAC board are shown in Figures 1 and 2.

Figure 2:
Final schematic for P-to-A/D conversion

Software:

         The digital filter was simulated using simulink.  Figure 3 shows the block diagram used for the simulation.
 

Figure 3:
Simulink Block Diagram

        By double clicking on the Sine Wave box, a window of parameters is displayed.  Table 3 lists the parameters that were used.
 

Table 3:
      Sine Wave Parameters

1.  Amplitude=1
                       2.  Frequency(rad/sec)=20*6.28
3.  Phase(rad)=0
              4.  Sample time=0.005sec

            The transfer function G(z) for a 20 Hz pole is
 
 

         By double clicking on the Discrete Transfer Fcn box, a window of parameters is displayed.  Table 4 lists the parameters that were used.

Table 4:
      Discrete Transfer Fcn Parameters

 1.  Numerator=[125 125]
     2.  Denominator=[500 -250]
3.  Sampling time=0.005






        The simulation was ran by clicking on simulation and choosing START.  After the simulation is done, double clicking on the Scope box will display the results.  The results for the simulation of Figure 3 is attached to this report.  The results show that the output is approximately 0.707 of the input signal.  This would be the 3dB down point or the pole location, which was designed to be 20Hz.

         The code for the digital filter was written.  To simulate and run the code, the following steps listed in Table 5 must be done.

Table 5:
Steps for Simulation of Code

         1.  Open my computer.
2.  Open H drive.
        3.  Open Ee451 folder.
                          4.  Copy emac folder into C drive.
                                            5.  Place file of code in emac folder in C drive.
      6.  Left click test.bat.
                                                                        7.  Enter asm51 "filename", save, close, and double click test.bat.
                      8.  Open Procomm if no errors.
         9.  Hit space bar twice.
                        10.  Plug in or reset EMAC board.
         11.  Hit space bar twice.
                              12.  Enter DOWNLOAD and hit enter.
                         13.  Hit Page Up key and select #7.
                    14.  Enter filename and hit enter.
                         15.  Enter MGO 8000 and hit enter.

         These steps will run your code.  We found that the output after running the code was not acting like a digital filter.  The code was troubleshooted by using breakpoints.  To set breakpoint the following steps listed in Table 6 must be executed.

Table 6:
Breakpoint Steps

1.  After entering the filename in Procomm, enter BR0="address to break at" and hit enter.
2.  Type "GO FROM 8000 TIL PROG".

         These steps will run the code until it hits the specified address.  After many changes the written code implemented a digital filter.  The 0.707 or 3dB down point was displayed on an oscilloscope.  This is shown in Figure 4.  The code used to implement this output is attached to this report.
 
 

Figure 4:
Digital Filter Input vs. Output at 3dB Down

        The pole was located at 53.45 Hz.  The code was written for a 20Hz pole.  This means the code must be written to consider any unnecessary rounding or remainders that need to be used.  This will be done next week.

;Ritesh Patel & Megan Bern
;Program1
;01/25/00
;generates 10Hz square wave
;A/D and D/A conversion
;Digital Filter [Yn=.25Rn + .25(Rn-1)+.50(Yn-1)]
;include(mod515)
$INCLUDE(mod515)
;include(digital)
$INCLUDE(digital.asm)

STARD EQU 8000H ;start address for program

 ORG stard
 JMP SETUP

;Interrupt Jump Table

org stard+2BH               ;TF2 + EXF2 interrupt
AJMP TMR2SRV          ; Jump to timer 1 interrupt

;-----------------------------------------------------------------

TMR2SRV:                        ;timer 2 service every 50 ms

          MOV A,#2                ; load ACC for channel 2
          CALL adcin              ; call converter subroutine
                                         ; value in ACC
          CALL da_out          ; write to D/A converter, Chn 0

          CPL p4.1              ;generate pulse
          CLR TF2              ;clear interrupt flag
          RETI
 
 

; ADCIN subroutine
; Return ACC with the 8 bit A/D conversion from the channel selected by ACC
;
ADCIN:
          ANL      A,#00000111B                      ; ONLY 8 CHANNELS
          ANL      ADCON,#11000000B          ;  MODE FOR A/D CONVERSION: SINGLE
          ORL      ADCON,A                           ; "OR" IN THE CHANNEL
           MOV      DAPR,#0                           ; START CONV W/NO REF VOLTAGE
           JB       BSY,$                                   ; LOOP TILL CONVERTED
          MOV      acc,ADDAT                       ; ACC = CONVERSION
 
 

LOOP:
  MOV IP_1,IP                               ;Cutrrent inpt stores for
                                                      ;later use
  ;MOV A,#07FH   ; debug

  MOV IP,a
  MOV b,#4h                               ;Store 4 in accumulator b
  DIV ab                                       ;Divide a by b
  MOV R4,a
  MOV a,b
  CLR C
  SUBB a,#2
  JC HERE
  JZ THERE
  JNZ THERE
THERE:
  MOV a,R4
  ADD a,#1
HERE:
  MOV  a,R4
  MOV R2,a                               ;Store value in R1
  MOV a,IP_1
  MOV b,#4h
  DIV ab
  MOV R4,a
  MOV a,b
  CLR C
  SUBB a,#2
  JC HERE1
  JZ THERE1
  JNZ THERE1

THERE1:
  MOV a,R4
  ADD a,#1

HERE1:
  MOV a,R4
  MOV R3,a                               ;store past input value in R2
  MOV OP_1,OP                        ;store current output for later use
  MOV a,OP_1
  MOV b,#2h
  DIV ab
  MOV R4,a
  MOV a,b
  CLR  C
  SUBB a,#2
  JC HERE3
  JZ THERE3
  JNZ THERE3

THERE3:
  MOV a,R4
  ADD a,#1

HERE3:
  MOV a,R4
  ADD a,R2
  ADD a,R3
  MOV OP,a                   ;Output store in R4
      ;Output store for later use
  RET
 

; da_out subrountine
; write value in ACC to D/A channel specified below
 
 

da_out:  MOV P2,#DA_0                               ; point to D/A channel 0
  MOVX @R1,a                                              ; write data
  RET
 
 

;***********************************************
;
;                 Intialization Code
;
;***********************************************

SETUP:
  MOV IEN0,#0                          ;Disable ALL INTS
  MOV SP,#70H                          ;Initialize STACK

  SETB P5.5                                ;Do a reset
  CLR P5.5                                  ;bring it low
  SETB P5.0                                ;make A16 of 128K Ram, high
  SETB P5.2                                ;disable EEPROM
  CLR P5.1                                  ;new port 5.1 for D/A
     ;END 80535 Stuff
  MOV R0,#7FH                         ;CLEAR 128 BYTES OF RAM

clr_ram: MOV     @R0,#0
  DJNZ R0,clr_ram
 

  SETB T2CON.0                          ; timer 2: 16 bit operation

  SETB T2CON.4                          ; and auto-reload mode
  MOV TH2,#0F6H                       ; load timer 2 registers
  MOV TL2,#0F2H
  MOV CRCH,#0F6H                   ; load capture registers
  MOV CRCL,#0F2H                   ; timer 2

  SETB    ET2                                ;enable timer 2 ovf int
                  SETB    EAL               ; enable all interrupts
Digital:
  MOV IP,#0                              ;Initialize IP
  MOV IP_1,#0                          ;Initialize IP_1
  MOV OP,#0                            ;Initialize OP
  MOV OP_1,#0                        ;Initialize OP_1
 

main:      jmp main
 

END
 
 


Back