Shop OBEX P1 Docs P2 Docs Learn Events
X10 CM11A interface simulator — Parallax Forums

X10 CM11A interface simulator

ArchiverArchiver Posts: 46,084
edited 2002-10-30 02:53 in General Discussion
I've never heard of such a thing (until now, I would have thought:
"whats the point?"). But it shouldn't be too hard to write, the CM11A
protocol is fairly well documented and understood (and simple).

On Mon, 2002-10-28 at 15:26, peter verkaik wrote:
> Does anyone know if there is a stamp program (or pic, sx or other
> microcontroller)
> that emulates a X10 CM11A interface? I would like to use Home Control
> Assistant
> as a GUI towards the stamp, even though there are no real X10 devices, but I
> do have
> 80 digital inputs/outputs that I would like to control using ON and OFF
> commands and
> to read their status using the GUI. HCA allows me to display floorplans and
> startup
> external programs if necessary.
>

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2002-10-28 12:32
    You can find some VB CM11A source code examples at Dave Houstons page
    here: http://www.laser.com/dhouston/source.htm (there is no Stamp code,
    as Dave is a bit of a BX-24 proponent, but we all have our shortfalls [noparse]:)[/noparse]
    )

    I was thinking that if all you wanted to do is send simple on/off sensor
    commands then you wouldn't have the need to implement the *full* CM11A
    protocol, but rather just the portions that were relevant to your
    project.

    In any regard, I don't have any stamp code to share, but it sounds like
    a fun project to develop [noparse]:)[/noparse]

    Best of luck...

    On Mon, 2002-10-28 at 16:26, peter verkaik wrote:
    > Hi Brian,
    >
    > The protocol is indeed quite simple as I found in the description at
    > http://software.x10.com/pub/manuals/cm11a_protocol.txt
    > but programming a complete emulator that supports polling and
    > extended codes (for data transfer) is still quite a task so I hope
    > someone has some code to point me to.
    >
  • ArchiverArchiver Posts: 46,084
    edited 2002-10-28 20:26
    Hi all,

    Does anyone know if there is a stamp program (or pic, sx or other
    microcontroller)
    that emulates a X10 CM11A interface? I would like to use Home Control
    Assistant
    as a GUI towards the stamp, even though there are no real X10 devices, but I
    do have
    80 digital inputs/outputs that I would like to control using ON and OFF
    commands and
    to read their status using the GUI. HCA allows me to display floorplans and
    startup
    external programs if necessary.

    Thanks,
    Peter
  • ArchiverArchiver Posts: 46,084
    edited 2002-10-28 21:26
    Hi Brian,

    The protocol is indeed quite simple as I found in the description at
    http://software.x10.com/pub/manuals/cm11a_protocol.txt
    but programming a complete emulator that supports polling and
    extended codes (for data transfer) is still quite a task so I hope
    someone has some code to point me to.

    Regards peter


    Oorspronkelijk bericht
    Van: Brian [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=PdFy-juxSrFNrQvtEXtBNMjRnXI5Ih59DlFiGlTjl17lLkrArpEhFoJ-MzKfg4tcRnUSPaSK27D_sg]stamp@k...[/url
    Verzonden: maandag 28 oktober 2002 03:46
    Aan: basicstamps@yahoogroups.com
    Onderwerp: Re: [noparse][[/noparse]basicstamps] X10 CM11A interface simulator

    I've never heard of such a thing (until now, I would have thought:
    "whats the point?"). But it shouldn't be too hard to write, the CM11A
    protocol is fairly well documented and understood (and simple).

    On Mon, 2002-10-28 at 15:26, peter verkaik wrote:
    > Does anyone know if there is a stamp program (or pic, sx or other
    > microcontroller)
    > that emulates a X10 CM11A interface? I would like to use Home Control
    > Assistant
    > as a GUI towards the stamp, even though there are no real X10 devices, but
    I
    > do have
    > 80 digital inputs/outputs that I would like to control using ON and OFF
    > commands and
    > to read their status using the GUI. HCA allows me to display floorplans
    and
    > startup
    > external programs if necessary.
    >


    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject and
    Body of the message will be ignored.


    Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
  • ArchiverArchiver Posts: 46,084
    edited 2002-10-30 02:53
    Hi all,

    I was unable to finf any code to simulate a CM11a so I started to write my
    own.
    The code below communicates between the HCA program and a stamp.
    HCA can be found at http://www.hcatech.com/
    To communicate a MAX232 converter is necessary. (the program port won't do).
    The program below decodes single devices only.
    I defined a floorplan and 4 test devices (X10 LM465 light modules) that only
    support on and off. (for now)
    The stamp debug window shows the house code, device code and
    function.(on/off)
    If you would like to test it for yourself, first startup the stamp with this
    program
    and then HCA because HCA sends an init byte at startup.

    Hope this first design is also helpful to others requiring a GUI for the
    stamp.

    Regards peter

    '{$STAMP BS2sx}
    'CM11A simulator
    '===============

    'baudrate definitions for bs2sx (through line driver)

    N81_4800 con 500

    'Pin names

    RX2 con 2 'serial input (via MAX232)
    TX2 con 3 'serial output (via MAX232)
    TX1 con 16 'PC port serial out
    RX1 con 16 'PC port serial in

    'Application variables

    n var byte
    j var byte

    cm_header var byte
    cm_sync var cm_header.bit2
    cm_FA var cm_header.bit1
    cm_ES var cm_header.bit0

    cm_code var byte
    cm_housecode var cm_code.highnib
    cm_devicecode var cm_code.lownib
    cm_function var cm_code.lownib

    cm_checksum var byte
    cm_acknowledge var byte
    code_house var nib
    code_device var nib
    code_function var nib

    cm_flags var nib
    house_valid var cm_flags.bit0
    device_valid var cm_flags.bit1
    function_valid var cm_flags.bit2

    CM_PC_ACK con $00
    CM_READY con $55
    CM_FA_ADDRESS con 0
    CM_FA_FUNCTION con 1
    CM_ES_STANDARD con 0
    CM_ES_EXTENDED con 1

    'Housecode Device Code Binary Value Hex Value
    'A 1 0110 06
    'B 2 1110 0E
    'C 3 0010 02
    'D 4 1010 0A
    'E 5 0001 01
    'F 6 1001 09
    'G 7 0101 05
    'H 8 1101 0D
    'I 9 0111 07
    'J 10 1111 0F
    'K 11 0011 03
    'L 12 1011 0B
    'M 13 0000 00
    'N 14 1000 08
    'O 15 0100 04
    'P 16 1100 0C

    'Function Binary Value Hex Value
    'All Units Off 0000 00
    'All Lights On 0001 01
    'On 0010 02
    'Off 0011 03
    'Dim 0100 04
    'Bright 0101 05
    'All Lights Off 0110 06
    'Extended Code 0111 07
    'Hail Request 1000 08
    'Hail Acknowledge 1001 09
    'Pre-set Dim (1) 1010 0A
    'Pre-set Dim (2) 1011 0B
    'Extended Data Transfer 1100 0C
    'Status On 1101 0D
    'Status Off 1110 0E
    'Status Request 1111 0F

    CM_All_Units_Off con $00
    CM_All_Lights_On con $01
    CM_On con $02
    CM_Off con $03
    CM_Dim con $04
    CM_Bright con $05
    CM_All_Lights_Off con $06
    CM_Extended_Code con $07
    CM_Hail_Request con $08
    CM_Hail_Acknowledge con $09
    CM_Preset_Dim1 con $0A
    CM_Preset_Dim2 con $0B
    CM_Extended_Data_Transfer con $0C
    CM_Status_On con $0D
    CM_Status_Off con $0E
    CM_Status_Request con $0F

    CM_BAUD con N81_4800
    CM_TX con TX2
    CM_RX con RX2

    'For a CM11, the status request is: 0x8b.

    'The status request is immediately followed by:

    'Bit range Init value Description
    '111 to 96 $FFFF Battery timer (set to 0xffff on reset)
    '95 to 88 $00 Current time (seconds)
    '87 to 80 $00 Current time (minutes ranging from 0 to 119)
    '79 to 72 $00 Current time (hours/2, ranging from 0 to 11)
    '71 to 63 $00 Current year day (MSB bit 63)
    '62 to 56 $01 Day mask (SMTWTFS)
    '55 to 52 $0 Monitored house code
    '51 to 48 $0 Firmware revision level 0 to 15
    '47 to 32 $0000 Currently addressed monitored devices
    '31 to 16 $0000 On / Off status of the monitored devices
    '15 to 0 $0000 Dim status of the monitored devices

    cm_init data $00,$00,$00,$00
    data $00,$00,$00,$01
    data $00,$00,$00,$00
    data $FF,$FF

    begin:
    debug "CM11A SIMULATOR",cr
    debug "===============",cr,cr

    debug "waiting for init",cr
    gosub cm_startup
    main7:
    serout CM_TX,CM_BAUD,[noparse][[/noparse]CM_READY]
    serin CM_RX,CM_BAUD,[noparse][[/noparse]cm_header]
    main8:
    serin CM_RX,CM_BAUD,[noparse][[/noparse]cm_code]
    cm_checksum = (cm_header + cm_code) & $FF
    serout CM_TX,CM_BAUD,[noparse][[/noparse]cm_checksum]
    serin CM_RX,CM_BAUD,[noparse][[/noparse]cm_acknowledge]
    if cm_acknowledge = CM_PC_ACK then decode6
    cm_header = cm_acknowledge
    goto main8
    decode6:
    lookdown
    cm_housecode,[noparse][[/noparse]$6,$E,$2,$A,$1,$9,$5,$D,$7,$F,$3,$B,$0,$8,$4,$C],code_house
    house_valid = 1
    if cm_FA = CM_FA_FUNCTION then decode7
    lookdown
    cm_devicecode,[noparse][[/noparse]$6,$E,$2,$A,$1,$9,$5,$D,$7,$F,$3,$B,$0,$8,$4,$C],code_device
    device_valid = 1
    goto decode8
    decode7:
    code_function = cm_function
    function_valid = 1
    decode8:
    if cm_flags & $07 <> 7 then main7
    debug "house=",$41+code_house," device=",dec 1+code_device," function=",dec
    code_function,cr
    cm_flags = cm_flags & $08
    debug "ready...",cr
    goto main7

    cm_startup:
    serin CM_RX,CM_BAUD,[noparse][[/noparse]cm_header]
    if cm_header <> $8B then cm_startup
    for j=0 to 13
    read cm_init+j,n
    serout CM_TX,CM_BAUD,[noparse][[/noparse]n]
    next
    debug "ready...",cr
    return

    end
Sign In or Register to comment.