My group is using a GT016 uno Arduino board.
The goal is to use 1 piezoelectric sensors to send a frequency/signal and for the other to recieve the signal.
The reciever is working using some basic code, but it detects vibrations and the values are shown in the serial moniter. ( Please advise on whether this okay and if there's any better ways to do this)
The emitter is the problem, since I couldn't find any examples on how to use the piezoelectric sensors as emitter because everything shown online is for sensors.
So far I've been using ditigitalWrite and analogWrite but I don't know if works or not.
A while back I did some experiments in ultrasonic serial communications. For both the transmit and receive side I used a modified HC-SR04 ultrasonic echo locator, so a 40 kHz piezo device. (Link to schematic of the version I used)
I removed the OTP microcontroller entirely, but you really only need to isolate pins 12,13,14 to control the transmitter. To transmit, one sets "HVOff" low and sends the differential signal on Tx1/Tx2. I bit banged the transmit with digitalWrite() and delayMicroseconds(), but the toneAC() library would also work to generate a differential signal.
For the receiver I simply tapped off the "Signal" net at pin 10 of the microcontroller and interpreted this in code.
The piezo transducers are highly resonant so frequency shift keying didn't work well. In an indoor space, at least, echos are persistent and not well constrained so coding on pulse duration didn't work well and this is probably also an issue for phase modulation. The best scheme I tried was pulse position based, e.g. 10 ms from start of pulse to start of next pulse is a "0" and 15 ms is a "1", or some such. The time required to let echos die away limited throughput to about 100 baud.
Whether or not this is appropriate for your application, the circuit shows the general flow. The transmitter is simply an untuned "high voltage" differential output to the piezo. The receive chain is a series of tuned amplifers with some sort of detector (amplitude in this case) at the end.
How does one code with piezoelectric sensors as an emitter on arduino uno?
The goal is to use 1 sensor as a reciever and the other as an emitter to send and detect ultrasound to help map a body composition.
The reciever part is fine and it detects vibration when you touch it.
But how do you write the code for the emitter, while only using the arduino, a resister, the piezo electric sensor. ( Is it possible to only use these?)
So for I tried using digitalWrite(pin,High) butnothing worked out so far
Ultrasonic at 3MHz is typically used in liquid (water...) or solid media, not in air.
The piezo you linked IMO is too big for 3MHz. No wonder that you cannot receive anything.
The Arduino UNO timers can't do a 3 MHz square wave. The closest you can get in a square wave is 4 MHz or 2.66 MHz. If you don't mind your wave being a little lop-sided you can get 3.2 MHz but only with 40% or 60% duty cycle.
arno117:
How does one code with piezoelectric sensors as an emitter on arduino uno?
The goal is to use 1 sensor as a reciever and the other as an emitter to send and detect ultrasound to help map a body composition.
The reciever part is fine and it detects vibration when you touch it.
But how do you write the code for the emitter, while only using the arduino, a resister, the piezo electric sensor. ( Is it possible to only use these?)
So for I tried using digitalWrite(pin,High) butnothing worked out so far
Please advice
You need to apply an alternating current to a piezo device to make it produce sound. Something like
tone(piezoPin, 2000) ;
which will produce a 2 kHz squarewave to drive the piezo disk which should be audible. The piezo device you show will probably be resonant around this frequency. As noted in posts 8 & 9 above, the device you show may not be suitable for 3 MHz and 8 bit 16 MHz Arduinos can't drive it that that frequency regardless.
We want to use an ultrasonic emitting freq of 3MHz
Why? Please describe the application and explain the choice of frequency. It requires very specialized transducers, impedance matched to the transmission medium.
jremington: Why? Please describe the application and explain the choice of frequency. It requires very specialized transducers, impedance matched to the transmission medium.
Sorry I didn't mention the reason, 1 part of our project is to use ultrasound for echology to map the body composition( mainly fat, muscle , bone).