home *** CD-ROM | disk | FTP | other *** search
AMOS Source Code | 1993-01-21 | 5.9 KB | 174 lines |
- '14/12/92
- ' POWER SUPPLY CONTROLLER SOFTWARE
- ' BY Stuart Tavener
- '
- ' Calibration (On/Off)
- ' Manual Output
- ' Automatic Output
- '
- '
- 'Procedure to output value to chip selected by pin 10
- '
- 'clear all select lines for clean start(this could be done at the start of
- ' THE MAIN PROGRAM)
- 'Bclr 0,P - Changes 1 bit of DATA 'P' which is the parallel port
- ' I/O register to 0 and Parallel Port pin 10 to 0 volts
- 'Bclr 1,P - Clear the other two as well (Pin 11)
- 'Bclr 2,P - (Pin 12)
- '
- 'Poke (PRA),P - Actually sends the changed value of 'P' to the Port
- ' register, only now will it take effect.
- '
- 'Set the chip select line
- 'Bset 0,P - Set only first Bit high, which will set pin 10 on
- ' the parallel port to 5 Volts after 'P' is 'Poked'
- '
- 'Then output value to the parallel port register
- 'Poke (PRB),136 - Poke ANY value (0 to 255) to the Parallel Port Register
- '
- 'Then activate the Select line to let correct DAC recive the value on the port
- 'Poke (PRA),P - Pokes previously changed value P which set the
- ' - Pin 10 at 5 Volts for the DAC to become active.
- '
- 'Then Clear the Select line so that the DAC is not selected...
- 'Bclr 0,P
- 'Poke (PRA),P
- '
- 'Then the Parallel port data can be changed and the next DAC or next set
- 'of data be sent out as from the beginning
- 'This can be simplified of course to fit on one line as in the program
- 'below.
- ' The only RULE to be followed is that the chip select line should NOT
- ' be set high BEFORE the data is output, otherwise the data recived
- ' by the DAC will change and old voltages will appear first before
- ' the new data is sent out.
- '
- '
- Screen Open 1,640,256,8,Hires
- Curs Off
- Rem Setup Port Addresses
- PRB=$BFE101
- DDRB=$BFE301
- PRA=$BFD000
- DDRA=$BFD200
- Rem Set Port Directions
- Poke(DDRB),%11111111
- Poke(DDRA),%111
- Rem Let Parallel Port Data be global
- P=Peek(PRA)
- MENU:
- '
- Rem Clear Data on Port
- Bclr 0,P : Poke(PRB),0 : Poke(PRA),P
- '
- Rem Setup Menu Screen
- Cls
- Locate 0,5
- Print " Computer Controlled Power Supply"
- Print " By Stuart Tavener"
- Print ""
- Print " Using PSU Output board"
- Print " With Select line on Pin 10"
- Print ""
- Print " 1 - Calibration"
- Print " 2 - Output Value"
- Print " 3 - Ramp"
- Print ""
- Print " 4 - Quit Program"
- Print ""
- Print " Enter Choice - "
- '
- Do
- A$=Inkey$
- If A$="1" Then Goto CALIBRATION
- If A$="2" Then Goto OUTPUT
- If A$="3" Then Goto RAMP
- If A$="4" Then End
- Loop
- '
- CALIBRATION:
- '
- Cls
- Locate 0,5
- Print " CALIBRATION SETUP"
- Print ""
- Print ""
- Print " Press LEFT Mouse Button To set Output at FULL"
- Print " and then alter the Maximum Output Voltage"
- Print " by turning the 100K Preset"
- Print ""
- Print " Press RIGHT Mouse Button to set Output at ZERO"
- Print ""
- Print " Hit 'Q' to Quit and return to the Main Menu"
- '
- Do
- '
- Rem Return to Menu if Q is pressed
- QUIT$=Inkey$ : If QUIT$="q" Then Goto MENU
- '
- Locate 20,20
- If Mouse Key=1 Then Bset 0,P : Poke(PRB),255 : Poke(PRA),P : Print "FULL"
- If Mouse Key=2 Then Bclr 0,P : Poke(PRB),0 : Poke(PRA),P : Print "ZERO"
- Loop
- '
- '
- OUTPUT:
- Cls
- Locate 0,5
- Print " Manual Output Control"
- Print ""
- Print " Please Type in a number between 0 and 255"
- Print " this will output a ratio of your Input Voltage"
- Print " i.e if using 12v Power Supply, Smallest Step"
- Print " of 1 will be 12v/255 steps = 0.05v"
- Print " 50 will be 0.05 * 50 = 2.5v"
- Print ""
- Print " Type '999' to Quit and return to the Main Menu"
- '
- Do
- Locate 39,15 : Print " "
- Locate 0,15
- Input " Please Input Value = ";VOLTAGE
- If VOLTAGE=999 Then Goto MENU
- If VOLTAGE<0 Then VOLTAGE=0
- If VOLTAGE>255 Then VOLTAGE=255
- Bset 0,P : Poke(PRB),VOLTAGE : Poke(PRA),P
- Locate 39,20 : Print " "
- Locate 0,20
- Print " Output Value now at = ";VOLTAGE
- Loop
- '
- '
- RAMP:
- Bset 0,P : Poke(PRA),P
- Cls
- Locate 0,5
- Print " Automatic Output Control"
- Print ""
- Print " The computer is Constantly increasing the output"
- Print " voltage in single steps up to the user definable"
- Print " value (max is 255), "
- Print " use the '+' Key on the KEYPAD to Increase this Value"
- Print " use the '-' Key on the KEYPAD to Decrease this Value"
- Print ""
- Print " Hit 'Q' to Quit and return to the Main Menu"
- '
- Do
- '
- QUIT$=Inkey$ : If QUIT$="q" Then Goto MENU
- Locate 39,15 : Print " "
- Locate 0,15
- Print " The current Value = ";HIGHEST
- '
- Locate 0,20
- Print " The current Output = ";OUT
- '
- CHANGE$=Inkey$
- If CHANGE$="+" Then Inc HIGHEST
- If CHANGE$="-" Then Dec HIGHEST
- If HIGHEST<0 Then HIGHEST=0
- If VOLTAGE>255 Then HIGHEST=255
- Inc OUT
- If OUT=>HIGHEST Then OUT=0 : Locate 39,20 : Print " "
- Poke(PRB),OUT
- Loop