You are reading a single comment by @DrAzzy and its replies. Click here to read the full conversation.
  • Right now, the times reported for things in events are... uh.... wrong.

    On an Arduino, clocked off a crystal, I can constrain the 1 and 0 lengths like so:

    
    // Version 2.1
    int rxSyncMin = 1900; //minimum valid sync length
    int  rxSyncMax = 2100; //maximum valid sync length
    int  rxZeroMin = 120; //minimum length for a valid 0
    int  rxZeroMax = 400; //maximum length for a valid 0
    int  rxOneMin = 450; //minimum length for a valid 1
    int  rxOneMax = 750; //maximum length for a valid 1
    int  rxLowMax = 600; //longest low before packet discarded
    
    int  txOneLength = 550; //length of a 1
    int  txZeroLength = 300; //length of a 0
    int txLowTime = 420; //length of the gap between bits
    int txTrainRep = 30; //number of pulses in training burst
    int txSyncTime = 2000; //length of sync
    int txTrainLen = 200; //length of each pulse in training burst
    
    

    The Arduino receiver happily takes the transmission and yields the correct result. With no interrupts or hardware timing more advanced than micros():

    +1FE10001

    Now, let's look at what lengths we get for those under Espruino:

    >setTimeout("stopListen()",10000);startListen();
    Listening started
    =undefined
    0.00003242492
    0.00004386901
    0.00006008148
    0.00008010864
    0.00002765655
    0.00003337860
    0.00003993511
    0.00002574920
    0.00002098083
    0.00007808208
    0.00006484985
    0.00005233287
    0.00005054473
    0.00001811981
    0.00001907348
    0.00002002716
    0.00005042552
    0.00004482269
    0.00004482269
    0.00001525878
    0.00013065338
    0.00010776519
    0.00004208087
    0.00002861022
    0.00008201599
    0.00005435943
    0.00035572052
    0.00033950805
    0.00032424926
    0.00031471252
    0.00030422210
    0.00030517578
    0.00029563903
    0.00029087066
    0.00028038024
    0.00026702880
    0.00028228759
    0.00026607513
    0.00026607513
    0.00025939941
    0.00025558471
    0.00026226043
    0.00024318695
    0.00024127960
    0.00023365020
    0.00022792816
    0.00022411346
    0.00022411346
    0.00022220611
    0.00022125244
    0.00021743774
    0.00021457672
    0.00021076202
    0.00020217895
    0.00019359588
    0.00018119812
    0.00029850006
    0.00026321411
    parserx
    listening stopped
    11111110000000000000000000000010
    bad csc
    Expected 1 got 2
    Listening started
    0.00022888183
    0.00027191638
    0.00002479553
    0.00004196166
    0.00016307830
    0.00016307830
    0.00012493133
    0.00013923645
    0.00019264221
    0.00035572052
    0.00035750865
    0.00034701824
    0.00033652782
    0.00035667419
    0.00037956237
    0.00038337707
    0.00013637542
    0.00013637542
    0.00014209747
    0.00014209747
    0.00039577484
    0.00015640258
    0.00015735626
    0.00014400482
    0.00015830993
    0.00016498565
    0.00015449523
    0.00015735626
    0.00042057037
    0.00014889240
    0.00016403198
    0.00016498565
    0.00040256977
    0.00017833709
    0.00015735626
    0.00016307830
    parserx
    listening stopped
    00000111111100001000000010001000
    good csc
    
    

    Note how the numbers are all WAY LOWER than they should be. Those decoding results are after I lowered the threshold for 0 vs 1 down to 0.000295, in an attempt to get everything out of the 0 range, and widened the threshold for accepting, ie:

    function sigOff(e) {
    	var d=e.time-e.lastTime;
      console.log(d);
      if (d>0.00012 && d<0.00075) {n+=d>0.000295?1:0;}
      else {n="";}
    	if (n.length==z) parseRx(n);
    }
    
    

    This is with analog squelching, by the way - it works splendidly. I can still receive without it - and it doesn't change the fact that the times are all over the place and consistently way under what they should be.

About

Avatar for DrAzzy @DrAzzy started