Avatar for Thijsmans

Thijsmans

Member since Apr 2018 • Last active May 2019
  • 3 conversations
  • 12 comments

See my dutch (mostly) Espruino blog @ https://thijsmans.tweakblogs.net/, or translate it using Google!

Most recent activity

  • in ESP8266
    Avatar for Thijsmans

    Benchmarked and... well done MaBe :)

    A full report can be found @ my Tweakblog, which is dutch but translate pretty accurate using Google.

  • in ESP8266
    Avatar for Thijsmans

    Would love to test, but I can't compile it myself because of a lack of skills ;-)

  • in ESP8266
    Avatar for Thijsmans

    @allObjects Thanks for the intel on possible future enhancements ;) I doubt though if setting a static IP on the AP-side will speed up things. It doesn't change the DHCP-negotiation as such, as far as I know, but just returns the same IP all of the time.

    Thanks @MaBe, I'll look into it! Unfortunately, my AP automatically jumps channels, depending on other network signals. So using a particular channel won't work. The BSSID sounds promising though (or would this only help in a situation with multiple AP's sharing one SSID?).

  • in ESP8266
    Avatar for Thijsmans

    So I found this threat where wifi.setIP() was implemented to set a static IP for an ESP8266. These docs mention "You must be connected to an access point to be able to call this successfully". I thought I misinterpreted it, because: why setting a static IP once connected? Turns out the documentation is right: calling wifi.setIP() before connecting to wifi, does nothing. Calling it once connected actually changes the IP-address.

    I want to get rid of DHCP in the first place. I'm building a battery-fed deep sleep project. DHCP is terribly slow and takes around 4 seconds (which is 40% of the total time needed for measuring and transmitting the results).

    Any thoughts on this?

  • in Projects
    Avatar for Thijsmans

    I got past the 8-bits vs 16-bits issue and I was just listening to my first song on the si4703; Phil Collings I believe...

    
        /*
            si4703 begins reading from register upper register of 0x0A and reads 
            to 0x0F, then loops to 0x00. Since register 0x0A comes in first 
            we have to shuffle the array around a bit.
        */
    
        si4703.prototype.readReg = function ( verb ) {
            //this.i2c.writeTo( this.addr, 0 );
            data = this.i2c.readFrom( this.addr, 32 );
    
            for( var i=0; i<data.length; i+=2 )
            {
                bits = data [ i ] << 8;
                bits |= data[ i+1 ];
    
                reg = ( i < 12 ? i+(10-i/2) : (i/2)-6 );
                this.registers[reg] = bits;
            }
    
            if( verb !== false )
                this.printReg();
        };
    
        /*
            Write the current 9 control registers (0x02 to 0x07) to the Si4703. 
            It's a little weird, you don't write an I2C addres, The Si4703 assumes 
            you are writing to 0x02 first, then increments.
        */
        si4703.prototype.writeReg = function () {
            bytes = [];
            for( i=0x02; i<0x08; i++ )
            {
                var high = this.registers[ i ] >> 8;
                var low  = this.registers[ i ] & 0x00FF;
                bytes.push(high, low);
            }
            this.i2c.writeTo( this.addr, bytes );
        };
    
        si4703.prototype.printReg = function () {
            console.log( 'Register    | Dec     | Hex    | Bits');
            fill   = String('.');
    
            for( var i in this.r )
            {
                label = i;
                dec = this.registers[ this.r[i] ];
                hex = dec.toString(16);
                bits = dec.toString(2);
    
                console.log( label + fill.repeat(10-label.length )      + '  | ' +
                             dec   + fill.repeat(6-String(dec).length)  + '  | ' +
                             hex   + fill.repeat(5-hex.length)          + '  | ' + 
                             fill.repeat(18-bits.length) + bits
                    );
            }
            console.log(" ");
        };
    

    This is working just fine:

    Register    | Dec     | Hex    | Bits
    DEVIDEID..  | 4674..  | 1242.  | .....1001001000010
    CHIPID....  | 2640..  | a50..  | ......101001010000
    POWERCFG..  | 50433.  | c501.  | ..1100010100000001
    CHANNEL...  | 0.....  | 0....  | .................0
    SYSCONFIG1  | 6144..  | 1800.  | .....1100000000000
    SYSCONFIG2  | 21....  | 15...  | .............10101
    SYSCONFIG3  | 0.....  | 0....  | .................0
    TEST1.....  | 48132.  | bc04.  | ..1011110000000100
    TEST2.....  | 6.....  | 6....  | ...............110
    BOOTCONFIG  | 1.....  | 1....  | .................1
    STATUSRSSI  | 28693.  | 7015.  | ...111000000010101
    READCHAN..  | 205...  | cd...  | ..........11001101
    RDSA......  | 255...  | ff...  | ..........11111111
    RDSB......  | 0.....  | 0....  | .................0
    RDSC......  | 0.....  | 0....  | .................0
    RDSD......  | 0.....  | 0....  | .................0
    

    So now onwards to an Espruino-port of the Arduino sketch!

  • in Projects
    Avatar for Thijsmans

    @allObjects: Perhaps I should have mentioned that I left the volume control out for the moment, since there is no sound to control yet :)

    @Gordon: you make some excellent points on 8 vs 16-bits. I'll have a look at DataView, and some YouTube tutorials on bitwise operators ;-)

  • in Projects
    Avatar for Thijsmans

    Okay, I've been breaking my head over this. There is a datasheet and an extensive programming guide available, but both assume you are able to interface with the si4703 :/

    I'm using the Arduino-sketch as a guide line:

        function si4703 ( option ) {
            this.addr  = 0x10;
            this.reset_pin = option.res;
            this.data_pin  = option.dat;
            this.clock_pin = option.clk;
            this.sen_pin   = option.sen;
            this.registers = new Uint16Array(16);
        }
    
        si4703.prototype.init = function () {
            pinMode(this.reset_pin, 'output');
            digitalWrite( this.reset_pin, false );
    
            pinMode(this.data_pin, 'output');
            digitalWrite( this.data_pin, false );
    
            digitalWrite( this.reset_pin, true );
    
            this.i2c = I2C1;
            this.i2c.setup( { scl: this.clock_pin, sda: this.data_pin } );
    
            this.readReg();
    
            this.registers[ 0x02 ] = 0x4001; // enable IC
            this.registers[ 0x07 ] = 0x8100; // enable oscillator
    
            this.writeReg();
    
            this.readReg();
        };
    
        si4703.prototype.readReg = function () {
            this.i2c.writeTo( this.addr, 0 );
            data = this.i2c.readFrom( this.addr, 32 );
    
            for( var x=0x0A; ; x++ )
            {
                if( x == 0x10 ) x=0;
                this.registers[x] = data[x] << 8;
                this.registers[x] |= data[x];
                if( x == 0x09 ) break;
            }
    
            console.log( this.registers );
        };
    
        si4703.prototype.writeReg = function () {
            for( var i in this.registers )
            {
                if( i > 0x02 )
                    this.i2c.writeTo( this.addr, i, this.registers[i] );
            }
        };
    

    So,the init-method should read the registers, update a few things (mainly the ENABLE-bit), and read the registers again. However, there is no change in the actual registers (first line is the output at startup, second line is after attempting to write the new values):

    new Uint16Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4626, 16962, 2056, 0])
    new Uint16Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4626, 16962, 2056, 0])
    

    What am I missing?

  • in Projects
    Avatar for Thijsmans

    Yes I'm aware of that. I thought the datasheet stated an input rise and fall time of 10ms. That's why I chose the digitalPulse anyway - creating a cueue would be too much of a hassle. However, reading the datasheet again, I see it says 10 ns :) I guess a double-digitalWrite should be fine.

    I guess the first step for interfacing with the si4703 is getting the registers out one by one, using the subaddress-examples found here. I'll let you know when I get lost...

Actions