Avatar for pacogh

pacogh

Member since Sep 2018 • Last active Oct 2018
  • 1 conversations
  • 4 comments

Most recent activity

  • in Puck.js, Pixl.js and MDBT42
    Avatar for pacogh

    Hi Gordon,

    http://microcosm.app/out/zEd6h is full working but it was not simple for me to understand how it manages I2C bus.

    I printed data sent from Espruino to MCP23017 thru function ' p._w = function(r,dArr) { this.i2c.writeTo(0x20,r,dArr); print (r,dArr); return this; }; '

    Comparing it with MCP23017 it was easy to write minimun code to use bank A & B as output.

    Other experiences:

    • I'm using a power Bank using 'alway-on mode' instead of a button battery, so power wasn't the problem as 'allObjects' sujected too.
    • My previous design was running on Arduino, my mistake was transtlate that Arduino code to Espruino. Espruino needs other detailed commands to manage I2C (attached Arduino example)

    Thanks,

  • in Puck.js, Pixl.js and MDBT42
    Avatar for pacogh

    Hi,

    Your post is at http://forum.espruino.com/conversations/­312487/

    Attachment that helped me to clarify how MCP2307 is working is: https://espruino.microcosm.app/api/v1/fi­les/e9474e4809d42cf2aa0a28c9377a4c4987ee­1b72.js
    and MCP2307 datasheet.

    Thanks

  • in Puck.js, Pixl.js and MDBT42
    Avatar for pacogh

    Hi,
    Thanks for your answer, your port expader is a really excellent job for reading a keypad.
    I tested your software and it changes signal output of GPA0, GPA1, GPA2, GPA3 to '1'. !!

    Reading your code, I solved my problem. Attached is a simple example of a '0' & '1' signal serie.

    Thanks a lot!!!!!!!,

    Paco.

  • in Puck.js, Pixl.js and MDBT42
    Avatar for pacogh

    Hi,
    I have connected a port expander MCP23017 to pixl.js using I2c (using D5 for scl : D5 and D4 for sda)
    My target is to use MCP 23017 for reading or writing some signal.

    There are instructions in https://www.espruino.com/MCP23xxx but it doesn't work for reading or writing:
    It doesn't reports error messages, here is the code:

       var i2c = new I2C();
       i2c.setup({ scl : D5, sda: D4 });
       var address = 0x20; //this is the address, set by the address pins.
       // for MCP23017
       var port=require("MCP23017").connect(i2c,nul­l,address);
       port.B0.mode('output');
       port.B0.write(1);      //<--IT MUST CHANGE TO '1' BUT B0 CONTINUE AT '0' LEVEL 
      port.A0.mode('input_pullup');
     console.log(port.A0.read());    //<--ALWAYS READ '1'
    

    I wrote a new code and now is working just for reading signals:

       var i2c = new I2C();
       i2c.setup({ scl : D5, sda: D4 });     
       i2c.writeTo(0x20, 0X12); 
       var x = i2c.readFrom(0x20, 1);  
       i2c.writeTo(0x20, 0X13); 
       var y = i2c.readFrom(0x20, 1);
    

    But for writing , it doesn't work:

       var i2c = new I2C();
       i2c.setup({ scl : D5, sda: D4});
       i2c.writeTo(0x20, 0x00);
       i2c.writeTo(0x20, 0x12);      // program all Bank A to output
       i2c.writeTo(0x20, 0x00);
       i2c.writeTo(0x20, 0x00);
       i2c.writeTo(0x20, 0x12);      // Change all pins of Bank A to '1'
      i2c.writeTo(0x20, 0xFF);
    
    i2c.writeTo(0x20, 0x13);      // program all Bank B to output     
    i2c.writeTo(0x20, 0x00);
    i2c.writeTo(0x20, 0x00);
    i2c.writeTo(0x20, 0x13);      // Change all pins of Bank B to '1'
    i2c.writeTo(0x20, 0xFF); 
    

    Some help, please?
    Thans in advance.

    Paco

Actions