This quest to build a stand-alone I2C pan/tilt range finder controller started with an article here by Ladvien. In https://www.robotshop.com/letsmakerobots/node/39130, Ladvien explores using an ATtiny85 (84) as an I2C motor controller...
And in https://www.robotshop.com/letsmakerobots/node/39222, Chris the Carpenter gives us an awesome pan and tilt code example... so...
I personally have a need to offload the sonar rangefinding scan function from my primary Arduino, as it messes with the timers and causes the entire system to run slowly.
As I want to be able to provide for the various devices most people use, there are not enough pins on the ATtiny85 for what I need, but the ATtiny84 will do just fine!
ATtiny84 short data sheet - ATtiny84 long data sheet
Attached Devices:
Depending on whether you use Ping or MaxSonar ultrasound rangefinders, or Sharp IR rangefinders the pin requirements will differ.\
I will be designing this control module to accept any combination . The Setup routine should identify what modules are attached, and provide output accordingly.
- I will require the two pins SDA and SCL for the I2C interface.
- I will require PWM outputs for the pan and tilt servos.
- I will require two digital Inputs for front and rear MaxSonar EZ rangefinders PWM.
- I will require two digital Outputs for front and rear Ping SR04 rangefinders trigger.
- I will share the MaxSonar digital input pins for for front and rear Ping SR04 rangefinders echo.
- I will require two analog inputs for front and rear Sharp IR rangefinders
That's a total of 2 I2C pins, 6 digital pins, and two analog pins.
Communications:
- SET PAN TO: Angle from 0-180 degrees Zero to the left, 90 degrees being center, and 180 to the right.
- SET TILT TO: Angle from 0-135 degrees Zero being 45 degrees down, 90 being center, and 135 being straight up (thoughts???)
- SET PAN INCREMENT: Range from 1 degree per increment to 10 degrees per increment (Again, thoughts?)
- SET TILT INCREMENT: Range from 1 degree per increment to 10 degrees per increment....
- SET CONVERSION: Boolean for Inches or Centimeters
- SET SWEEP START: Angle at which rangefinding sweep starts.
- SET SWEEP END: Angle at which rangefinding sweep ends.
- INITIATE SWEEP: Iniatiate a sweep, using current pan increment, sweep start and stop.
- SET RETURN COUNT: The number of data points to return on GET DATA
- GET DATA: Retrieve most recent full scan
Future Thoughts:
If there are enough cycles left after coding the above, allow for:
- Return Polar Coordinates: Data returned in consecutive integer pairs (Angle, distance)
- Return Cartesian Coordinates: Data returned in consecutive integer triplets (Angle, x, y)
- Commit unused pins to LED/Infrared/Lazer illumination
So, before I commit this to circuit board, I would love to get your feedback.
References:
https://www.robotshop.com/letsmakerobots/node/39130,
https://www.robotshop.com/letsmakerobots/node/39222
http://www.instructables.com/id/Ultrasonic-Range-Finder-with-an-ATtiny85/
http://blog.iteadstudio.com/arduino-library-for-ultrasonic-ranging-module-hc-sr04/
http://www.instructables.com/id/Getting-started-with-the-Maxbotix-sonar-sensor-q/