TR switching and receiving echo signals

ericgibbs

Joined Jan 29, 2010
21,448
Hi demir,
I have looked through your Arduino code, it is difficult to follow, as there a no Comments.

It is advisable to add 'Comments' in the Sketch so that your Code sequences and purpose, can be easily understood by other readers.

What Arduino MCU module are you using?

E
 

Thread Starter

demir-ali

Joined Jul 13, 2024
321
Hi demir,
I have looked through your Arduino code, it is difficult to follow, as there a no Comments.

It is advisable to add 'Comments' in the Sketch so that your Code sequences and purpose, can be easily understood by other readers.

What Arduino MCU module are you using?

E
I use ardunio uno board, there is few problems in code but even i fixed it still doesnt work
 

ericgibbs

Joined Jan 29, 2010
21,448
Hi demi,
Please post your new Sketch, I want to help, so please add Comments, so that can see what you are expecting the code to do.
E
 

ericgibbs

Joined Jan 29, 2010
21,448
hi demir,

Have you considered the time it takes to send this serial print message, at 9600 Baud, after you have sent the TX pulse.?
Serial.println("SIGNAL TRANSMITTED"); // PRINTS SIGNAL SENT MESSAGE AND SET STATE TO RECEIVING
E
 

Thread Starter

demir-ali

Joined Jul 13, 2024
321
hi demir,

Have you considered the time it takes to send this serial print message, at 9600 Baud, after you have sent the TX pulse.?
Serial.println("SIGNAL TRANSMITTED"); // PRINTS SIGNAL SENT MESSAGE AND SET STATE TO RECEIVING
E
I am not süre I will recheck it but I do not think it is due to that
 

ericgibbs

Joined Jan 29, 2010
21,448
hi,
At 9600 Baud, assuming an 10 Bit Byte, that is approx 1/960 , approx 1mSec/byte.
So for your 20 Byte message, that is 20mSec.

In air sound travels at approx 340m/Sec, so in 20mSec that is a distance of 340m*0.02sec =6.8mtrs.

E
 

Thread Starter

demir-ali

Joined Jul 13, 2024
321
hi,
At 9600 Baud, assuming an 10 Bit Byte, that is approx 1/960 , approx 1mSec/byte.
So for your 20 Byte message, that is 20mSec.

In air sound travels at approx 340m/Sec, so in 20mSec that is a distance of 340m*0.02sec =6.8mtrs.

E
I get it sir , It is debugging habits hahah.
I will let you know whenever I try again.
 

ericgibbs

Joined Jan 29, 2010
21,448
Hi demir,
I would consider programming a spare Arduino as an Emulator for your Transmitter/Receiver and use it as a simulated RX echo source

Your main MCU would generate the usual TX pulse, say every 100mSec and trigger the Emulator, which would generate a simulated RX pulse at say 5mSec [ or any value from say 1mSec through 9mSec] after the TX pulse.
This simulated RX pulse would be connected back into the main MCU.

Using this method, you will be able to create/debug and calibrate your main MCU program that calculates the distance etc..

When you have the main MCU program debugged and running, relook at the analogue and comparator circuitry.

E
 

Thread Starter

demir-ali

Joined Jul 13, 2024
321
Hi demir,
I would consider programming a spare Arduino as an Emulator for your Transmitter/Receiver and use it as a simulated RX echo source

Your main MCU would generate the usual TX pulse, say every 100mSec and trigger the Emulator, which would generate a simulated RX pulse at say 5mSec [ or any value from say 1mSec through 9mSec] after the TX pulse.
This simulated RX pulse would be connected back into the main MCU.

Using this method, you will be able to create/debug and calibrate your main MCU program that calculates the distance etc..

When you have the main MCU program debugged and running, relook at the analogue and comparator circuitry.

E
Hi Eric , firstly thanks for your help and hints , as I am year 3 student next semester I have some additional questions discrete. Is there anywhere else I can contact you if you would like to share your experiments with me ?
 

ericgibbs

Joined Jan 29, 2010
21,448
Hi demir,
It helps other students if technical questions and answers are posted on the open forums.
Also, it enables any interested member can participate in helping.

E
 

ericgibbs

Joined Jan 29, 2010
21,448
Hi demir,
Your Sketch does not detect the RX pulse.??

Attached is a simple Sketch that have in a Nano, that detects the TXP pulses, from the main MCU and then generates a simulated RX pulse 250uSec after a 5mSec delay.
This simulated RX pulse is connected back into pin 10 of the main MCU, where it should be detected, and a distance calculated.

E
BTW: I would suggest you run the TX pulse rate every 100mSec, that is 10 per Sec.
In that way, when you get your project working, you can average 10 RX times and output the distance value every second.
 

Attachments

Thread Starter

demir-ali

Joined Jul 13, 2024
321
Hi demir,
Your Sketch does not detect the RX pulse.??

Attached is a simple Sketch that have in a Nano, that detects the TXP pulses, from the main MCU and then generates a simulated RX pulse 250uSec after a 5mSec delay.
This simulated RX pulse is connected back into pin 10 of the main MCU, where it should be detected, and a distance calculated.

E
BTW: I would suggest you run the TX pulse rate every 100mSec, that is 10 per Sec.
In that way, when you get your project working, you can average 10 RX times and output the distance value every second.
No sir , it is really interested why it does not detect. At this moment I look for cascode setups in my freetime and looking for what I do have fun when doing. It also helps that I have electronics 2 class next semester and working earlier will give me free time in semester.
I am also very happy about the way we had in project , I sent the last results to my lecturer , he liked
and congratulated me.
 

ericgibbs

Joined Jan 29, 2010
21,448
Hi demir,
You are transmitting the TX pulses, then waiting for 10mSec before testing for an RX Echo.
The TX pulse will have travelled 3.3mtrs in 10mSec!!!

PORTB = B00000000;
digitalWrite(7,0); // IMPEDANCE SWITCH
delayMicroseconds(1500);
digitalWrite(6,0); // IMPEDANCE SWITCH
delayMicroseconds(100);
digitalWrite(5,1); // 5V OUT FOR COMPARATOR OUTPUT
delay(10);
digitalWrite(5,0);
 
Top