• Support PF! Buy your school textbooks, materials and every day products Here!

What is the ASCII code an ultrasonic sensor will output?

  • #1
97
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)
 

Answers and Replies

  • #2
FactChecker
Science Advisor
Gold Member
5,385
1,954
I seriously doubt that the output is in ASCII. It is probably an 8 bit representation of some dustance unit of measure.
 
  • #3
phinds
Science Advisor
Insights Author
Gold Member
2019 Award
15,918
5,615
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
97
1
"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
phinds
Science Advisor
Insights Author
Gold Member
2019 Award
15,918
5,615
"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:
  • #6
berkeman
Mentor
56,860
6,843
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
97
1
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
berkeman
Mentor
56,860
6,843
Nice! :smile:
 
  • #9
97
1
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:

Related Threads on What is the ASCII code an ultrasonic sensor will output?

  • Last Post
Replies
1
Views
911
Replies
4
Views
2K
  • Last Post
Replies
11
Views
4K
Replies
2
Views
1K
Replies
4
Views
1K
  • Last Post
Replies
3
Views
3K
Replies
9
Views
209
  • Last Post
Replies
3
Views
1K
  • Last Post
Replies
3
Views
2K
Top