Reading HE433-2/R data with Flowcode 4
Posted: Fri Jan 29, 2010 3:24 pm
I use a sender and receiver HE433-2/R of Heiland (http://www.heiland-electronic.de/uhf-mod.htm) for my turnouts/points of my gradenrailway. I want to use the digital output of the receiver to control directly the servo’s used to switch the pneumatic switches. http://lichtenbelt.com/jan/trein/kleintjestoom.htm (see number 3)
I first wrote an assembler program for PICKit 2 and later an improved assembler version for Flowcode 4. Time critical steps are found by just counting the program steps (no timer used). It works correctly, but it does not use the simple Flowcode possibilities. So I thought that must be possible to program in Flowcode 4. But after 3 weeks without success. If you like to help please read the details below.
The sequence of the digital output has not been published, but with a scope, see picture, I found out that there are 4 bytes, repeated in a time frame of 84 bits. The 4 bytes are preceeded by a startbit β€1β€ and followed by a controlbit (β€1β€ for an even number of bits in the byte, else β€0β€). The total length is thus 10 bits followed by 6 bits β€0β€. Between the last control bit and the first start bit of the next sequence are 26 bits β€0β€.
There is one problem, the bit width is about 120 usec and the distance between two bits is about 104 usec. That means two bits β€1β€ will overlap and detection of these two bits simple by detection low-high and high-low is not possible. One must know the bit-width and the bit-distance first.
An example is given in the picture. High is β€0β€and low is β€1β€. The first byte is always 0x00, the second address-byte is in this case also 0x00, the third data-byte is in this case 0x80 (see overlap with the startbit) and the forth byte is a controlbyte (which I skip, because I do not know the mathematics for it). The peak at about 9 msec is the first startbit of the second sequence.
I used the following steps
1) Find the bit-distance: Check for at least 20 bits (about 2 msec) the input (E2 in my case for PIC16F877A) to be high. The next bit must be the first start bit. Start the timer (TRM0 with 19200Hz, 52 usec) and wait about 8 msec and find the first bit of the 2 sequence. The time/84 is the distance between the bits.
2) To make it easy, take the bit-width = bit-distance + 15 usec. (bit-width is less critical)
3) Repeat 1) to get the first start bit β€1β€, wait at least a bit-width and read the 8 bits of the first byte. This must be 0x00 and the control bit must be β€1β€
4) After this control bit, wait about 5 bits and check for the next start bit. Read the second startbit-byte-controlbit. Repeat 4) for the third byte and forget the forth controlbyte.
I first wrote an assembler program for PICKit 2 and later an improved assembler version for Flowcode 4. Time critical steps are found by just counting the program steps (no timer used). It works correctly, but it does not use the simple Flowcode possibilities. So I thought that must be possible to program in Flowcode 4. But after 3 weeks without success. If you like to help please read the details below.
The sequence of the digital output has not been published, but with a scope, see picture, I found out that there are 4 bytes, repeated in a time frame of 84 bits. The 4 bytes are preceeded by a startbit β€1β€ and followed by a controlbit (β€1β€ for an even number of bits in the byte, else β€0β€). The total length is thus 10 bits followed by 6 bits β€0β€. Between the last control bit and the first start bit of the next sequence are 26 bits β€0β€.
There is one problem, the bit width is about 120 usec and the distance between two bits is about 104 usec. That means two bits β€1β€ will overlap and detection of these two bits simple by detection low-high and high-low is not possible. One must know the bit-width and the bit-distance first.
An example is given in the picture. High is β€0β€and low is β€1β€. The first byte is always 0x00, the second address-byte is in this case also 0x00, the third data-byte is in this case 0x80 (see overlap with the startbit) and the forth byte is a controlbyte (which I skip, because I do not know the mathematics for it). The peak at about 9 msec is the first startbit of the second sequence.
I used the following steps
1) Find the bit-distance: Check for at least 20 bits (about 2 msec) the input (E2 in my case for PIC16F877A) to be high. The next bit must be the first start bit. Start the timer (TRM0 with 19200Hz, 52 usec) and wait about 8 msec and find the first bit of the 2 sequence. The time/84 is the distance between the bits.
2) To make it easy, take the bit-width = bit-distance + 15 usec. (bit-width is less critical)
3) Repeat 1) to get the first start bit β€1β€, wait at least a bit-width and read the 8 bits of the first byte. This must be 0x00 and the control bit must be β€1β€
4) After this control bit, wait about 5 bits and check for the next start bit. Read the second startbit-byte-controlbit. Repeat 4) for the third byte and forget the forth controlbyte.