home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format 44 / af044.adf / Serious_Stuff / Controller.AMOS / Controller.amosSourceCode
AMOS Source Code  |  1993-01-21  |  6KB  |  174 lines

  1. '14/12/92  
  2. '                          POWER SUPPLY CONTROLLER SOFTWARE  
  3. '                                BY Stuart Tavener 
  4. '                              
  5. '                                  Calibration (On/Off)
  6. '                                  Manual Output 
  7. '                                  Automatic Output
  8. '    
  9. '
  10. 'Procedure to output value to chip selected by pin 10
  11. '
  12. 'clear all select lines for clean start(this could be done at the start of 
  13. '                                       THE MAIN PROGRAM)
  14. 'Bclr 0,P            - Changes 1 bit of DATA 'P' which is the parallel port  
  15. '                      I/O register to 0 and Parallel Port pin 10 to 0 volts     
  16. 'Bclr 1,P            - Clear the other two as well (Pin 11)    
  17. 'Bclr 2,P            - (Pin 12)  
  18. '
  19. 'Poke (PRA),P        - Actually sends the changed value of 'P' to the Port 
  20. '                      register, only now will it take effect. 
  21. '
  22. 'Set the chip select line
  23. 'Bset 0,P            - Set only first Bit high, which will set pin 10 on 
  24. '                      the parallel port to 5 Volts after 'P' is 'Poked' 
  25. '                                                            
  26. 'Then output value to the parallel port register             
  27. 'Poke (PRB),136      - Poke ANY value (0 to 255) to the Parallel Port Register   
  28. '
  29. 'Then activate the Select line to let correct DAC recive the value on the port 
  30. 'Poke (PRA),P        - Pokes previously changed value P which set the  
  31. '                    - Pin 10 at 5 Volts for the DAC to become active. 
  32. '
  33. 'Then Clear the Select line so that the DAC is not selected... 
  34. 'Bclr 0,P    
  35. 'Poke (PRA),P
  36. '
  37. 'Then the Parallel port data can be changed and the next DAC or next set 
  38. 'of data be sent out as from the beginning 
  39. 'This can be simplified of course to fit on one line as in the program 
  40. 'below.
  41. ' The only RULE to be followed is that the chip select line should NOT 
  42. ' be set high BEFORE the data is output, otherwise the data recived
  43. ' by the DAC will change and old voltages will appear first before 
  44. ' the new data is sent out.
  45. '
  46. '
  47.    Screen Open 1,640,256,8,Hires
  48.    Curs Off 
  49.                               Rem Setup Port Addresses 
  50.    PRB=$BFE101
  51.    DDRB=$BFE301
  52.    PRA=$BFD000
  53.    DDRA=$BFD200
  54.                               Rem Set Port Directions  
  55.    Poke(DDRB),%11111111
  56.    Poke(DDRA),%111
  57.                               Rem Let Parallel Port Data be global 
  58.    P=Peek(PRA)
  59. MENU:
  60. '
  61.                               Rem Clear Data on Port 
  62.    Bclr 0,P : Poke(PRB),0 : Poke(PRA),P
  63. '
  64.                               Rem Setup Menu Screen
  65.    Cls 
  66.    Locate 0,5
  67.    Print "                     Computer Controlled Power Supply"
  68.    Print "                           By Stuart Tavener"
  69.    Print ""
  70.    Print "                        Using PSU Output board"
  71.    Print "                      With Select line on Pin 10"
  72.    Print ""
  73.    Print "                          1 - Calibration"
  74.    Print "                          2 - Output Value"
  75.    Print "                          3 - Ramp"
  76.    Print ""
  77.    Print "                          4 - Quit Program"
  78.    Print ""
  79.    Print "                          Enter Choice - "
  80. '
  81.    Do 
  82.       A$=Inkey$
  83.       If A$="1" Then Goto CALIBRATION
  84.       If A$="2" Then Goto OUTPUT
  85.       If A$="3" Then Goto RAMP
  86.       If A$="4" Then End 
  87.    Loop 
  88. '              
  89.  CALIBRATION:
  90. '
  91.    Cls 
  92.    Locate 0,5
  93.    Print "                             CALIBRATION SETUP"
  94.    Print ""
  95.    Print ""
  96.    Print "               Press LEFT Mouse Button To set Output at FULL"
  97.    Print "               and then alter the Maximum Output Voltage"
  98.    Print "               by turning the 100K Preset"
  99.    Print ""
  100.    Print "               Press RIGHT Mouse Button to set Output at ZERO"
  101.    Print ""
  102.    Print "                Hit 'Q' to Quit and return to the Main Menu"
  103. '
  104.    Do 
  105. '
  106.                                     Rem Return to Menu if Q is pressed 
  107.       QUIT$=Inkey$ : If QUIT$="q" Then Goto MENU
  108. '
  109.       Locate 20,20
  110.       If Mouse Key=1 Then Bset 0,P : Poke(PRB),255 : Poke(PRA),P : Print "FULL"
  111.       If Mouse Key=2 Then Bclr 0,P : Poke(PRB),0 : Poke(PRA),P : Print "ZERO"
  112.    Loop 
  113. '
  114. '
  115.  OUTPUT:
  116.    Cls 
  117.    Locate 0,5
  118.    Print "                       Manual Output Control"
  119.    Print ""
  120.    Print "             Please Type in a number between 0 and 255"
  121.    Print "          this will output a ratio of your Input Voltage"
  122.    Print "          i.e if using 12v Power Supply, Smallest Step"
  123.    Print "                of 1 will be 12v/255 steps = 0.05v"
  124.    Print "                  50 will be     0.05 * 50 = 2.5v"
  125.    Print ""
  126.    Print "           Type '999' to Quit and return to the Main Menu"
  127. '
  128.    Do 
  129.       Locate 39,15 : Print "           "
  130.       Locate 0,15
  131.       Input "                  Please Input Value = ";VOLTAGE
  132.       If VOLTAGE=999 Then Goto MENU
  133.       If VOLTAGE<0 Then VOLTAGE=0
  134.       If VOLTAGE>255 Then VOLTAGE=255
  135.       Bset 0,P : Poke(PRB),VOLTAGE : Poke(PRA),P
  136.       Locate 39,20 : Print "    "
  137.       Locate 0,20
  138.       Print "                 Output Value now at = ";VOLTAGE
  139.    Loop 
  140. '
  141. '
  142.  RAMP:
  143.    Bset 0,P : Poke(PRA),P
  144.    Cls 
  145.    Locate 0,5
  146.    Print "                       Automatic Output Control"
  147.    Print ""
  148.    Print "         The computer is Constantly increasing the output"
  149.    Print "         voltage in single steps up to the user definable"
  150.    Print "         value (max is 255), "
  151.    Print "        use the '+' Key on the KEYPAD to Increase this Value"
  152.    Print "        use the '-' Key on the KEYPAD to Decrease this Value"
  153.    Print ""
  154.    Print "                Hit 'Q' to Quit and return to the Main Menu"
  155. '
  156.    Do 
  157. '
  158.       QUIT$=Inkey$ : If QUIT$="q" Then Goto MENU
  159.       Locate 39,15 : Print "         "
  160.       Locate 0,15
  161.       Print "                 The current Value = ";HIGHEST
  162. '
  163.       Locate 0,20
  164.       Print "                The current Output = ";OUT
  165. '
  166.       CHANGE$=Inkey$
  167.       If CHANGE$="+" Then Inc HIGHEST
  168.       If CHANGE$="-" Then Dec HIGHEST
  169.       If HIGHEST<0 Then HIGHEST=0
  170.       If VOLTAGE>255 Then HIGHEST=255
  171.       Inc OUT
  172.       If OUT=>HIGHEST Then OUT=0 : Locate 39,20 : Print "   "
  173.       Poke(PRB),OUT
  174.    Loop