Avatar for ClearMemory041063

ClearMemory041063

Member since Apr 2016 • Last active May 2017
  • 43 conversations
  • 305 comments

Retired. Just having fun now.
I'm running an Espruino Board connected to ESP8266 via serial port.

Working on a program derived from the SD card file server example.
When you request a file from the displayed list, it looks at the file extension and modifies the MIME header field.
This causes files with the extension .HTML to load the Web page.
Files with the extension .js allow an .HTML file to include scripts.
Files with the extension .csv cause Excel to load the file into a spreadsheet, which can be saved on your hard drive.

I'm having problems with another part that accepts POSTs from a client.

Most recent activity

  • in Projects
    Avatar for ClearMemory041063

    You can identify an interval by naming it
    and use the name to clear only that interval

    var id = setInterval(function () { print('foo'); }, 1000);
    
    clearInterval(id)
    

    espruino.com/Reference#l__gl­obal_setInterval

    espruino.com/Reference#l__gl­obal_clearInterval

  • in Interfacing
    Avatar for ClearMemory041063

    Thanks for the input @allObjects
    Your expertise in JavaScript is greatly appreciated.
    As with all projects and programming each author brings to the task a collection of familiarity with subjects and blind spots to other subjects. As a project develops new knowledge is revealed as ignorance retreats.
    So your input has led me to search for more information on modules.
    The CommonJS paradigm expressed in the following link seems to fit the pattern you are proposing for the Rodrigues.js module.
    medium.freecodecamp.com/javascri­pt-modules-a-beginner-s-guide-783f7d7a5f­cc
    So far I haven’t found a reference (other than Espruino) to the methods used for hardware module using the Connect method.
    That which I knew of JavaScript was obtained from using it in HTML and using Espruino. The opposite problem seems to show up in this @trusktr
    question.
    http://forum.espruino.com/conversations/­305040/

  • in Interfacing
    Avatar for ClearMemory041063
    Correction to AGMagtest1

    The index values were corrected in the displayAg() function when set to display Accelerometer and Magnetometer values. AGMagtest2.js is attached.

    Adding the Rodrigues.js module to level the compass

    The background for this module is described here:
    http://forum.espruino.com/conversations/­298151/

    The basic idea is to take the accelerometer readings and determine the vector transformation needed to level the compass. This is done with the function A=FF.Setup(AA,[0,0,1]); where FF is an instance of Rodrigues. The tilt angle theta is then available and subsequent calls to the function BB=FF.RotVector(t) will transform other vectors (magnetometer) into level coordinates.
    The attached Rodrigues.js should be placed in the modules subdirectory of your WebIDE project.
    The attached program AGMagCompass1.js will then produce the following output when autocalc=2 and W.AGwrite(W.REGval.ODR_G,1);//do gyro and acceleration.

    M,0.0744,-0.1211,-0.1714,G,-0.1053,0.041­3,-0.0948,A,0.1575,0.3104,0.8621,
    Tilt,21.98781027298,Heading,306.68106708­380,Dip,72.16684715533
    M,0.0735,-0.1221,-0.1734,G,-0.1128,0.056­3,-0.1072,A,0.1559,0.3118,0.8613,
    Tilt,22.03654082060,Heading,306.02287887­278,Dip,72.48561573888
    M,0.0730,-0.1207,-0.1713,G,-0.1165,0.025­1,-0.0998,A,0.1551,0.3114,0.8618,
    Tilt,21.98386692289,Heading,306.35699288­042,Dip,72.36622200953
    M,0.0742,-0.1194,-0.1707,G,-0.0928,0.071­2,-0.0823,A,0.1538,0.3145,0.8604,
    Tilt,22.14296350951,Heading,308.33309975­404,Dip,72.42224117781
    M,0.0736,-0.1171,-0.1704,G,-0.0679,0.031­3,-0.0674,A,0.1558,0.3134,0.8606,
    Tilt,22.13447453002,Heading,308.75984729­535,Dip,72.83761339423
    >clearInterval();
    

    Changing W.AGwrite(W.REGval.ODR_G,0);//do acceleration only produces the following output:

    M,0.0747,-0.1202,-0.1713,A,0.1563,0.3096­,0.8569,
    Tilt,22.03355580117,Heading,307.43511787­449,Dip,72.28617992890
    M,0.0763,-0.1235,-0.1719,A,0.1563,0.3094­,0.8568,
    Tilt,22.02918941321,Heading,306.91511852­880,Dip,71.66990038608
    M,0.0741,-0.1204,-0.1721,A,0.1560,0.3093­,0.8569,
    Tilt,22.01028842165,Heading,306.98156662­314,Dip,72.44988041050
    M,0.0780,-0.1226,-0.1704,A,0.1559,0.3090­,0.8568,
    Tilt,22.00089649394,Heading,308.38042963­598,Dip,71.31936469986
    >clearInterval();
    

    ```

  • in Interfacing
    Avatar for ClearMemory041063

    Now that's an interesting idea. The flywheel shaft is 10mm long with a crank on each end, so there's not much room for the Puck. Perhaps a photo interrupter with a tab on the flywheel would be easier for RPM sensing.
    The LTD (Low Temperature Differential) Stirling is right up against the wall to work using hot coffee and small design changes can move the needed temperature differential.
    One idea to pursue is a pressure sensor tapped into the displacer chamber. This would allow one to study the differences in displacer designs such as size, materials and motion of the displacer.

  • in Interfacing
    Avatar for ClearMemory041063

    AGmagtest1.js

    The attached program AGmagtest.js uses the LSM9DS1.js module and the preceding calibrations to produce data in engineering units.

    The variable autocalc controls the type of units displayed.

    //autocalc 0=raw, 1=raw-offset, 2 Engineering Units
    var autocalc=2;

    In the function setupAG() the gyro ODR determines if gyro data are available.

    W.AGwrite(W.REGval.ODR_G,1);//do gyro and acceleration
    //W.AGwrite(W.REGval.ODR_G,0);//do acceleration only.

    Here is sample output with autocalc=2 and ODR_G=1

    M magnetometer values are in Gauss,
    G gyroscope values are in degrees per second
    A acceleration values are in g, (1= Earth gravity)

    M,0.0150,-0.0847,-0.1949,G,0.3582,-0.105­7,-0.1222,A,0.0839,-0.0478,0.9993,
    M,0.0172,-0.0830,-0.1933,G,0.3358,-0.158­1,-0.1297,A,0.0869,-0.0552,1.0039,
    M,0.0172,-0.0830,-0.1933,G,0.3433,-0.165­5,-0.1297,A,0.0841,-0.0479,1.0000,
    M,0.0172,-0.0830,-0.1933,G,0.3807,-0.105­7,-0.1222,A,0.0831,-0.0438,0.9987,
    M,0.0151,-0.0866,-0.1965,G,0.4031,-0.210­4,-0.1222,A,0.0817,-0.0398,0.9956,
    M,0.0151,-0.0866,-0.1965,G,0.3807,-0.083­3,-0.1222,A,0.0821,-0.0416,0.9960,
    M,0.0151,-0.0866,-0.1965,G,0.4031,-0.187­9,-0.1147,A,0.0831,-0.0460,0.9991,
    M,0.0162,-0.0845,-0.1933,G,0.3732,-0.098­2,-0.1446,A,0.0822,-0.0459,1.0009,
    M,0.0162,-0.0845,-0.1933,G,0.3059,-0.113­2,-0.1297,A,0.0834,-0.0461,1.0031,
    >clearInterval();
    
    Changing ODR_G to 0 produces:
    M,0.0154,-0.0826,-0.1849,A,0.0864,-0.051­6,1.0014,
    M,0.0154,-0.0826,-0.1849,A,0.0868,-0.053­7,1.0017,
    M,0.0154,-0.0826,-0.1849,A,0.0858,-0.054­9,1.0009,
    M,0.0154,-0.0826,-0.1849,A,0.0862,-0.056­7,1.0032,
    M,0.0154,-0.0826,-0.1849,A,0.0861,-0.059­4,1.0028,
    M,0.0154,-0.0826,-0.1849,A,0.0852,-0.059­8,1.0009,
    M,0.0154,-0.0826,-0.1849,A,0.0883,-0.060­1,0.9992,
    M,0.0154,-0.0826,-0.1849,A,0.0877,-0.057­4,0.9964,
    >clearInterval();
    
  • in Interfacing
    Avatar for ClearMemory041063
    MPU6050 Try this code
    function start(){
    I2C1.setup({scl:B6,sda:B7});
    var mpu = require("MPU6050").connect(I2C1);
    
    setInterval(() => {
      console.log(
        '\nAcceleration:', mpu.getAcceleration(), // returns an [x,y,z] array with raw accl. data
        '\nGravity:', mpu.getGravity(),  // returns acceleration array in G's
        '\nRotation:', mpu.getRotation(), // returns an [x,y,z] array with raw gyro data
        '\nDegress per second:', mpu.getDegreesPerSecond() // returns gyro array in degrees/s
      );
    }, 1000);
    
    }//end start
    
    //Wait for program to load
    setTimeout(function () {
     start();
    }, 1000);
    

    Without an MPU6050 connected to the PICO I get the following:

    1v92 Copyright 2016 G.Williams
    >
    =undefined
    Uncaught InternalError: Timeout on I2C Write Transmit Mode 2
     at line 1 col 29
    this.i2c.writeTo(this.addr,a);return this.i2c.readFrom(this....
                                ^
    in function "readBytes" called from line 1 col 25
    var g=this.readBytes(a,1)[0],h=(1<<b)-1<<c-b­+1,g=g&~h|d<<c-b...
                            ^
    in function "writeBits" called from line 2 col 41
    d.PWR1_CLKSEL_BIT,d.PWR1_CLKSEL_LENGTH,a­)
                                            ^
    in function "setClockSource" called from line 1 col 38
    ...ockSource(d.CLOCK_PLL_XGYRO);this.set­FullScaleAccelRange(d.A...
                                  ^
    in function "initialize" called from line 1 col 103
    ...AD0_HIGH:c;this.initialize()
                                  ^
    in function "b" called from line 1 col 10
    new b(a,c)
             ^
    in function "connect" called from line 3 col 42
    var mpu = require("MPU6050").connect(I2C1);
                                             ^
    in function "start" called from line 1 col 7
    start();
          ^
    in fun
    

    Please try it with your chip connected.
    As for the connections, I use similar prototype connections for testing. For long term reliability soldered connections are the best. Loose connections cause headaches.

  • in Interfacing
    Avatar for ClearMemory041063

    No experience with the MPU6050 module here.
    Here are some I2C suggestions to try:

    Pullup resistors on the scl and sda lines are one thing to check.
    Does your MPU6050 breakout board provide these?
    Are the jumpers on the breakout board used to engage the pullup resistors?

    var MPU6050 = require("MPU6050");
    You might try
    var MM= require("MPU6050"); (and subsequent references to MPU6050 in your code)
    as the MPU6050 may already used by the module.

     I2C3.setup({ scl :A8, sda: B4} );
    //console.log(I2C3);
     var xgAddress= 0x6B;// Would be 0x1C if SDO_M is LOW
     var mAddress= 0x1e;// Would be 0x6A if SDO_AG is LOW 
     W=require("LSM9DS1").connect(I2C3,xgAddr­ess,mAddress);
    // W=new LSM9DS1(I2C3,xgAddress,mAddress);
     W.run();//Get it started
    

    For PICO
    //I2C1 sda=B7 scl=B6
    //I2C1 sda=B9 scl=B8 shim pins
    //I2C3 sda=B4 scl=A8
    //I2C2 sda=B3 scl=B10

  • in Interfacing
    Avatar for ClearMemory041063

    The Accelerometer and Gyroscope Calibrations

    Accelerometer May12 2017 2g scale using average R

    Culled Range = 2230.842

    Offset A B C
    X -987.2736361 0.995549457 0.140149893 2.11449E-05
    Y 272.0992136 -0.042589517 0.991729217 0.00020329
    Z 446.896968 -0.24363696 -0.291923385 1
    Accelerometer May12 2017 2g scale using target value

    Culled Range = 2159.087

    Offset A B C
    X -1068.093899 0.981090704 0.127644011 4.11128E-05
    Y 185.8088179 -0.013882693 0.989541404 3.62454E-05
    Z 193.6596862 -0.268744893 -0.20999626 1
    Gyroscope May12 2017 245deg per s.

    Offsets Only as I’m not set up to spin the sensor and collect data.
    Culled Range = 2506.073

    Offset A B C
    X -780.9157638 1 0 0
    Y 214.1401801 0 1 0
    Z -0.657364084 0 0 1

    See attached files

Actions