Author Topic: multiple digital sensors  (Read 3295 times)

0 Members and 1 Guest are viewing this topic.

Offline pomprockerTopic starter

  • Supreme Robot
  • *****
  • Posts: 1,431
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
    • Nerdcore - Programming, Electronics, Mechanics
multiple digital sensors
« on: January 10, 2009, 07:56:45 PM »
What is the best way to handle multiple digital sensors?


They both seem to require some PWM to communicate with them.

I am using a mega328p and, I am using the parallax ping, by making the pin go high and low, and using a timer to capture the time it takes, etc

I want to add a MEMS 2-axis accelerometer I got from radio shack
http://www.parallax.com/Store/Sensors/AccelerationTilt/tabid/172/CategoryID/47/List/0/Level/a/ProductID/93/Default.aspx?SortField=ProductName%2cProductName


But it would require me to do the same thing using a timer.


This can't be the way to do it, seeing how if I had more sensors than timers, this would not work.





Offline Ro-Bot-X

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,431
  • Helpful? 25
  • Store: RoBotXDesigns.ca
    • Ro-Bot-X Designs
Re: multiple digital sensors
« Reply #1 on: January 10, 2009, 08:26:51 PM »
Can't you use the same timer for all sensors, since the sensors will be sampled one after the other? For each sensor you need to reset timer, start timer, stop timer, store to variable. What if you are trying to read several Ping sensors at once? You'll send the trigger to all sensors, reset timer, start timer, then monitor each sensor for pin change (interrupt?) and store that timer value without stoping the timer. After all sensors are sampled, process the data. You think it'll work? It's kind of similar to the simultaneous servo pulse generator.
Check out the uBotino robot controller!

Offline pomprockerTopic starter

  • Supreme Robot
  • *****
  • Posts: 1,431
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
    • Nerdcore - Programming, Electronics, Mechanics
Re: multiple digital sensors
« Reply #2 on: January 10, 2009, 08:28:39 PM »
Maybe so, but it doesn't seem like it would be the correct way to go.

Offline Ro-Bot-X

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,431
  • Helpful? 25
  • Store: RoBotXDesigns.ca
    • Ro-Bot-X Designs
Re: multiple digital sensors
« Reply #3 on: January 10, 2009, 08:31:45 PM »
Maybe so, but it doesn't seem like it would be the correct way to go.
What doesn't seem to be the correct way to go?
Using the same timer for reading all sensors one after the other or using the same timer to read all sensors at once?
Check out the uBotino robot controller!

Offline pomprockerTopic starter

  • Supreme Robot
  • *****
  • Posts: 1,431
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
    • Nerdcore - Programming, Electronics, Mechanics
Re: multiple digital sensors
« Reply #4 on: January 10, 2009, 08:37:59 PM »
Having to use timers I guess. aren't there better ways to handle digital sensors

Offline Ro-Bot-X

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,431
  • Helpful? 25
  • Store: RoBotXDesigns.ca
    • Ro-Bot-X Designs
Re: multiple digital sensors
« Reply #5 on: January 10, 2009, 08:44:34 PM »
They are eighter PWM or serial (be it I2C or RS232). If they are PWM, a timer must be used.
Check out the uBotino robot controller!