Show Posts
Pages: 1 ... 3 4 [5] 6 7 ... 52
61  Using Arduino / Motors, Mechanics, and Power / Re: Short power with more than 2 servos on: September 12, 2012, 01:51:50 pm
Can you provide a simple schematic, or at least specifics on exactly what pins are connected to what?
62  Using Arduino / Motors, Mechanics, and Power / Re: Stepper motor used as a servo on: September 12, 2012, 01:47:13 pm
It doesn't appear that you're using any sort of positional feedback on that stepper motor, which doesn't really make it a servo.  Still a nice demo, and a good use of salvaged printer hardware (I have two old printers in storage just waiting for me to get around to tearing the goodies out of their guts).
63  Using Arduino / Programming Questions / Re: One request from beginner - Motor Shield + Arduino UNO. on: September 12, 2012, 10:24:23 am
Or, alternatively, you could do the legwork yourself.
64  Using Arduino / Programming Questions / Re: One request from beginner - Motor Shield + Arduino UNO. on: September 12, 2012, 09:56:38 am
Google is an excellent resource for finding 'stuff' in general.  This  includes tutorials of all sorts, which includes Arduino tutorials, which even includes tutorials on driving motors with an Arduino and H-bridge/motor driver/motor shield.
65  Using Arduino / Programming Questions / Re: How accurate are delays within loops on: September 12, 2012, 09:54:15 am
delay() is pretty accurate, but fairly useless for a variety of other reasons.  One of them of course being the problem you are running into.  It's rather useless when used in conjunction with the rest of the program to perform overall timing.

Take a look at the Blink without Delay sample.  That provides a good method for overall timing.
66  Using Arduino / Programming Questions / Re: How to save a constant updating value on: September 12, 2012, 09:51:58 am
To everyone who assumes my code will not compile, you look really ignorant and rude right now as my code def compiles and will fully upload and run on my build.

No assumptions have been made.  The code you provided in your initial post does not compile, period.
I highly recommend reading the sticky in this forum.  The one titled 'Read this before posting a programming question'.  Perhaps you already think you know what that post contains.  I can assure you though, based on the above comment you've made, you have no idea what that post contains.
67  Using Arduino / Programming Questions / Re: Is there an easier way to do all of this? on: September 10, 2012, 07:38:26 pm
You are creating a whole bunch of consecutive pointers into your array inParse, when you can just pass that array into your sort methods.
And since your chan array lines up with your parsed array, you can also loop through the assignments instead of individual separate assignments.  Here's an example (separate from your own sources):


char buffer[] = "12,345,55,178,9,77,900,122";
//inParse only needs to be as large as the number of individual int strings strtok will find in buffer
//It does not need to be as large as buffer
char *inParse[8];
int values[8];

void setup()
  char *s;
  int count = 0;
  s = strtok(buffer, ",");
  inParse[count++] = s;
  while(NULL != s)
    s = strtok(NULL, ",");
    if(count < 8) inParse[count++] = s;
  //We only need to pass in a single value, a pointer to our array of pointers
  //ie, a pointer to a pointer (char**)
  for(int x = 0; x < 8; x++) Serial.println(values[x]);

void loop(){}

//An array of pointers is basically just a pointer to a pointer
void Convert(char** arr)
  for(int x = 0; x < 8; x++)
    //Here's where the magic happens.
    //We dereference our array pointer, to pass our char * to atoi()
    //And also increment the array pointer to the next element in our array
    values[x] = atoi(*arr++);
    //Or, if you're having trouble wrapping your mind around that, try this:
    //values[x] = atoi(arr[x]);

No, I'm so used to HTML that this is the structure I am used to seeing, and makes it easier for me to read my own code... Even my java looks like that...
When asking strangers for help, it's probably best to try to accomodate them as best as possible.  Help them help you, and you'll get better help.  Hint:  The Arduino IDE has an Auto Format capability in the Tools menu.

I don't have to take serial data as String?
No.  You can, and should, stick to char arrays.

From here on out, it is obvious to me that you are a much more advanced C++ programmer than myself. I have no idea what a bounds check is...
Bounds checking isn't all that advanced stuff.  You should spend some time brushing up on your C++ skills.  In summary, C++ does very little for you.  if you create an array of 5 elements, you can try to access the 10th element, and C++ won't stop you.  You'll just access memory beyond the array, and who knows what value that memory is going to contain.  Worse still would be changing that memory.  It's up to you to make sure you're index values are within the bounds of your array.
68  Community / Bar Sport / Re: What is the most expensive board you ever smoked? on: September 07, 2012, 08:57:05 am
This isn't an instance of me frying some hardware, but an amusing instance still.

