home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / sys / hp48 / 7394 < prev    next >
Encoding:
Text File  |  1993-01-27  |  4.6 KB  |  152 lines

  1. Newsgroups: comp.sys.hp48
  2. Path: sparky!uunet!ukma!usenet.ins.cwru.edu!magnus.acs.ohio-state.edu!csn!stortek!robertt
  3. From: robertt@atlantis.stortek.com (Robert Thompson x7747)
  4. Subject: Motor Controller Code
  5. Message-ID: <1993Jan28.003400.7415@stortek.com>
  6. Originator: robertt@termite
  7. Sender: usenet@stortek.com
  8. Nntp-Posting-Host: termite.stortek.com
  9. Organization: Storage Technology
  10. Distribution: na
  11. Date: Thu, 28 Jan 1993 00:34:00 GMT
  12. Lines: 138
  13.  
  14.  
  15. Here is the code I promised.  Set your HP48 to 9600 baud odd parity 7 bits
  16. and hook it up.  The codes you send it are as follows:
  17.  
  18.         O = on
  19.         F = off
  20.         Ctrl-A = speed header (sent before two speed bytes)
  21.  
  22.         Speed bytes are values from 0 to 255 inclusive.  The first byte
  23.         specifies the on time and the second byte specifies the off time
  24.  
  25.         so to turn the motor on full speed send this:
  26.  
  27.             
  28.                 CHR(1)CHR(255)CHR(0)O
  29.  
  30. Also included is a S-record format file for eprom programmers.  I may be
  31. interested in programming the prom for you for a minimal charge but that
  32. depends on demand.  Let me know.  
  33.  
  34. I used the Pseudo-Sam assembler to assemble this stuff if anyone is
  35. interested.  You can get it from wuarchive in one of the msdos mirrors.
  36.  
  37. -Robert
  38.  
  39. --- CUT HERE ---
  40.  
  41. ;
  42. ; mcontrol.asm:    A simple motor controller for the HP48 or any other device
  43. ;        capable of transmitting ascii data through a serial link.
  44. ;
  45. ;
  46.                 .equ    gotchar,8               ; bit 8 is character ready
  47.                 .equ    rxchar,h'7f             ; character is at location 7f
  48.         .equ    onstate,h'7e        ; on state of motor
  49.         .equ    onsave,h'7f        ; save loc for on time
  50.         .equ    offsave,h'7e        ; save loc for off time
  51. ;
  52.                 .org    h'0000
  53.                 ljmp    init
  54. ;
  55. ; since the serial port is the last interrupt vector, the entire service
  56. ; routine will start at the vector address (23h)
  57.                 .org    h'0023                  ; serial port service routine
  58. ;
  59. serialserv:     jb      ri,notti
  60.                 reti
  61. notti:          clr     ea
  62.                 push    psw
  63.                 push    acc
  64.                 clr     ri                      ; clear interrupt flag
  65.                 mov     a,sbuf                  ; get char from buffer
  66.                 mov     c,p
  67.                 cpl     c
  68.                 anl     a,#h'7f                 ; mask parity
  69. ;               mov     p1,a                    ; send char to port 1
  70.                 mov     rxchar,a                ; save charater
  71.                 setb    gotchar
  72.                 pop     acc
  73.                 pop     psw
  74.                 setb    ea
  75.                 reti
  76. ;
  77. ; main program
  78. ;
  79. init:           mov     sp,#h'30                ; initialize the stack pointer
  80. ;
  81. ; port configuration
  82. ;
  83.                 mov     p1,#h'ff                ; configure port 1 outputs
  84. ;
  85. ; interrupt section
  86. ;
  87.                 mov     ie,#b'00010001          ; enable ext0 and es
  88.                 mov     ip,#b'00000001          ; int0 has highest priority
  89. ;
  90. ; timer configuration section.  Timer 1 will be generating the serial clock
  91. ; signal for 9600 baud 7 bits odd parity
  92. ;
  93.                 mov     scon,#b'01010010        ; mode 1, reception enabled
  94.                                                 ; and set xmit ready
  95.                 mov     tcon,#b'11010011        ; auto reload 
  96.                                                 ; int0 falling edge triggered
  97.                 mov     tmod,#b'00100010        ; timers 1 and 0 auto reload
  98.                                                 ; 8 bit timer mode
  99.                 mov     th1,#h'fd               ; timer 1 reload value 9600BPS
  100.                 setb    tr1                     ; turn on timer
  101. ;
  102.  
  103. mainloop:    jb    gotchar,inchar        ; wait for a character
  104.         jnb    onstate,mainloop
  105.         mov    onsave,r2            ; save r2 and r3
  106.         mov    offsave,r3
  107.         setb    p0.1
  108.         djnz    r2,*            ; keep motor on for r2 counts
  109.         clr    p0.1
  110.         djnz    r3,*            ; turn motor off for r3 counts
  111.         mov    r2,onsave
  112.         mov    r3,offsave
  113.         sjmp    mainloop
  114.  
  115. inchar:        mov    a,rxchar
  116.         clr    gotchar
  117.         cjne    a,#'O',noton        ; is character an O (on)
  118. on:        setb    onstate
  119.         ajmp    mainloop
  120.         
  121. noton:        cjne    a,#'F',speed        ; is chacacter an F (off)
  122. off:        clr    onstate
  123.         ajmp    mainloop
  124.  
  125. speed:        cjne    a,#1,invalid        ; is char a speed header (^A)
  126.         jnb    gotchar,*
  127.         mov    a,rxchar        ; get on time
  128.         clr     gotchar
  129.         mov    r2,a
  130.         jnb    gotchar,*        
  131.         mov    a,rxchar        ; get off time
  132.         clr     gotchar
  133.         mov    r3,a
  134.  
  135. invalid:    ajmp    mainloop
  136.  
  137.         .end
  138.         .eof
  139.  
  140. --- CUT HERE ---
  141.  
  142. :03000000020041BA
  143. :1000230020980132C2AFC0D0C0E0C298E599A2D0F7
  144. :10003300B3547FF57FD208D0E0D0D0D2AF327581F0
  145. :10004300307590FF75A81175B8017598527588D3EE
  146. :10005300758922758DFDD28E200815307EFA8A7F30
  147. :100063008B7ED281DAFEC281DBFEAA7FAB7E80E883
  148. :10007300E57FC208B44F04D27E015BB44604C27E5E
  149. :10008300015BB401103008FDE57FC208FA3008FDBA
  150. :07009300E57FC208FB015BE1
  151. :00000001FF
  152.