Avatar for user49360

user49360

Member since Oct 2014 • Last active Feb 2015
  • 2 conversations
  • 7 comments

Most recent activity

  • in General
    Avatar for user49360

    Yeah, that's the case then. If the serial buffer misses 1 bit of data, the whole string is shifted, so you get random characters.

    The difference between 50 and 150ms is pretty big to be a minor change though, but it's no big deal to implement.

    Thanks again :)

  • in General
    Avatar for user49360

    Hi again guys, sorry for the late reply, I've been pretty busy last week, so I didn't have time to reply.

    I tried Gordon's build, which worked for me. I've moved to pins A9 and A10 now. Communication is stable with this build.

    Then I tried Drazzy's bigram build, version "espruino_1v72_12-17_espruino_1r3_bigram­", which also worked, but only after I changed the timings a bit.

    So instead of reading the buffer after 50ms, I had to do it after 150ms, or else it seemed the buffer wasn't "ready" yet (I would get random characters or only part of the reply string).

    The program is stable with this timing, so my problem is solved, but maybe you guys know what could have caused the timing difference. Just letting you know :)

    Thanks for the help and suggestions!

  • in General
    Avatar for user49360

    Ok, thanks for the reply! Any other thoughts as to what it could be? It only happens when I use a bigram build, I tried most of the new builds and several old ones now.

    Thanks again in advance :)

  • in General
    Avatar for user49360

    Hi all,

    I'm working on a project involving communication via RS485. I use a MAX485 board to convert it all and it works fine up to a certain point.

    A while ago, I installed one of @DrAzzy 's builds to get more RAM, since we needed that in the project. The thing is, since the new firmware install, the serial communication seems to have stopped working.

    The code below works on the newest 'normal' firmware, but somehow the value of reply is still 0 when we run the code on one of Drazzy's builds.

    digitalWrite(B8, 0);
    Serial1.setup(9600, {tx:B6,rx:B7,bytesize:8,parity:'none',st­opbits:1});
    var reply = 0;
    
    function sSend(command){
      reply = 0;
      print("Command: "+command);
      digitalWrite(B8, 1); 
      setTimeout(function(){Serial1.print(comm­and);}, 5);
      setTimeout(function(){digitalWrite(B8, 0);}, command.length/0.96+6.53);
      setTimeout(function(){
        reply = Serial1.read();
        print("Reply: "+reply);
        if(reply === ""){
          setTimeout(function(){sSend(command);},1­000);
        }
      }, 50);
    }
    
    

    sSend("@01EO=1\r") is the command we send to turn on the power for one of our connected devices and it should return "#01OK". If there is no reply (when the supply power is turned off for example), Serial1.read() should return "".
    However, I noticed that when I run the code under Drazzy's firmware, Serial1.read() indeed returns "", but the actual value of reply is still 0, so sSend isn't called for a second time. It seems as if the code just stops there.

    I have a feeling it either has to do something with timing (although I tried a lot of different timings supported by my oscilloscope), or with the firmware not working well with Serial1.

    Any thoughts and advices are welcome :)

  • in General
    Avatar for user49360

    @Gordon

    If the IDE runs on chrome, maybe you could try to use localStorage. You could JSON.stringify the code and save it on the storage and when you open the IDE, all that has to be done is JSON.parse.

    No clue if it works like that in the IDE, but with browsers it works perfectly :)

    • 3 comments
    • 2,292 views
  • in JavaScript
    Avatar for user49360

    Hi Gordon,

    the first option seems to have done it, thanks! I had to add 7 ms to the timeout to get it to work though. It seems to work with all the strings I try to send.

    Thanks a lot for the quick reply!

    Eric

  • in JavaScript
    Avatar for user49360

    Hello,

    I'm working on a project involving driving stepper motors via RS485.
    I've found a nice converter board:

    http://arduino-info.wikispaces.com/Softw­areSerialRS485Example

    I converted this example to JavaScript and I got it working.

    digitalWrite(B8, 0);
    Serial1.setup(9600, {tx:B6,rx:B7,bytesize:8,parity:'none',st­opbits:1});
    Serial1.on('data', function (data) { print("<Serial1> "+data); });
    
    digitalWrite(B8, 1); digitalWrite(LED2, 1);
    setTimeout(function() {Serial1.print("@01STOP\r");}, 5);
    setTimeout(function() {digitalWrite(B8, 0);}, 15);
    
    

    The only problem is that the stepper motors have encoders, which will reply (very fast) when I send a serial command. This means I have to make my driver enable output LOW as fast as possible after sending my command.

    Timeouts may work, but the timings vary, as different commands require more or less time to print.
    Does anyone have any idea how to make sure the driver enable pin goes to LOW as soon as the Espruino is done sending?

    Sorry if my English is not that good, but I hope you guys can understand my question :)

    Thanks in advance,

    Eric

Actions