What is the ASCII code an ultrasonic sensor will output?

In summary, the problem statement is about determining the ASCII code for a certain distance (0.15 meters or 0.5 feet) from an ultrasonic sensor (MB7380) with 8 data bits, no parity, and one stop bit. The datasheet for the sensor provides that the output is an ASCII capital "R" followed by four ASCII character digits representing the range in millimeters. However, there was initial confusion about the conversion process, but with the help of other forums and careful reading of the datasheet, a solution was achieved. The code provided shows how the output can be emulated using an Arduino program.
  • #1
adamaero
109
1
Problem statement
For an ultrasonic sensor (MB7380) sending 8 data BITS, no parity and one stop bit, what is the ASCII code it will give for a certain distance like 0.15 meters (0.5')?


Attempt at a solution
  • I do not know how to convert 0.15 meters into 8 bits. It is using TTL serial output. I believe this model is the 5' version.
  • I'm thinking I need to borrow a scope from my uni.
  • ASCII Encoder/ Decoder (tool)
 
Physics news on Phys.org
  • #2
I seriously doubt that the output is in ASCII. It is probably an 8 bit representation of some dustance unit of measure.
 
  • Like
Likes phinds
  • #3
FactChecker said:
I seriously doubt that the output is in ASCII. It is probably an 8 bit representation of some dustance unit of measure.
Yep. @adamaero you really need to look at the spec sheet for the device.

Also, you clearly don't understand what "ASCII code" means or you would not have asked the question, so you might want to study up on that as well if you are interested in computer communication.
 
  • #4
"The output is an ASCII capital “R”, followed by four ASCII character digits representing the range in millimeters." Talk about reading the datasheet!

I had trouble interpreting how to convert that. For example, I did not know that "\r" would be 13 in ASCII. (I would've taken both characters separately.) But I was actually helped on a different forum. Thanks, but no thanks.
 
  • #5
adamaero said:
"The output is an ASCII capital “R”, followed by four ASCII character digits representing the range in millimeters." Talk about reading the datasheet!
Would have been nice if you had said so in the first place. The clear implication of your question was that it was a binary 8-bit output as FactChecker suggested.

But you are correct about the spec sheet. You linked to it and I didn't look at that link. My bad.
 
Last edited:
  • Like
Likes adamaero
  • #6
adamaero said:
But I was actually helped on a different forum.
Why did you mark your thread Solved here before you got any replies? Is it because you got a reply on a different forum? You didn't reply to my personal message to you about it before any replies appeared in this thread... Just curious.
 
  • #7
Because with the partial help of another forum, I was going to post the complete solution to what I am doing (i.e., writing an Arduino program to emulate this sensor) . . .
 
  • #8
Nice! :smile:
 
  • #9
C:
void setup() {

  Serial.begin(9600); // bps ~ baud rate
  delay(50);
}

void loop() {
    Serial.write("R0030");  // 30 mm = 1.2" = 0.1'
    Serial.write('\r');     // "\r" (stop bit) carriage return
      delay(60000);         // takes a minute to show on graph
   
    Serial.write("R0061");  // 0.2 feet
    Serial.write(0x0d);     // hex
      delay(60000);
    Serial.write("R0091");  // 0.3 feet
    Serial.write(13);       // ASCII
      delay(60000);
    Serial.write("R0122");  // 0.4 feet
    Serial.write(13);
      delay(60000);
    Serial.write("R0152");  // 0.5 feet
    Serial.write(13);
      delay(60000);
    Serial.write("R0183");  // 0.6 feet
    Serial.write(13);
      delay(60000);
    Serial.write("R0213");  // 0.7 feet
    Serial.write(13);
    Serial.end();
}

And from there it depends on the datalogger's logic settings for the correct distances to be displayed...
 
Last edited:

What is the ASCII code for an ultrasonic sensor?

The ASCII code for an ultrasonic sensor is the numerical representation of the sensor's output in the American Standard Code for Information Interchange (ASCII) format. It is a standardized code used for representing text and characters in electronic devices.

How is the ASCII code interpreted from an ultrasonic sensor output?

The ASCII code from an ultrasonic sensor output is interpreted by converting the numerical values to their corresponding characters or symbols. For example, the numerical value 65 represents the letter "A", 97 represents the letter "a", and so on.

Is the ASCII code the same for all ultrasonic sensors?

No, the ASCII code may differ between different ultrasonic sensors, depending on their manufacturer and model. However, the basic ASCII code is the same for all electronic devices and is standardized across all systems.

Can the ASCII code from an ultrasonic sensor be converted to other formats?

Yes, the ASCII code from an ultrasonic sensor can be converted to other formats such as binary, hexadecimal, and decimal. This can be done using a conversion table or through programming languages like C or Python.

How can I use the ASCII code from an ultrasonic sensor in my research or experiments?

The ASCII code from an ultrasonic sensor can be used in various ways in research and experiments. It can be used to measure distances, detect objects, and track movements. It can also be integrated into other systems and devices for data analysis and automation.

Similar threads

  • Electrical Engineering
Replies
34
Views
3K
  • Sticky
  • Programming and Computer Science
Replies
13
Views
4K
Back
Top