Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 7 of 7

Thread: UART Communication

  1. #1
    Junior Member
    Join Date
    May 2021
    Posts
    3

    UART Communication

    I want to use two pressure sensors with two teensy 3.6. At a specific pressure teensy will active a motor. If the pressure sensor broken, uart communicated other teensy should activate the motor with its own pressure sensor. How can i do this? How other teensy understand that the other sensor is broken?

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    24,454
    Quote Originally Posted by New View Post
    How can i do this? How other teensy understand that the other sensor is broken?
    Assuming the motor is controlled by a simple on/off digital signal, probably the simplest and (maybe) most reliable way would be to use an "open collector" approach to connect both output signals. If logic high turns on the motor, you would connect a resistor from the pin to GND so it is logic low when neither Teensy drives the pin high. On each Teensy, when the pin is supposed to be low you would use pinMode(pin, INPUT) so that Teensy doesn't drive the signal. The resistor does the work of making the pin low when neither Teensy wants the motor on. When it should be high, use digitalWrite(pin, HIGH) and then pinMode(pin, OUTPUT). If both do this, it is safe because neither tries to actively drive the pin low.

    This way you do not need any communication between the 2 boards. You only need to design each so it avoids driving the pin high if the sensor fails. By avoiding communication between the 2 boards, you can have it work properly even if one of the Teensy boards fails, as long as the failure mode doesn't drive the pin high. The only really critical component would then be the resistor, and you could use 2 of those in parallel if you wanted to have a system where every part has a redundant backup.

    As for normal serial (UART) communication, here is the page with details.

    https://www.pjrc.com/teensy/td_uart.html

  3. #3
    Junior Member
    Join Date
    May 2021
    Posts
    3
    Unfortunately, I have to use two boards for this project.

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    24,454
    I don't understand. You question asked "I want to use two pressure sensors with two teensy 3.6".

    Now you're saying you only have one Teensy 3.6?

  5. #5
    Junior Member
    Join Date
    May 2021
    Posts
    3
    Oh sorry, I mean in the project, two teensy must communicate for the broken sensor and activate the motor with its own sensor. I am a beginner. Sorry for my bad explanation.

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    24,454
    I'm still confused. You have 1 motor. You have 2 Teensy. Do you have 2 sensor or 1 sensor?

    I do not understand why the open collector summing of the 2 outputs from the 2 Teensy does not solve your problem.

  7. #7
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    9,210
    Sorry I was reading this thread and it is very unclear to me, what your setup or desired setup is and what are you trying to solve.

    Maybe if you showed a diagram or the like, which sort of shows what pieces are where they are. And your constraints... What is a broken sensor?

    I mean for example could this be as simple as having the outputs of each board fed into some form or OR gate (which maybe could be a couple of diodes) to whatever starts the motor (Relay? Motor controller?)

    Can the boards have anything in common? Example each has an output pin that feeds to an input pin of the other board? That way each board can look at what the other board says and decide to do something.
    Or could be more advanced than simple digital, maybe analog value or Uart or ...

    Again no idea of what is failure? If you wish to trigger motor at pressure X like lets say 50... And one thinks it is 55 and other 45 how you know which one is correct... Probably easy to detect complete failure like stuck at 0 or at some high value...

    Again sorry I may be missing something obvious here, but not again not sure what you are asking.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •