Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
BASCOM AVR, help reference (2007).PDF
Скачиваний:
305
Добавлен:
12.08.2013
Размер:
17.02 Mб
Скачать

© MCS Electronics, 1995-2007

'20 OFF

'21 DIM '22 BRIGHT

'23 All lights off '24 extended code '25 hail request '26 hail acknowledge '27 preset dim

'28 preset dim

'29 extended data analog '30 status on

'31 status off '32 status request

X10send House , X

' send the code

Loop

 

Dim Ar(4) As Byte

' send 4

X10send House , X , Ar(1) , 4

additional bytes

 

End

 

X10SEND

Action

Sends a house and key code with the X10 protocol.

Syntax

X10SEND house , code

Remarks

House

The house code in the form of a letter A-P.

 

You can use a constant, or you can use a variable

Code

The code or function to send. This is a number between 1-32.

 

 

The X10SEND command needs a TW-523 interface.

Only ground, TX and Zero Cross, needs to be connected for transmission. Use CONFIG X10 to specify the pins.

X10 is a popular protocol used to control equipment via the mains. A 110 Khz signal is added to the normal 50/60 Hz , 220/110 V power.

Notice that experimenting with 110V-240V can be very dangerous when you do not know exactly what you are doing !!!

In the US, X10 is very popular and wide spread. In Europe it is hard to get a TW-523 for 220/230/240 V.

I modified an 110V version so it worked for 220V. On the Internet you can find modification information. But as noticed before, MODIFY ONLY WHEN YOU UNDERSTAND WHAT YOU ARE DOING.

page -722-

© MCS Electronics, 1995-2007

A bad modified device could result in a fire, and your insurance will most likely not pay. A modified device will not pass any CE, or other test.

When the TW-523 is connected to the mains and you use the X10SEND command, you will notice that the LED on the TW-523 will blink.

The following table lists all X10 codes.

 

Code value

Description

 

1-16

Used to address a unit. X10 can use a maximum of 16 units per house

 

 

code.

 

17

All units off

 

18

All lights on

 

19

ON

 

20

OFF

 

21

DIM

 

22

BRIGHT

 

23

All lights off

 

24

Extended ode

 

25

Hail request

 

26

Hail acknowledge

 

27

Preset dim

 

28

Preset dim

 

29

Extended data analog

 

30

Status on

 

31

Status off

 

32

Status request

At www.x10.com you can find all X10 information. The intension of BASCOM is not to learn you everything about X10, but to show you how you can use it with BASCOM.

See also

CONFIG X10 , X10DETECT , X10SEND

Example

See X10DETECT

#IF ELSE ENDIF

Action

Conditional compilation directives intended for conditional compilation.

Syntax

#IF condition

#ELSE

page -723-

© MCS Electronics, 1995-2007

#ENDIF

Remarks

Conditional compilation is supported by the compiler. What is conditional compilation?

Conditional compilation will only compile parts of your code that meet the criteria of the condition.

By default all your code is compiled.

Conditional compilation needs a constant to test.

So before a condition can be tested you need to define a constant.

CONST test = 1 #IF TEST

Print "This will be compiled" #ELSE

Print "And this not" #ENDIF

Note that there is no THEN and that #ENDIF is not #END IF (no space)

You can nest the conditions and the use of #ELSE is optional.

There are a few internal constants that you can use. These are generated by the compiler: _CHIP = 0

_RAMSIZE = 128

_ERAMSIZE = 128 _SIM = 0

_XTAL = 4000000

_BUILD = 11162

_CHIP is an integer that specifies the chip, in this case the 2313 _RAMSIZE is the size of the SRAM

_ERAMSIZE is the size of the EEPROM

_SIM is set to 1 when the $SIM directive is used _XTAL contains the value of the specified crystal _BUILD is the build number of the compiler.

The build number can be used to write support for statements that are not available in a certain version :

#IF _BUILD >= 11162 s = Log(1.1)

#ELSE

Print "Sorry, implemented in 1.11.6.2" #ENDIF

Conditional compilation allows you to create different versions of your programbut that you keep one source file.

For example you could make a multi langual program like this :

CONST LANGUAGE=1

'program goes here

#IF LANGUAGE=1

page -724-

© MCS Electronics, 1995-2007

DATA "Hello" #ENDIF

#IF LANGUAGE=2 DATA "Guten tag"

#ENDIF

By changing the just one constant you then have for example English or German data lines.

Conditonal compilation does not work with the $REGFILE directive. If you put the $REGFILE inside a condition or not, the compiler will use the first $REGFILE it encounters. This wil be changed in a future verison.

A special check was added to 1.11.8.1 to test for existance of constants or variables. #IF varexist("S")

'the variable S was dimensioned so we can use it here #ELSE

'when it was not dimmed and we do need it, we can do it here DIM S as BYTE

#ENDIF

See Also

CONST

page -725-