Connect with us

Ultrasonic serial communication transmitter.

Discussion in 'Electronic Basics' started by Andrew Holme, Jan 30, 2005.

Scroll to continue with content
  1. Andrew Holme

    Andrew Holme Guest

    Ultrasonic transducers are usually resonant at 40 KHz and their efficiency
    and sensitivity are greatly reduced at other frequencies.
    Trying to modulating the duty cycle is a bad idea - this will not be
    transmitted faithfully over a narrow band link because the "information"
    will be in harmonics. Modulating the frequency (FSK = Frequency Shift
    Keying) sounds like a better idea. Keep the frequency deviation fairly
    small though.
    The NE567, if that's what you're referring to, is a tone decoder. That
    would be a good choice for demodulating FSK at the receiving end. The NE567
    can detect a signal buried in noise, but you still might need a little

    An oscilloscope is essential to develop something like this.

    You would need a varicap diode to generate FSK from a crystal oscillator.

    You can generate AM by making a crystal oscillator from logic gates and then
    using a spare NAND or NOR to gate the carrier on and off with the
    transmitted data.
  2. Personally, I'd recommend getting a scope first. I use my ~20 year old
    scope about 100 times as much as I use my frequency counter.
    Why not just drive the transducer directly from the PIC? If you put the
    transducer accross two output pins, you can develop 10V of drive to the
    transducer by alternately driving one high and the other low. It's also
    going to be much more accurate at frequency control than the 555.
    If a 1 bit is represented by ~10 cycles of sound and a 0 bit by silence
    (or vice versa) you probably have issues with reflected signals
    confusing the receiver. At 1200 baud a bit time is about 1mS. Your
    sound signals only travel 1 foot during this time, and many reflections
    are delayed by several mS. This could result in bits showing up
    literally out of sequence to the receiver. You need to slow your baud
    rate way down.

    You also haven't mentioned any amplification stages on the receiver.
    What are you using to condition the received signal before feeding it to
    the PIC?
    Yes, I think there is a better and easier way.
    Your making it harder than it needs to be.
    Now you are aproaching Rube Goldberg status. ;-)
    The more complicated you make it, the harder it will be to make it work
    reliably. Especially without a scope. Do you have to use ultrasonics?
    How about IR, it should give you as much range with less noise issues
    and virtually no reflection issues. The receiving end is allot easier
    as well since you can use a cheap off the shelf receiver to remove the
    38Khz carrier and give you plain serial data.

    You can use a TMR interrupt to generate the 38Khz carrier on the sending
    side, or you could just bit bang it out using inline delay routines. To
    make things simple you could have a TMR interrupt toggle an output pin
    at 38Khz continuously. You then connect this pin to one input of an AND
    gate. You connect another output pin to the remaining input of the AND
    gate and use it to toggle the carrier on and off to send data.

    I can help you with the code to get timer interrupts working if you
  3. One easy way to do this is to use a flag, set or cleared in the main
    loop, that gets xor'd into the port during the interrupt. If the flag is
    1, the value is changed (A xor 1 = ~A), and the port wiggles. If the
    flag is 0, the value isn't changed (A xor 0 = A). This saves a pin and
    an "and" gate, without substantially changing the code you propose.

    However, the 555 is perfectly acceptable. It can be made fairly
    accurate, within a few percent, using a pot and a frequency counter. If
    the pic is doing other things, using an offchip oscillator may be a good

    Given that the transducer will ring with the incoming signal at whatever
    it's natural frequency is, frequency stability may not matter all that
    much. It will filter anthing outside it's bandwidth, also, so using a
    tone detector is probably a waste.
    Actually, RF is probably a much better solution. You can get a
    transmitter/receiver pair that will do FSK at 300' for under $20 in
    single quantity from digikey.

    Robert Monsen

    "Your Highness, I have no need of this hypothesis."
    - Pierre Laplace (1749-1827), to Napoleon,
    on why his works on celestial mechanics make no mention of God.
  4. Rubicon

    Rubicon Guest


    I'm trying to make a 24kHz ultrasonic transmitter capable of sending
    AM serial data to a receiver over a min 30ft range. I have no scope or
    frequency counter (looking for a counter locally) and have managed to
    get it just-going on occasion over a couple of feet by using high
    tolerance components and using an ultrasonic tone controlled switch
    kitset as a tuning referance. I'd foolishly thought when I bought the
    kit "What are the chances of there being 24kHz lurking about?" Pretty
    good actually. Drop a tool on the garage floor, tap the workbench and
    away she'd go. Lucky I didn't connect it to the main garage door!

    At present I have a 16F84A PIC sending serial out at T1200 (True
    logic) to the reset pin of a 555 timer set for 24kHz. Its output goes
    to a 4069 inverter that drives a transducer. The inverter is wired in
    parallel, 180 degrees shifted for maximum output. My PIC programmer is
    old and doesn't go beyond the 16F84A which is why I'm trying to do it
    this way.

    TX PIC----555 24kHz----INVERTER----TRANSDUCER

    If I connect the TX PIC serial output pin straight to the RX PIC
    serial input pin then the receiving LED lights up during the program
    cycle just fine. However if I connect the 555 output pin to the RX PIC
    then it lights up only occasionally. A sync problem I'm guessing
    caused by the 555 duty cycle? It was set to 55% and I changed it to
    50% which made things worse. I'm unsure what to do here as I read that
    the duty cycle for a transducer should be less than 60% for it to
    operate properly and also that connecting a transducer straight to a
    555 isn't a good idea. The 555 isn't stable at the resonant frequency
    as a reverse voltage causes the frequency to jump about.

    I've just seen a circuit where a modulated input goes to the Control
    Voltage pin of a 555 (astable mode), the output having a pullup
    resistor. Another circuit provides control over the duty cycle without

    changing the output pulse frequency.
    I can combine them and try it but is it the best way to go about this?
    Is there a better way considering the limitations of my PIC?

    Perhaps a tone controller or are they not fast enough?

    Maybe going up to 40kHz with a crystal locked TX inverter as in the
    link below but how does one connect it to the PIC for serial AM? I
    have a 40Khz crystal I pulled from some old junk which I could use and
    the crystal eliminates tuning. I can't find any 24kHz crystals

    Any advice on how to go about making this work reliably welcome.


  5. Rubicon

    Rubicon Guest


    Thankyou all for your responses.

    I hope you don't mind if I post questions tomorrow night as I just
    spent over three hours trying to get True 300 baud going between the
    PICs. Tired and not thinking straight but one things for sure
    T300/N300 wont work. It might be a bug in the old PBP version I have.
    T1200 baud works fine in a little test program.


  6. Your right of course, that would be the best way.
    Agreed. Like someone mentioned (maybe it was you), the transducers seem
    to act allot like mechanical filters.
    Do they work ok with straight serial data, or should it be encoded so as
    to keep duty cycle less than 50%?
    Great reading datasheet. ;-) I really liked the section on "Surviving
    an RF Implementation". :-D
  7. I don't think it matters. The two together function as a pipe,
    reproducing bit transitions on the other side. However, using some form
    of manchester encoding or a bit stuffing protocol like hdlc might make
    clock recovery on the other side easier.

    Robert Monsen

    "Your Highness, I have no need of this hypothesis."
    - Pierre Laplace (1749-1827), to Napoleon,
    on why his works on celestial mechanics make no mention of God.
  8. Rubicon

    Rubicon Guest

    Basically mechanical filters.
    I wasn't going to modulate the duty cycle just adjust it until I had
    the best "sync" rate between the 555 and the RX PIC. That was my
    theory anyway. I don't know if it would work.

    I looking for a second hand one.
    Thankyou for the information Andrew.


  9. Rubicon

    Rubicon Guest

    This is beyond me at the moment as I've only recently started
    programming PICs. I keep everything for future reference though.

    Does the duty cycle of the 555 matter when it's used to modulate a
    signal? If so what should it be for 300baud/1200 baud?

    Could the tone detector be used on the RX after a LM833 1000Xgain or
    more amplifier to filter out the noise of the amplifier, its
    associated components and other circuitry?
    I'd rather stick with ultrasonics as I already have so much of the
    required components and I also find it interesting.
    Thankyou for the information and advice.


  10. Rubicon

    Rubicon Guest

    I'm looking for a secondhand one at the moment. They're not that
    common on the secondhand market down here but there is a Velleman HPS5
    PersonalScope for sale at

    The trouble with being a rank newbe at PIC programming is one just
    doen't know the great things you can do with a PIC. It certainly would
    reduce the parts count but more than likely my current programming
    skill level and the programmer itself would fail me.

    I'm trying to do that but there seems to be a bug in the old PicBasic
    Pro programmer when it comes to T300/N300. There's another forum I'll
    ask in to be sure about this.

    I thought I'd deal with the TX circuit first as the 555 appeared to be
    a major problem. The RX consists of a LM833 low noise opamp (set at
    about 1400X), a schottky diode detector and a LM393 voltage
    comparator. The output then goes to the PIC.

    I was thinking of using a LM567 tone detector after the LM833 to
    filter out the noise of the opamp, its associated components and other
    circuitry at that gain level along with the actual signal. Good idea
    or not?
    I don't understand the reference here but I do see a wink!

    Wouldn't a crystal make things a little more "solid" and temperature

    Yes, I do like adding lights and switches to things a little too much.

    I'd rather keep to the ultrasonic path. I already have so much of the
    required components and I also find it interesting.

    I roughly understand what you mean with the TMR and interrupts but as
    mentioned I'm a rank novice and not capable of it yet. My knowledge of
    electronics and PIC programming is like Swiss cheese.

    That would be great but I don't wish to take up too much of your time.

    PBP allows me to insert assembly code but if I can get a detailed
    "Process" then I can read up on it and also ask the PBP forum for help
    to convert it to Picbasic. No offence I hope.

    I think perhaps the AND gate would be best method. Simple is good.

    The PICs have 4MHz crystals and the TX PIC input/output pins are
    completely free with the exception of one required for an indicator
    LED. The RX PIC has the watchdog timer set for napping and sleeping to
    conserve power. During its cycle it currently checks for a manual
    button push, then listens for any incoming signal before timing out,
    sleeping then starting over.
    Help with the code for both 24kHz and 40kHz transducers would be
    appreciated as I have both types to play with.

    Thankyou Anthony for your advice and kind offer.

    Time for bed.


Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day