PDA

View Full Version : Holtek Decoder



George
- 26th June 2007, 03:16
I'm wondering if anyone has a subroutine to decode a Holtek chip - I've spent a couple of hours on it and am more confused now than when I started!!! I've done a search on here and found several people saying that a pic can easily take place of a holtek decoder chip - but in my brain - not so easy.

I have a LINX ready made transmitter with 8 buttons and a 10 bit address, from what I can figure out it does this:

sync bits: 01010
address bits (if set to 1111100000):11111111110101010101
data bits (button 6 pressed): 0101010101000101

a zero is represented as 00
a one is represented as 11
and open circuit (button not pressed or address switch open) as 01

where a 0 is a 380uS pulse and a 1 is a 760uS pulse, i was trying to do it with pulsin to determine pulsewidth and convert it, I was going to try and bring it in as serial data and play with it then - but it figured out to me to be 770bps - given that I'd get 20 data pulses (for the address) in 26ms and PBP doesn't allow that as a valid speed.

The encoding chip is a holtek HT640 (apparently it's the same protocol as motorola use)

Any help would be greatly appreciated - cheers

mackrackit
- 26th June 2007, 20:06
This might help
http://www.holtek.com.tw/english/tech/appnote/consumer/pdf/ha0040e.pdf

Or this
http://www.picbasic.co.uk/forum/showthread.php?t=6436

With the help I received from the above thread, PIC to PIC and no wires!! Also has more capability as it is not limited to 8 or 10 signals.

If you want, I can post the good code when I get back to the shop(can not do it from memory)

George
- 26th June 2007, 21:53
I've done pic to pic with no wires - I'm wanting holtek to pic with no wires - the remote I've bought has a holtek chip in it so need to decode that - do you have code for a holtek? If so I'd love to see it

Cheers

dhouston
- 26th June 2007, 22:06
There are far, far too many variables.

There are several different Holtek chips and the chip frequency (and thus the pulse/space duration) depends on the value of the resistor used for the oscillator. Some use a two state code, others use a three state code. You need to study the Holtek datasheets for the specific encoder and decoder chips you are using.

Does wireless mean IR or RF? If RF, ASK or FSK?

mackrackit
- 27th June 2007, 01:31
I've done pic to pic with no wires - I'm wanting holtek to pic with no wires - the remote I've bought has a holtek chip in it so need to decode that - do you have code for a holtek? If so I'd love to see it

Cheers

Sorry, no code for the holteks.

In your case just buy the correct decoder.

dhouston
- 27th June 2007, 17:47
I've attached a GIF showing the output waveform from the HT640 sending all ONES, all ZEROS, all ELSE, and repeating those three in ONE, ZERO, ELSE order.

First, you have to pick the start sequence out of the air (usually signals are sent 3-5 times with the first few setting the receiver AGC) and then capture and decipher the following bitstream. You might do this using the CCP hardware in Capture mode, resetting the polarity after each interrupt but it's not a simple task.

As you can see there are two different pulse widths and two different space widths. The actual widths will depend on the transmitter oscillator frequency.

The best advice is to use the Holtek decoder chip with the same oscillator frequency as used by the transmitter.

Bruce
- 30th June 2007, 13:09
The attached code example will decode the Holtek HT640.

Download the Linx .PDF below for details of the 640 data
structure.

http://www.linxtechnologies.com/Documents/encdecdatastruct.pdf

George
- 1st July 2007, 23:00
Hey thanks Bruce exactly what I was looking for

Bruce
- 1st July 2007, 23:17
Hey George,

You're most welcome. It's pretty old, but it's simple & it works.

You can improve the synch bit check part by replacing it with this;

IF PBIT[0] <= PBIT[1] THEN Begin
IF PBIT[1] >= PBIT[2] THEN Begin
IF PBIT[2] <= PBIT[3] THEN Begin

And you can remove this part; IF Loops > 2 THEN Begin

I stripped a lot of code out before posting it, but missed that line. It's bits &
peices of a much larger program that was a first go at decoding the Linx
hand-held.

richb20b
- 26th July 2009, 19:46
Having spent a couple of hours decoding the output from a Holtek HT600 encoder (in a Micromark wireless burglar alarm system), using the voltage divider / sound card / audacity method, I decided to post the specs to save anybody else the trouble...

01 01 0 - 5 bit header
01 01 01 01 01 - A0 A1 A2 A3 A4
01 01 01 01 01 - A5 A6 A7 A8 A9 (note A5 doesn't exist and is always 01)
01 01 01 01 01 - NA AD11 AD12 AD13 AD14
01 01 01 - AD15 NA NA

As noted, there is no A5 pin on the chip - this results in 01 always being present in this field. I'm not sure what the final four bits do, they always seem to be 01.

Hope this helps. I'm hoping Bruce's code will decode this - otherwise I've got the info to write my own :-)

richb20b
- 26th July 2009, 21:23
Having spent a couple of hours decoding the output from a Holtek HT600 encoder (in a Micromark wireless burglar alarm system), using the voltage divider / sound card / audacity method, I decided to post the specs to save anybody else the trouble...

The pulse train looks like this:

01 01 0 - 5 bit header
01 01 01 01 01 - A0 A1 A2 A3 A4
01 01 01 01 01 - A5 A6 A7 A8 A9 (note A5 doesn't exist and is always 01)
01 01 01 01 01 - NA AD11 AD12 AD13 AD14
01 01 01 - AD15 NA NA

0 (pin pulled low) is encoded as 00
1 (pin pulled high) is encoded as 11
- (pin left floating) is encoded as 01

A[0-9] is the address pin (these are connected to DIP switches on my alarm), AD[11-15] are the data pins - these are connected to other switches corresponding to the data that should be sent. As noted, there is no A5 pin on the chip - this results in 01 always being present in this field. I'm not sure what the final four bits do, they always seem to be 0, 1, 0, 1.

Between A9 and AD11 there appears to be two sync bits. These appear to be always 01.

Hope this helps. I'm hoping Bruce's code will decode this - otherwise I've got the info to write my own :-)

tekart
- 6th August 2010, 18:22
Bruce,
Just wanted to thank you for posting that Holtek Decoder code. Really nice job and extremely well documented. I had a job up and running using the Linx CMD-KEY keyfob transmitter in minutes thanks to you. Much appreciated.
Guy


The attached code example will decode the Holtek HT640.

Download the Linx .PDF below for details of the 640 data
structure.

http://www.linxtechnologies.com/Documents/encdecdatastruct.pdf

Bruce
- 6th August 2010, 18:29
Hi Guy,

You're very welcome, and thank you too. I'm glad you found a good use for it.;)

Edit: If you ever need to create your own PIC chip to emulate the Holtek 8-bit encoder too, I posted a pretty cool project for the Crownhill Amicus board here http://www.myamicus.co.uk/content.php?259-PC-Remote-Control with code for one.

And PC software to control the PIC, so you have a PC-based encoder to control your PIC-based decoder. Pretty fun stuff...:o

khong20
- 23rd June 2011, 04:16
the code work great.

i there i am newbie in this forum and also at Picbasic pro, i need help in this code as well. the other PIC cannot receive every single bits :( , pls help
thanks alot


CLEAR
@ device pic16F876A, HS_OSC, wdt_on, lvp_off, protect_off
DEFINE OSC 20

ADDRESS VAR WORD ' Holds 10-bit address
DAT_OUT VAR BYTE ' Holds 8-bit data byte
BITS VAR BYTE ' Bit index for address & data bit pointer
LOOPS VAR BYTE ' Loop var for encode routine
LEDGreen var PORTC.4

' Use this timing for a Holtek HT640 @3V, 390K osc resistor
LONGB CON 732 ' 732uS for long bit & inter-bit delay
SHORTB CON 382 ' 382uS for short bit & inter-bit delay

' Use this timing for a Holtek HT640 @5V, 390K osc resistor
'LONGB CON 861 ' 861uS for long bit & inter-bit delay
'SHORTB CON 431 ' 431uS for short bit & inter-bit delay

SYMBOL E_OUT = PORTB.5 ' Assign encoder data out (to RF module) pin here

' Bank 1 Hardware initialization
'OPTION_REG = 128 ' Pull-ups = off, GPIO.2 = I/O, prescaler to Timer1

' Bank 0 Hardware initialization
PORTB = 0 ' Data output to RF transmitter idles low
TRISB=%00000000 ' all outputs

' sending A#2#3#64 with MCS terminal turns ON relay #1 at address #2
' #3 is sent since the FCTN-RLY4-xxx has the upper 2 address bits of the
' 10-bit decoder address left open (floating).

MAIN:
;DEBUGIN 5000,MAIN,[WAIT("A"),ADDRESS.LOWBYTE,ADDRESS.HIGHBYTE,DAT_OUT]
ADDRESS = $31F '1100011111
DAT_OUT = $99 '10011001

ENCODE_640:
high LEDGreen

FOR LOOPS = 1 TO 8 ' 8 data packet bursts per transmit period
' to simulate user button presses. |
' now do synch period & synch bits _ __ _ __ _|
HIGH E_OUT : PAUSEUS SHORTB ' | | | | | | | | | |
LOW E_OUT : PAUSEUS SHORTB ' | | | | | | | | | |
HIGH E_OUT : PAUSEUS LONGB ' | | | | | | | | | |
LOW E_OUT : PAUSEUS LONGB ' | | | | | | | | | |
HIGH E_OUT : PAUSEUS SHORTB ' | | | | | | | | | | ADDRESS | DATA
LOW E_OUT : PAUSEUS SHORTB ' | | | | | | | | | | 10-BIT | 8-BIT
HIGH E_OUT : PAUSEUS LONGB ' | | | | | | | | | |
LOW E_OUT : PAUSEUS LONGB ' 14mS | | | | | | | | | |
HIGH E_OUT : PAUSEUS SHORTB '_____ | |_| |__| |_| |__| |
' SYNCH BITS |
' now encode/send address
FOR BITS = 0 to 9 ' send 10-bit address
IF ADDRESS.0[BITS] = 1 THEN ' a 1 indicates the address bit is floating. NOT 1
LOW E_OUT : PAUSEUS LONGB
HIGH E_OUT : PAUSEUS SHORTB
LOW E_OUT : PAUSEUS LONGB
HIGH E_OUT : PAUSEUS SHORTB
ELSE
LOW E_OUT : PAUSEUS SHORTB
HIGH E_OUT : PAUSEUS LONGB
LOW E_OUT : PAUSEUS SHORTB
HIGH E_OUT : PAUSEUS LONGB
ENDIF
NEXT BITS

' now encode/send data
FOR BITS = 0 to 7 ' 8-bit data
IF DAT_OUT.0[BITS] THEN
LOW E_OUT : PAUSEUS LONGB
HIGH E_OUT : PAUSEUS SHORTB
LOW E_OUT : PAUSEUS LONGB
HIGH E_OUT : PAUSEUS SHORTB
ELSE
LOW E_OUT : PAUSEUS SHORTB
HIGH E_OUT : PAUSEUS LONGB
LOW E_OUT : PAUSEUS SHORTB
HIGH E_OUT : PAUSEUS LONGB
ENDIF
NEXT BITS
LOW E_OUT ' start synch period @ start of 2nd data packet
PAUSE 14 ' 14mS to 15mS synch period
NEXT LOOPS ' Close loop
LOW E_OUT ' Disable transmitter (turn off carrier)

low LEDGreen
pause 1000
GOTO Main

END

khong20
- 24th June 2011, 07:07
Any Help Pls.. i does received the data but not what i set in

ADDRESS = $31F '1100011111
DAT_OUT = $99 '10011001

shahidali55
- 24th June 2011, 16:55
Try the HT648L. This will decode data from the HT640.
Just make sure you select the same address as the one selected on the encoder (HT640)

Megahertz
- 29th June 2011, 12:17
Just to make sure I am getting it correctly (Bruce's code), is the Frequency of the operation of Holtek 640 in the above example 79Khz (appx) ?