Avatar for RFPlus

RFPlus

Member since May 2014 • Last active May 2014
  • 0 conversations
  • 3 comments

Most recent activity

  • in Interfacing
    Avatar for RFPlus

    I think I've understood the problem ... it's a speed/timing issue. Maybe my LCDs are running a little slow, certainly the processor at 168MHz is fast. I started getting a response from the LCD when I built a small init routine in the IDE.

    After some playing I moved the HD44780.js module into the IDE right-hand pane and it worked(!) essentially unmodified. However, after a save() and restart, the display corrupted. I think it's because the timing on the write() routine is too quick for the LCD interface when it's minified. I changed the digitalWrite() to digitalPulse() on the 'en' line and it now works fairly reliably, even standalone after a save().

    It's a hack ... that it works at all is probably coincidental. There's work to be done on ensuring the timing constraints on the HD44780 are always met, regardless of processor speed.

    var exports={};
    function HD44780J(write) {
      // initialise
      write(0x33,1);
      write(0x32,1);
      write(0x28,1);
      write(0x0C,1);
      write(0x06,1);
      write(0x01,1);
      // add functions
      return {
        write : write,
        // clear screen
        clear : function() { write(0x01,1); },
        // print text
        print : function(str) {
          for (var i=0;i<str.length;i++)
            write(str.charCodeAt(i));
        },
        // set cursor pos, top left = 0,0
        setCursor : function(x,y) { var l=[0x00,0x40,0x14,0x54];write(0x80|(l[y]+x),1); }
      };
    }
    
    
    exports.connect = function(_rs,_en,_d4,_d5,_d6,_d7)  {
      var data = [_d7,_d6,_d5,_d4];
      var rs = _rs;
      var en = _en;
      digitalWrite(rs, 1);
      digitalWrite([rs,en], 0);
      var write = function(x, c) 
        {
        digitalWrite(rs, !c);
        digitalWrite(data, x>>4);
    //    digitalWrite(en, 1);     Original pulse
    //    digitalWrite(en, 0);
        digitalPulse(en,1,1);    // 1ms timed pulse
        digitalPulse(en,1,0);    // wait for pulse end
        digitalWrite(data, x);
    //    digitalWrite(en, 1);       Original  pulse
    //    digitalWrite(en, 0);
        digitalPulse(en,1,1);     // 1ms timed pulse
        digitalPulse(en,1,0);    // wait for pulse end
        };
      return new HD44780J(write);
      };
    
    var lcd;
    var sensor;
    
    setInterval(function()  {
      //lcd.clear();
      lcd.setCursor(7,1);
      lcd.print(" "+sensor.getTemp());
      }, 1000);
    
    function onInit()  {
      // Set up display and sensor
      lcd = exports.connect(A3,A1,C0,C1,C2,C3);
      lcd.clear();
      lcd.setCursor(1,1);
      lcd.print("Temp =");
      lcd.setCursor(14,1);
      lcd.print("C");
      lcd.setCursor(0,0);
      lcd.print("* RFPlus  2014 *");
        
      var ow = new OneWire(A2);
      sensor = require("DS18B20").connect(ow);
      sensor.setRes(10);  // 10 bit mode
      }
    
    
    onInit();
    
  • in Interfacing
    Avatar for RFPlus

    Thanks, Gordon ... I'll try to track it down. I've tried another display and rewired. Tested each path end-to-end with a conductivity tester. Pulsed all pins using digitalWrite() and these appear on the LCD connector, according to my trusty HP545A probe. No shorts between pins, RW grounded. So electrically it appears sound. Now I'd like to understand which code is being called. There seem to be several functions in code/lcd.js .. is there any documentation on how/what is called? And could I try driving the display directly, using digitalWrite() for example, to troubleshoot this? ... Cheers, Jon

  • in Interfacing
    Avatar for RFPlus

    Hi Gordon, Dan ... Encountering exact same symptoms here, STM32F4Discovery board, (A0,A1,C0,C1,C2,C3 wiring) ... including the 'ever so slight' dimming on running the code. A DS18B20 on A2 runs perfectly. Have double-checked wiring, tried 1.62 and 1.63 . Changed 'rs' from A0 to A3 in case it was a button conflict, but no joy. Just a single bar of blank chars ... Any ideas?
    Cheers, Jon

Actions