EasyManua.ls Logo

ST ST7 - Page 284

ST ST7
317 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
284/317
9 - A Carrier-current System for domestIc Remote Control
InitPorts () ;
InitTimerA() ;
InitTimerB() ;
MISCR = 0x0 ; /* Normal mode (clock/2). */
EnableInterrupts ;
LastDirection = STOP_OPEN ; /* to properly start manual cycle */
StopMotor () ; /* To guarantee motor off at power on */
while (1)
{
if ( HOUSE_CODE == Codes[HouseCode] )
{
switch ( Codes[KeyCode] )
{ /* If code acceptable, energize one of the coils. */
/* They will be de-energized by timer interrupt. */
case CLOSE_COMMAND :
SwitchMotor ( START_CLOSE ) ;
break ;
case OPEN_COMMAND :
SwitchMotor ( START_OPEN ) ;
break ;
}
KeyCode = NO_COMMAND ; /* Erase order. */
HouseCode = NO_COMMAND ; /* Erase order. */
}
if ( ButtonPressed () )
/* Take into account the push button. It overrides the remote
control. */
switch ( LastDirection )
{
case START_OPEN :
SwitchMotor ( STOP_OPEN ) ;
break ;
case STOP_OPEN :
SwitchMotor ( START_CLOSE ) ;
break ;
case START_CLOSE :
SwitchMotor ( STOP_CLOSE ) ;
break ;
case STOP_CLOSE :
SwitchMotor ( START_OPEN ) ;
break ;
}
/* Update state when end-of travel automatic stop. */
switch ( LastDirection )
{
case START_OPEN :
if ( ReadADC ( MOTOR_ADC_CHANNEL ) < RUNNING_VOLTAGE )

Table of Contents

Related product manuals