Hi there,
So for anyone following our groups work (Prior Decoding Post), we've done some upgrades to our FPGA code (attached with a constraints file for a Xilinx Artix7). The code now dumps out to a UART for a serial terminal on a computer or laptop instead of sad blinkly lights. Anyways after doing the design we found something rather interesting we're hoping someone out there can give advice on.
***********************************************************************************
Weird thing we see:
***********************************************************************************
When we have the same engine (my DDA40x MTH locomotive), with the same engine number (#69), on the same track, with the same TIU and the same remote (and only the 1 engine on the track, actually the only engine in the building even).... every-time we push the same whistle button on the remote we see a slightly different decoded sequence and very different lengths, which seems super strange.
***********************************************************************************
You can have a look at the attached video here where I investigate the whistle signal in detail on the scope showing the spreading codes and with the FPGA (Who does the decoding) in parallel using the attached verilog code and front end decoder circuit from (Level Shifting).
(this video is low quality since there was a 100M limit... and the green LED is really hard to see on the white board. If you email me I can send you a better video)
If anyone has a good idea or explanation why the code would be different each time (and change in length considerably for the same command repeated over and over), I would really love to discuss!.
A few of my own thoughts first:
We don't know the reason the code is changing each time, but we KNOW it's not noise related. The reason of this is because of how the decoder works... it's spread spectrum meaning a long sequence used to represent a single bit:
The: "101110110101001..." code is used to represent a single "1" (or "0" by flipping it upside down) and the decoding is done by correlation (seeing how many bits match the code) and compared against a confidence threshold (Detailed explaination). In this capture case the threshold is set to 29.. so 29 out of 31 bits have to match the code to produce a "1" in the terminal while 29/31 bits have to be opposite the code to produce a "0" in the terminal. This means that having a random noise won't really affect the captured sequence since the probability of randomly having 29/31 bits match (and in the right position) is 1 in billions. Also if you look at the code... we have the packet detector (a flag which says when the DCS code is detected) that lights the green LED on my FPGA board. You can see in the video the LED doesn't light up until I actually touch the remote, and there is no other DCS signals in the background (which means there's no noise in the idle condition producing false data)
Also we know it's not clock mismatch missing the odd bit here or there or something. Again if the clock was off there might be an error in the 31 chip-sequence code... but as long as 29/31 match, the end result isn't changed. If the clock was far enough off to screw up the packet length by a factor of 29/31 Tperiod then no data would come out at all becasue the XOR lines in the decoder would work in this part:
//-----------------Assign the odd and even registers from the main shift register in order to cover both possible phases----------------
odd_reg <= {sr_reg[60],sr_reg[58],sr_reg[56],sr_reg[54],sr_reg[52],sr_reg[50],
sr_reg[48],sr_reg[46],sr_reg[44],sr_reg[42],sr_reg[40],sr_reg[38],
sr_reg[36],sr_reg[34],sr_reg[32],sr_reg[30],sr_reg[28],sr_reg[26],
sr_reg[24],sr_reg[22],sr_reg[20],sr_reg[18],sr_reg[16],sr_reg[14],
sr_reg[12],sr_reg[10],sr_reg[8], sr_reg[6], sr_reg[4], sr_reg[2],
sr_reg[0]};
eve_reg <= {sr_reg[61],sr_reg[59],sr_reg[57],sr_reg[55],sr_reg[53],sr_reg[51],
sr_reg[49],sr_reg[47],sr_reg[45],sr_reg[43],sr_reg[41],sr_reg[39],
sr_reg[37],sr_reg[35],sr_reg[33],sr_reg[31],sr_reg[29],sr_reg[27],
sr_reg[25],sr_reg[23],sr_reg[21],sr_reg[19],sr_reg[17],sr_reg[15],
sr_reg[13],sr_reg[11],sr_reg[9], sr_reg[7], sr_reg[5], sr_reg[3],
sr_reg[1]};
//-------------Generate the 4 correlation terms--------------
//Even Phase Positive
CE <= eve_reg ~^ PN_code;
//Odd Phase Positive
CO <= odd_reg ~^ PN_code;
//-------------Compute the total correlation--------------
CE_TOTAL = CE[30] + CE[29] + CE[28] + CE[27] + CE[26] + CE[25] + CE[24] + CE[23] + CE[22] + CE[21] +
CE[20] + CE[19] + CE[18] + CE[17] + CE[16] + CE[15] + CE[14] + CE[13] + CE[12] + CE[11] +
CE[10] + CE[9] + CE[8] + CE[7] + CE[6] + CE[5] + CE[4] + CE[3] + CE[2] + CE[1] +
CE[0];
CO_TOTAL = CO[30] + CO[29] + CO[28] + CO[27] + CO[26] + CO[25] + CO[24] + CO[23] + CO[22] + CO[21] +
CO[20] + CO[19] + CO[18] + CO[17] + CO[16] + CO[15] + CO[14] + CO[13] + CO[12] + CO[11] +
CO[10] + CO[9] + CO[8] + CO[7] + CO[6] + CO[5] + CO[4] + CO[3] + CO[2] + CO[1] +
CO[0];
Anyways basically what I am saying is it's mathematically improbable (like 1 in billions) that the decoding is screwed up, so an error should never happen, let alone happen over and over if I keep pushing the button, and this improbability seems confirmed by the fact that the FPGA only detects something when I actually send DCS data.
Given these facts, does anyone have any idea why the packet would be different ... and more importantly different length for the whistle each time, even though there's only 1 engine, 1 engine number, 1 TIU, 1 Remote and 1 whistle button?
Cheers!
~Adrian
Here is some sample data if anyone want's to play with it:
(TIU RevL / MTH DD40AX 6944 / Engine 69 / Remote V 4.20)
WHISTLE
11111111111111111111011111111111111111111110110011100000000000001000000101111111
11111111111011001110000001111111111111110110001011011111111111111111111111111111
111111111111111111011100000000000001000000101111111111111111111111111111
11111111111111110111000000001000101111111111111111111111111111111111111111111111
11100111111111111111111101100111000000000000010000001011111111111111111111111111
11011100111110000000000000110000001101111111111111111111101101110111111111111111
11111011001110000000000000100000010111
11111111111111101100011010000000000000100000001001101111111111111111001100010101
00000000000000100000001001101111111111111111001100010110000000000000100000010111
11111111111111111011100000000000100000010111111111111111110011100011011010000000
00000010000001011011111111111111111100111000000000000010000000101111111111111111
1111111111111111111111111111111111111
11111111111111101100101100000000000000100000010111111111111111111111111101111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111
111110110011111111111111111111111111111111111111111
11111111111111011001110000000001000010111111111111111111011000101100000000000001
00000001001111111111111111111111111111111111111111111111111111111111110001111111
11111111111110111111111111111111101100111000000000000010000000101111111111111111
111111111111
QUICKSET 1 SMPH
11111111111111111111111111111111111111110000000000000100000000111111111111111111
11111111111111111111111101100100011111100011111111111111111111110111111111111111
11111011001000000000000000010000000111111111111111111111111111
11111111111111111001000000000000000100000000011111111111111111110110010000000000
00000010000000001111111001111111111111111111111111111111111111001000000000000000
01000000000111111111111111111111100000000000100000011111111111111111111110000000
00000000010000000001111111111111111111011001000000000000000010000000001111
11111111111111111010001111111111111111111011001000000000000000010000000000111011
111111111111111111001110111111111111111111101011111111111111111111111
11111111111111101100010000000000011111111111111111111111111111111111111111111101
11111111111111111111110100000001000001111111111111111111111111111111111111111111
1111111111111111111110110100000000000000001000000000011101
11111111111111111010000100111111111111111111101100100000000000000001000000000111
11111111111111111111111111111111111111111100000000000000100000000011111111111111
11111011001000000111111111111111111111111111111111111111111101111111111111111111
1111011001010001111
QUICKSET 2SMPH
10000111110111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111100000001000111111111111111111110011000100000000000000000
010000001111101
11111111111111011001000001111111111111111111111111101111111111111111111111111111
11111000111111111111111111111011001000000000000000001000000111110111111111111111
1111111111
11111111111111111111111111111111111111111111111111111111111111001100010000000000
00000000101111111111111111111101111111111111111111111110111111111111111111111111
011011111111111111111111111101000000000000000100000111111111111
QUICKSET 10 SMPH
11111111111111111000001111111111111111111111111111111111111111111111111111111111
11111111011011111111111111111111111000111111111111111111111101100100000000000000
000110001111111111111111111101100100000000000000000101000111111
11111111111111110010000000000000000010100011111111111111111111111111111111111111
11111111110011111111111111111111111111100000000000000001100011110111111111111111
10011000100000000000000000011011111111111111111111111111111111111111111111111111
111111
11111111111111111111111111111111111111111001000000000000000001100011111111111111
11111111111111111111111111111111111111111111111111111111111111111011001000000110
1111111111111111111111111111111