Back about 12-14 years ago we were working on a new product that supported two new cameras from Dalsa, one a high speed 2k linescan camera, and the other a high speed 2kx2k areascan camera.  Both cameras were in identical packaging with identical connectors.  However, the linescan camera operated on 24v and the areascan camera only operated on 12v.  Needless to say, it was entirely possible to connect the 24v power supply to the 12v camera.  Our lead engineer was constantly lecturing everyone about the risk, and to always be sure what camera and power supply they were using (the power supplies were identical in appearance as well).  About a month into the project, the lead engineer was the one to plug the 24v power supply into the 12v camera.  And of course, the areascan camera was the more expensive of the two as well, $20k at the time vs I think $7k for the linescan.
69  Using Arduino / Programming Questions / Re: Passing char arrays to a function then using strcat() on: September 07, 2012, 07:35:58 am
If I pass a character array to a function, then add to it by using strcat() will my program adjust the memory allocated for this char array, or am I going to run into a memory problem.  For example

strlcat() can be used to prevent writing outside the bounds of the destination buffer.  It will just truncate the second string if necessary.  Here is the reference for all the C string library functions:
70  Topics / Robotics / Re: Servo (PAN) and Parallax Ping))) on: September 06, 2012, 10:17:43 am
Code re-use is a wonderful thing:,106043.0.html
71  Topics / Robotics / Re: Robot From An Existing Toy on: September 06, 2012, 10:15:14 am
There are plenty of rover kits that are designed to be custom modified as well as integrated with an Arduino.  These kits will almost universally be a better option than buying a new toy and hacking it apart.

Now, buying an old RC toy car from a yard sale for a few bucks, that may be worth the effort, since there's little financial investment involved, and a similarly sized robotic rover will be substantially more money (think of the Dagu Wild Thumper 4wd/6wd rovers).
72  Topics / Robotics / Re: And another self balancing robot on: September 06, 2012, 07:04:21 am
His code is published for all to see.  Go read it.  There are no physical computations.  There are no torque calculations. I'll sum it up as thus:
He reads an IMU and computes an angle based on those readings.
He feeds that angle into a PID controller that, with three tweakable parameters (Kp, Ki, Kd) outputs a raw value.
He clamps this raw value to the range his motor controller wants to use.
He feeds this value into the motor controller, that simply linearly converts it to some PWM output to drive the motors.

With the exception of some remote control code, that is ALL his code does.  Again, the code is available.  You are arguing that he is doing things that simply aren't in his code.  That's the beauty of PID controllers.  You can spend days, weeks, even months, developing an accurate physical representation in code that MAY be able to properly balance your robot, or you can spend hours writing a simple PID controller, and maybe another couple of hours tweaking the PID to balance your robot.  This is a method that has been used thousands of times by a variety of people, myself included.
73  Topics / Robotics / Re: And another self balancing robot on: September 05, 2012, 08:14:53 pm
If for example the PID says a torque of 1 Nm is needed

The PID does no such thing.  It simply outputs a dimensionless value that abstractly represents how much adjustment needs to be made to attain/maintain it's 'ideal' state (that is, the robot standing straight up) based on it's input mechanism (the IMU).  That value is converted into a PWM output to the motor.  The K values are tweaked to provide optimal balance.  There are no real 'physics' calculations involved at all.  It's just some rather abstract tuning (though the Proportional, Integral, and Differential portions of the PID do have different characteristics regarding how the influence they output value).
74  Using Arduino / Programming Questions / Re: Code Cleanliness And Organization on: September 05, 2012, 12:12:59 pm
Those are some rather extreme examples.  Worst case I ever saw in an actual work environment was a function called:

AsicMonsterOverrideBurstSizeAndInterval(int, int);

I've personally never had any trouble reading CamelCase (even your unrealistic example), and the majority of variables/functions don't need to be more than 2-3 words long to be adequately described anyways.
75  Topics / Robotics / Re: And another self balancing robot on: September 05, 2012, 09:49:35 am
Looks really nice!
I've read the PDF in your github, it was very informative and easy to understand.
I'm thinking of building a self balancing robot my self and may I ask how are you controlling the motors?
You don't have encoders so I'm guessing its an open loop design(?), how do you control the torque they output?

He's using a PID controller to drive the motors based on feedback from the IMU.
Pages: 1 ... 3 4 [5] 6 7 ... 52