Thorian USB Interface

For all other Thorian devices, see the Thorian section

 

 

Overview

This device is the bridge between Open Source Automation PC software and the Thorian wireless devices.

The interface connection to te PC itself is via a USB to serial (TTL) converter lead. This allows direct connection straight into the microcontroller (note this is not an RS232 interface).

 

Data received from the PC then gets converted and broadcast over the RF transmitter.

Also visa versa, correct data received is passed from the module to the PC.

 

Quick Fast‑Track Build

Parts List

  • USB → TTL serial cable (e.g. from eBay)
  • 434 MHz AM RX/TX module pair (310 MHz for USA)
  • PIC16F88 microcontroller (pre‑programmed with PCUSB21.hex below)
  • 3 mm bi‑colour LED + 330 Ω resistor
  • 100 µF electrolytic capacitor
  • Veroboard or pre‑designed PCB

Initial testing of the USB cable

Follow the instructions to install the drivers on the Windows PC. You can test that the USB to serial lead is working by shorting the RX and TX together (careful not to short anything else).

Select the comm port in the windows test program.

Any commands sent from the test program should appear in the receive window. Fill some numbers into the address, data1, data2 and data3. click send command. The data should appear as a received command.

Wiring & Assembly

  1. Solder USB cable wires:
    Red → VCC (5 V)
    Black → GND
    Green (PC TX) → RB0
    White (PC RX) → RB1
  2. Connect:
    RF TX data line to RA2
    RF RX output to RA3
  3. Include an ICSP header for easy PIC re‑flashing.

Operation

  1. Plug USB‑TTL into PC: LED stays green when idle
  2. Run Test App, select COM port → Connect
  3. Set Address ≠ 1 & Data fields to anything, click RGB button → Send
  4. LED flashes red on transmit; flashes green (valid) or double‑flash (invalid) on receive

Downloads



Advanced - Show code, timing diagrams & packet format

TTL‑Serial Transmit Routine

TTLtx:
  MOVWF divisor
  MOVLW D'8'
  MOVWF byteL
  bcf PORTB,1  ; start bit
  MOVLW D'9'
  call uSdelay
mainLoop:
  btfsc divisor,7
  bsf PORTB,1
  call uSdelay
  rlf divisor,F
  decfsz byteL,F
  goto mainLoop
  bsf PORTB,1  ; stop bit
  MOVLW D'9'
  call uSdelay
  return

RF Transmit Packet

RFtx:
  bsf PORTA,2  ; AGC on 9ms
  MOVLW D'18'
  call MSdelay
  bcf PORTA,2  ; AGC off 4.5ms
  MOVLW D'9'
  call MSdelay

  movf deviceaddress,W  ; copy deviceaddress value to W
  movwf data1			 ; copy W to data1
  call doRFbyte		 ; go transmit data1
  ; repeat for devicecommand, devicecommand2, devicecommand3

  bsf PORTA,2  ; stop-burst 670us, wait time before any more data can be transmitted 
  MOVLW D'33'
  call uSdelay
  bcf PORTA,2 ; switch off TX
  return
Bit timingMark (RA2=1)Space (RA2=0)
AGC Burst9 ms4.5 ms
Bit “1”330 µs800 µs
Bit “0”330 µs230 µs
Stop‑burst670 µs

RF Receive & Validation

RFgetByte:
  clrf tempdata
  MOVLW D'8'
  MOVWF counter
getLoop:
  MOVLW D'40'
  call uSdelay
  rrf count,F
  btfss PORTA,3
    goto skipSet
  iorwf tempdata,F
skipSet:
  decfsz counter,F
  goto getLoop
  return

Photos & Gallery


Related Links