So, I need to build a simple gimbal with three servos to control pitch, roll and yaw. I have a 9dof imu which can give me the euler angles in degrees. Can I just connect these angle errors to servo outputs? As in with 1 degree error, the servo should rotate 1 degree, or do I have to use some form of pid control? I have worked with controlling regular dc motors with pid so that the bigger the error, the faster the motor should rotate to compensate. But it's not like I can adjust the speed the servo rotates at.
I recon there would be a problem when the angle error becomes very high in a small amount of time since the servo would take more time to reach the desired position instead of when the error is very small.
I did a similar project. It isn't perfect, but good enough. Cheap servos can't really be precise because of the cheap potentiometer inside and the horrible plastic gears.
There wont be much error overtime because common servos use a potentiometer and not a rotary encoder. Thus a PID is almost impossible.
Related
I have tried varying the duty cycle of the servo motor but it only turns 180 degrees clockwise and anti-clockwise.
You need some measurement device to read the angle, if you want to stick with that servo. With the angle you can implement a closed-loop transfer function to approach the angle you want.
Servos as the FS90R are "continuously rotation servos" and the control signals sets the speed (exactly: the driving current, giving the torque) and direction. For example, see this fine explanation.
If you want to control the angle directly by the control signal, you need "the other" type of servo, described earlier in the linked Wikipedia page.
Is it possible measure a robot car movement distance only with ultrasonic sensor ??
I working on robot car, in the picture you can see how i placed my ultrasonic sensors(red points) and my question is if i can get width value??
Yes it is possible.
The low cost HC-SR04 sensor, can measure objects from 2cm to 4-5m.
The sensor will send some pulses and measure the time, until the pulses returns. So you can just measure the time (short pulse = near, long pulse = far).
There is just 1 problem with your car:
- it must reflect your pulses. If you don't have any wall or obstacles, you will always detect the maximal pulse with.
If you are inside a room, you can detect the movement. If you are outside or in a big room (more than 8x8m), this is not possible.
I'm trying to control my 180 degree servo motors through a Adafruit 1411 Servo shield. However I don't find it simple enough to write the servo's position in angles like the normal servo library without the shield.
Using the Adafruit 1411 Servo shield and Adafruit_PWMServoDriver-library lets you control a servomotor by modifying its pulselength as far as I've realised. To my question..
Is there a way for me to either use the servo shield's output and still write in degrees OR somehow convert these pulselength into angle-degree?
Example of the differences:
Adafruit_PWMServoDriver-library:
pwm.setPWM(Servo, 0, pulseLength);
Servo-library:
Servo.write(45); //Writing in angles like this would be optimal for my project.
Any help in the right direction is much appreciated!
Use the Arduino map function. The following is from the Adafruit instructions:
pulselength = map(degrees, 0, 180, SERVOMIN, SERVOMAX);
Where SERVOMIN and SERVOMAX are values you set according to the range of travel of your servo. This linearly maps a value between 0 and 180 into the range between SERVOMIN and SERVOMAX.
Since you've been doing this with pulse widths so far, you probably already knew the values you need to use.
Do you know how to stop continuous servo in desired position?
I tried to code like this (which I found on many forums):
myservo.write(10); //moves forward
delay (1000); //waits 1s
myservo.write(90); //stops
My servo indeed moves forward for 1s then stops in the position I wanted then immediately goes back to its one position (the same position every time). I would like it to stay in the desired position. For example, I counted that in 150ms it moves for angle of 60 degrees and there it should stop and wait for next info.
I also tried to use trick to detach servo like this:
myservo.write(10);
delay(120);
myservo.detach();
delay(2000);
It works, but it is not as precise as I want it to be and I can't reach smaller angles than 100 degrees.
I'm using Servo TowerPro MG996R Robot 360 which is continuous servo.
I'm sorry if there is already the answer for my question but I promise I went through countless topics and forums!
Thank you for any advices!!!
I am using arduino and accelerometer MMA7341 to measure the acceleration in x direction of an oscillating metal table. But the mounting of the accelerometer is tilted by a small angle (say Q) . Is it affect the acceleration?. If it is affect the acceleration in x direction , how can correct it without changing the tilt of the acceleration sensor.
"Tilt" and "acceleration" are both the same, from the perspective of most sensors, since both measure a force, rather than an actual angle (tilt) or change in velocity (acceleration).
What you should do is make sure the object on which the sensor is mounted is "level", within the best of your ability to determine such a thing, and use the values from analogRead() or whatever else your device provides, as the "0" values.
For the MMA7341 you'll also need to calibrate your analog signals, or else use a high precision reference as input to the Aref pin, assuming you're Arduino exposes that pin.
I think this depends on what you are measuring. THe MMA7341 looks to be able to be used for acceleration as well as tilt. If you are measuring acceleration then the mounting position doesn't matter since acceleration is a change of velocity and the velocity delta will be constant regardless of orientation.
If you are measuring tilt then thats obviously different. You could theoretically measure the initial tilt and then compensate for that in your code if you wanted to of course.