Show Posts
|
|
Pages: [1] 2
|
|
2
|
Topics / Robotics / Re: Help required for Servo Control Problems ...
|
on: April 29, 2013, 11:22:28 am
|
Ok, so I might have been too quick to give up there.  I gave the code another go and this time, I added in ... pinMode(pin, OUTPUT) ... for each of the servos and now everything works fine.  As far as current pulling goes, the 6 servos in total were only pulling about 300mA - then again, they are pretty small and the frame they are fixed into is incredibly light.  Anyway, I've posted an annotated copy of the final code in case anyone else ever has this problem. Hope it helps!  // Description: Setting 6 servos in a robot's legs to their // original "0" position. // Date: 29th April 2013.
// Include the relevant Servo Library. #include <Servo.h>
// Provide names for the servos to be controlled. Servo RH; Servo RK; Servo RA; // Right Leg. Servo LH; Servo LK; Servo LA; // Left Leg.
// This was the key part of getting it to work - I had to set // the pins that the servo was connected to as OUTPUTS. Then // it worked perfectly fine. void setup() { pinMode(2, OUTPUT); RH.attach(2); pinMode(3, OUTPUT); RK.attach(3); pinMode(4, OUTPUT); RA.attach(4); pinMode(5, OUTPUT); LH.attach(5); pinMode(6, OUTPUT); LK.attach(6); pinMode(7, OUTPUT); LA.attach(7); }
void loop() { // Gives me time to lift the robot off the table. delay(5000); // Sets all the servos in the Right Leg to their origin. RH.write(90); RK.write(90); RA.write(90); // Sets all the servos in the Left Leg to their origin. LH.write(90); LK.write(90); LA.write(90); } AKdaBAOUS
|
|
|
|
|
3
|
Topics / Robotics / Re: Help require for Servo Control Problems ...
|
on: April 29, 2013, 10:07:33 am
|
Ok, so a single servo seems to work fine ... I have a servo controller IC anyway and I was originally intending to use that - I just wanted to see if I could get the servos up and running directly from the Arduino but that doesn't seem to be working so I'll put a lid on it. Thank you for your help anyway. 
|
|
|
|
|
6
|
Topics / Robotics / Re: Help require for Servo Control Problems ...
|
on: April 29, 2013, 09:41:09 am
|
|
They do briefly settle at 0 but only for about half a second (or less) before going haywire. I'm actually using a custom made board but the servos are being powered from an external bench power supply so I don't think that's a problem ...
|
|
|
|
|
7
|
Topics / Robotics / Help require for Servo Control Problems ...
|
on: April 29, 2013, 08:57:45 am
|
Hi everyone! ^___^ I've been trying to get some basic control for some servos for the past few hours (sorry, I'm a noob at coding  ) and after following the tutorials, I've had no luck whatsoever. All I want the servos to do is just stay in their "0" position and not move but every time I upload the program and the servos just move off to some random positions ... I have absolutely no idea where to go from this so I was wondering if someone could shed some light on this for me - I'd appreciate it greatly!  Thanks in advance! ^___^ Here's my code, I'm trying to run 6 servos simultaneously: #include <Servo.h>
Servo RH; Servo RK; Servo RA; Servo LH; Servo LK; Servo LA;
void setup() { RH.attach(4); RK.attach(5); RA.attach(6); LH.attach(7); LK.attach(8); LA.attach(9); }
void loop() { RH.write(0); delay(10); RK.write(0); delay(10); RA.write(0); delay(10); LH.write(0); delay(10); LK.write(0); delay(10); LA.write(0); delay(10); } AKdaBAOUS
|
|
|
|
|
12
|
Using Arduino / Networking, Protocols, and Devices / Re: Is it possible to upload sketches over Bluetooth to an Arduino?
|
on: January 25, 2013, 06:55:11 pm
|
Hi again. ^___^ I have a feeling that the bluetooth module is broken because after following pretty much every tutorial out there, I can't seem to get a piece of software to detect it so I've given up on that for the time being.  Just another question - how would I go about programming the ATmega328 using a wired connection? Could I simply just connect the RX and TX from a serial port in reverse to the RX and TX on the ATmega328 (i.e. RX/TX and TX/RX)? Or is there something more detailed that requires to be done? Thanks again in advance!  AKdaBAOUS
|
|
|
|
|
13
|
Using Arduino / Networking, Protocols, and Devices / Is it possible to upload sketches over Bluetooth to an Arduino?
|
on: January 25, 2013, 02:09:53 pm
|
Hi everyone.  I have a quick question - would it be possible for me to upload a sketch over Bluetooth onto my Arduino? Some extra information: I'm using a custom created board with an ATmega328 with the Arduino bootloader on it. The Bluetooth Module that I'm using is http://dx.com/p/jy-mcu-arduino-bluetooth-wireless-serial-port-module-104299. I've connected the RX to TX and TX to RX and the power wires to the required +5V and ground. I can connect to the module using my Windows and my Mac but when it comes to uploading a program, it keeps saying that "Serial port 'COM5' already in use. Try quitting any programs that may be using it." I'm pretty sure that no other programs are using it, so ...  Anyone have any suggestions? Or am I just doing something really stupid?  Thanks in advance!  AKdaBAOUS
|
|
|
|
|
15
|
Using Arduino / Microcontrollers / Re: Burning a bootloader onto a regular ATmega328 using an Arduino chip.
|
on: December 09, 2012, 12:28:59 pm
|
Hi guys, I've got another quick question. ^__^ Since the ATmega328 can only control 12 servos simultaneously, I found a Servo Controller Slave IC which can run 12 servos too and I was wondering if the following was possible: The Servo Controller IC uses I2C to communicate so if I connect the SDA and SCL pins from the ATmega328 (pins 27 and 28 I think) to the corresponding SDA/SCL pins on the controller, I should be able to control 24 servos in total? Servo Controller datasheet: http://www.hobbytronics.co.uk/datasheets/slave_servo_pro_datasheet_v01.pdfI've written some basic code and I think it looks ok - I got the Servo Controller code from the datasheet. #include <Servo.h> #include <Wire.h>
Servo 0; Servo 1; Servo 2; Servo 3; Servo 4; Servo 5; //Right Side Servos Servo 6; Servo 7; Servo 8; Servo 9; Servo 10; Servo 11; //Left Side Servos
void setup() { //Assigning Right Side Servos to Pins 0.attach(0); 1.attach(1); 2.attach(2); 3.attach(3); 4.attach(4); 5.attach(5); //Assigning Left Side Servos to Pins 6.attach(6); 7.attach(7); 8.attach(8); 9.attach(9); 10.attach(10); 11.attach(11); } void loop() { //Setting Leg Servos to '0' 0.write(0); 1.write(0); 2.write(0); 3.write(0); 4.write(0); 5.write(0); 6.write(0); 7.write(0); 8.write(0); 9.write(0); 10.write(0); 11.write(0); delay(1000); Servo::refresh(25); }
const int servoslave_address = 40; //I2C Address of Servo Controller IC
void servoConfig (int device, byte address, byte val) { Wire.beginTransmission (device); Wire.send (address); //Send the Register Address Wire.send (val); //Send value to write Wire.endTransmission (); }
//Write start-up values for the servo(s) void servoStartup (int device) { unsigned char i; Wire.beginTransmission (device); Wire.send (0); //Send the Register Address for (i = 0; i <= 7; i++) Wire.send (127); //Set all the servos to '0' Wire.endTransmission (); }
void setup () { Wire.begin (); servoConfig (servoslave_address, 61, 1); //Extended Mode servoConfig (servoslave_address, 62, 4); //Feedback rate for servos (133Hz) //Setting time taken for rotation to 2 seconds servoConfig (servoslave_address, 63, 20); //Register Address 63 = Servo 0 servoStartup (servoslave_address); //Send the start up values servoConfig (servoslave_address, 60, 1); //Turn the servo output on }
void loop () { unsigned char j; Wire.beginTransmission (servoslave_address); Wire.send (0); //Send the starting Servo Register for (j = 0; j <= 7; j++) { Wire.send (63); //Rotate all servos 45 degrees to the left } Wire.endTransmission (); delay (2000); Wire.beginTransmission (servoslave_address); Wire.send (0); for (j = 0; j <= 7; j++) { Wire.send (190); //Rotate all servos 45 degrees to the right } Wire.endTransmission (); delay (2000); }
Thank you! 
|
|
|
|
|