Hi, I have been picking away at this project for the last few months. Basically the project is a motion stabilized camera platform for use on slow moving objects.
I have purchased:
-MPU-6050 IMU
-Arduino Uno
-Adafruit 16 channel I2C PWM board
-(2x) Hitech servos
The servos will just need to do pitch and roll. From the 90* position laying down, i only require 45* in either direction (up/down) and then for the servos to stop, no matter what the IMU angle is if its past 45*.
I have been playing with a kalman filter code that gives steady, consistent values from the IMU. My problem comes when i have to put those numbers to the servos. I have tried a map command, and some really rough if statements to control what values can get sent. I have already burned 2 servos after hours of code and testing. Cant afford 2 more!
If anyone has experience, or could point me in the right direction to get IMU values with limits to the adafruit PWM board that would greatly help. This is only my 4th arduino project (first using i2C) and i just cannot think of a proper way to go about this. Thanks.
Why do you need the PWM board. You can control up to 6 servos directly with the Uno using the servo library. For fine control use servo.writeMicroseconds. Still need an external supply capable of supplying enough current for the running servos ( 1 amp for each servo). Do you understand them difference between servo PWM and analogWrite PWM?
I have ran servos off the arduino with an external power source before, so i understand that. The PWM, not entirely between the two, no.
The way i was explained was that the PWM board will provide smoother movement and cause the servos to jitter less by having a dedicated board to supply signal (the adafruit board). While the arduino (when doing other things, interrupted) leaves the servos to jitter.
If the same output quality can be had by just the arduino, and no dedicated breakout, that would simplify things. I have a 2S LiPo for power.
The way i was explained was that the PWM board will provide smoother movement and cause the servos to jitter less by having a dedicated board to supply signal (the adafruit board). While the arduino (when doing other things, interrupted) leaves the servos to jitter.
I doubt this is true.
The board uses the PCA9685 chip and you need to look at the data sheet. The PCA9685 is basically a 12bit counter with a pair of registers for each channel. A pair of these registers determines the count when the channel output turns on and an other pair when it turns off. Hence the width of the pulse can be altered in 4095 steps.
There are a lot of registers and you must program them correctly in order for it to work correctly.
First off the total cycle time of the output waveform must be set to 50Hz this is done by setting a divider register in the chip. This code is in python but the numbers of the registers and the values are the same
# initialise the outputs on the PCA9685
bus.write_byte_data(PCA9685,0,0x31) # sleep mode set to 1
bus.write_byte_data(PCA9685,0xfe,132) # divider for 50Hz frame
bus.write_byte_data(PCA9685,0,0x21) # sleep mode set to 0
bus.write_byte_data(PCA9685,0x01,0x08) #Mode reg 2 - outputs open drain, output change on ack
Now in order to move the servo you must generate a pulse between 1 and 2mS in this 20mS cycle time. This can be done by setting the first, or turn on, register pair to be 0 and the turn off register to be:-
20mS over 12 bits ( 4096 ) is 20 / 4096 = 4.8828125 uS per register value.
Therefore for a time of 1.5mS ( mid point in a typical servo ) you need a value of 307 in the second register pair.
This diagram shows the register configuration for one channel.
groundfungus:
You can control up to 6 servos directly with the Uno using the servo library.
No
Note that as of Arduino 0017, the Arduino Servo library supports up to 12 motors on most Arduino boards and 48 on the Arduino Mega.
From
http://playground.arduino.cc/ComponentLib/Servo