You are reading a single comment by @jakedempsey and its replies. Click here to read the full conversation.
  • I am using the following Maxbotix sensor:

    http://www.maxbotix.com/Ultrasonic_Senso­rs/MB7334.htm

    I have it working where I connect to Serial3 and have a callback attached on the 'data' and I am console logging the returned value from the sensor.

    The problem I have having is I have PIN 4 connected to B10 and PIN 5 connected to B11. Their document has that PIN 4 is internally pulled high so if it will continually ping for a reading. If you pull the pin low it will not and if you pull it high for a short period of time it will take a reading.

    Am I pulling the pin B10 low incorrectly? My goal was to connect via Serial, pull the pin low, then every 60 seconds pull the pin high which would cause it to read data and then after 10 readings it would send off the reading and set the pin back to low. In production the 60 second interval may be something more like 5 or 10 minutes. I wanted it to not be reading, then take 10 measurements every X mins and use that last one then turn it back off.

    I just can't get the LOW/HIGH pin stuff right on B10 for their PIN4. Am I missing something simple?

    var interval = 60000;
    var readingInterval = 10; 
    var fullReading = "";
    var readingCount = 0;
    
    Serial3.setup(9600, { rx: B11, tx: B10, bytesize: 8, parity: false, stopbits: 1 });
    B10.write(false);
    
    var pulseLed = function(){
        digitalPulse(LED1,1, 100);
    };
    
    var handleData = function(data){
        if(data == 'R'){
            console.log("NG:", fullReading);
            ++readingCount;
            pulseLed();
            if(readingCount == readingInterval){
                B10.write(false);
                readingCount = 0;
                console.log("Got final Result:", fullReading);
            }
            fullReading = "";
        } else {
            fullReading = fullReading + data;
        }
    };
    
    Serial3.on('data', handleData);
    
    setInterval(function(){
        console.log("Run Interval");
        B10.write(true);
    }, interval);
    

    From their document:

    Pin 4- Ranging Start/Stop: This pin is internally pulled high. If this pin is left unconnected or held high, the sensor will
    continually measure and output the range data. If held low, the HRXL-MaxSonar-WRS will stop ranging. Bring high for
    20uS or longer to command a range reading.
    Filtered Range Data: When pin 4 is left high on the sensors, the sensors will continue to range. The data that is output
    includes a filter for increased accuracy. The sensors will output the range based on recent range information. The filter
    does not affect the speed at which data is made available to the user but instead allows for more consistent range
    information to be presented. For sensor specific timing and filter information refer to pages # and #.
    Real-time Range Data: When pin 4 is low and then brought high, the sensor will operate in real time and the first reading
    output will be the range measured from this first commanded range reading. When the sensor tracks that the RX pin is low
    after each range reading, and then the RX pin is brought high, unfiltered real time range information can be obtained. For
    timing information please refer to pages # and #.

About

Avatar for jakedempsey @jakedempsey started