You are reading a single comment by @d0773d and its replies. Click here to read the full conversation.
  • Following the thread of thought I read from your code is that after each command you have to wait a certain time until you can issue the next command or continue with the calculation. For example:

    A) for a calibrate-clear command you send "Cal,Clear" and then you have to wait 300 [ms] before you can continue. Is that correct? If so, what is the command that has to follow this calibrate-clear command? ...or what is the process/calculation/function that would follow this or any of these commands?

    May be you describe me in simple use case(s) what the system will do. To be of more concrete help, I read up on all your posts to get an overall understanding. What I understand so far is that you have the following system and process: The system[Sys] reads[read] temperatures[temp] with temperature sensors[Tempsensor], ph values[ph] with ph sensors, etc. The readings[tmp,ph,etc.] are then somehow displayed, transmitted, or made available otherwise for user or other system consummation. Reading and follow up processing are repeated based on some kind of schedule.

  • @allObjects I appologize for not explaining myself.

    For example I execute:

    I2C1.writeTo(0x63, "R,25.3");
    

    That tells the ph sensor to calculate the ph at the temp 25.3C. The ph sensor will take 1 second to calculate the ph, therefor, I will be required to wait 1 second before executing:

    I2C1.readFrom(0x63, 7);
    

    So depending on the specific command that i invoke will be require to wait what ever the wait value is before I readFrom the sensor. I hope I did a better job at explaining...

    When you said:

    What I understand so far is that you have the following system and
    process: The system[Sys] reads[read] temperatures[temp] with
    temperature sensors[Tempsensor], ph values[ph] with ph sensors, etc.
    The readings[tmp,ph,etc.] are then somehow displayed, transmitted, or
    made available otherwise for user or other system consummation.
    Reading and follow up processing are repeated based on some kind of
    schedule.

    Yes, I am gathering all the sensor data and will eventually send all the calculations to my Intel Edison using UART communication; also out put all the values to 4x 4digit 7-segment displays.

    Maybe a better example? :

    Sensor.prototype = {
      constructor: Sensor,
      getSensorType:function () {
        return this.type; //Get Sensor type
      },
      getSensorAddress:function () {
        return this.address; //Get Sensor address
      },
      getSensorReading:function() {
        a = this.getSensorAddress;
        d = I2C1.readFrom(a, 7);
        return d;
      },
      getSensorResult:function () {
        var a = this.getSensorAddress;
        var c = this.cmdTable.Reading.R.cmd;
        var w = this.cmdTable.Reading.R.wait;
        var that = this;
        I2C1.writeTo(a, c);
        setTimeout(function (e) { that.getSensorReading(); }, w);
      },
      storeSensorResult:function () {
    
      },
      updateResTemp:function (temp) {
        console.log("Before: " + this.cmdTable.Reading.R.cmd);
        this.cmdTable.Reading.R.cmd = "R," + temp;
        console.log("After: " + this.cmdTable.Reading.R.cmd);
      }
    };
    
    var ph = new Sensor("ph", 0x63);
    
    ph.updateResTemp(90.5);
    ph.getSensorResult();
    

    That last example doesn't exactly work. I receive the error:

    Uncaught Error: Function "getSensorReading" not found!
     at line 1 col 8
    { this.getSensorReading(); }
            ^
    in function called from system
    

    How do I call getSensorReading() function from Sensor.prototype?
    I updated my code to my working code.

About

Avatar for d0773d @d0773d started