Tell me more ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

I'm thinking about getting a bunch of Maxbotix Ultrasonic rangefinders. I'd like to use as few pins on my controller as possible. Since I don't think you can have multiple devices on an RS232 serial connection, I'd quite like to interface their PWM output with the controller using I²C.

Is there some I²C device I can buy that accepts around 8 PWM inputs, and stores a representation of $\frac{\text{pulse width}}{\text{period}}$ in its registers?

share|improve this question
2  
Is "A microcontroller" with I2C and a timer acceptable, or do you need a custom solution? – Kevin Vermeer Mar 29 '11 at 18:03

3 Answers

up vote 4 down vote accepted

Thank you for linking to exactly what you are talking about -- it makes it much easier to get to the data sheets. The question "How can I use more than one MaxSonar®-EZ1™ in the same system?" in the MaxBotix MaxSonar FAQ lists several ways of using a bunch of them at one time (and some pitfalls to avoid). Some of them use 2 pins of the MCU -- the same number of pins as I2C, but a completely different protocol.

If I understand the data sheet correctly, one of those 2-pin methods is:

  • wire pin 1 low the MaxSonar to enable chaining
  • Wire an output pin from your MCU to the RX pin of the first MaxSonar in the chain.
  • Wire TX of each MaxSonar to RX of the next in the chain
  • Combine the signals from all the MaxSonar PW pins (AND? OR? NAND? diodes?).
  • Wire that combined signal to a timer input pin on the CPU.

Then software on the MCU

  • pulse the RX pin of the first MaxSonar
  • Time the first pulse width to give the distance the first MaxSonar sees
  • Time the second pulse width to give the distance the second MaxSonar sees
  • ...
  • After getting the pulse from every sonar (or timing out at 49 ms per sonar), do something with the data.
  • repeat.

Perhaps one of the other methods listed in the FAQ would work just as well or better for you.

share|improve this answer

Will an 8 channel ADC that supports I2C cut it?

http://www.linear.com/product/LTC2309

share|improve this answer
@eric, if you place the signal through an averaging circuit(low pass) you will lose your response time but you can just read the analog value to know what percentage it is on. To expand on RQDQ's answer. – Kortuk Mar 29 '11 at 18:32
+1 Better yet, those sensors have analog output anyway! I'd still be interested in whether there are PWM input I²Cs out there though. – Eric Mar 29 '11 at 19:18

The microchip PIC18F87K22 has 10 capture compare modules that can handle this function and of course you can talk to it through I2C.

You could also do this will a really simple FPGA.

The Cypress PSoC family could probably also handle measurement of a bunch of PWM inputs.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.