'***********************************************************************
'*                    <Tremulant solenoid controller>                  *
'*                                 by                                  *
'*                        Dr.Godfried-Willem RAES                      *
'*                      Stamp1 Hardware version 1.4                    *
'*                       Filename : <vohumtre.bs1>                     *
'*                           Code version 1.0                          *
'***********************************************************************
' 22.05.2003: Version for Vox Humanola Tremulant.

' INITIALISATION:
                    ' parallel input bits 0 to 6
                    ' these bits are mapped on midi notes 8-14 / 16-22
                    ' make these bits inputs:
DIR0 = 0
DIR1 = 0
DIR2 = 0
DIR3 = 0
DIR4 = 0
DIR5 = 0
DIR6 = 0
DIR7 = 1            ' switching output, so must be output.
LOW 7			  ' OFF on start.
' stated in its most compact form:
'DIRS = %10000000

ReadInput:
      b2 = pins & %01111111       ' isolate lowest 7 bits
      IF b2 < 1 then SwitchOff
      w2 = b2         ' byte is incoming info 1-127
      w3 = w2 * 2	    ' = 2 to 254 milliseconds
	w2 = 316 - w3
      HIGH 7
      Pause w2        ' ontime  - range 314ms - 62ms
      LOW 7
      Pause w2        ' offtime
                      ' the frequency will vary between 1.59Hz and 8.06Hz
goto ReadInput


SwitchOff:
      LOW 7
      b2 = pins & %01111111
      if b2 > 0 then ReadInput
GOTO SwitchOff 

END

bsave               ' creates an OBJ file to disk
