Show Posts
Pages: 1 ... 2262 2263 [2264] 2265 2266 ... 3361
33946  Topics / Robotics / Re: Reading from Serial on: November 30, 2011, 07:47:24 pm
Code:
         case '119':
This is almost certainly wrong. Either lose the single quotes, or replace the number in the quotes with the correct letter (preferred).
33947  Using Arduino / Interfacing w/ Software on the Computer / Re: processing & sensor data on: November 30, 2011, 07:33:39 pm
I don't see any print() or println() statements in serialEvent(). Some reason why not?
33948  Using Arduino / Programming Questions / Re: robot hand shadowing on: November 30, 2011, 07:10:19 pm
Quote
Would writing code for this sensor be like code for a normal knob style potentiometer?
Yes, it would. The site doesn't mention how much change in resistance you can expect, so you will definitely need to experiment to determine the maximum change in resistance, and how to map that change to a servo position value. Should be fun.

Try to find a more stylish glove, though.
33949  Using Arduino / Programming Questions / Re: Question about calculating RPM from encoder on: November 30, 2011, 04:42:43 pm
Quote
Right now, the only thing I could do is change to "double motor_speed = .1;" so that the encoder could read it.
This motor_speed?
Code:
  digitalWrite(STEP_PIN, motor_speed);
digitalWrite() accepts an int as the second argument. If you pass a double it will be truncated. So, any value less than 1.0 will become 0.0.

Using a variable named motor_speed with a digital pin is silly.

Quote
order number is 143984
OK, so it's an 84 to 1 reduction. So the output shaft is turning 1/84th the speed of the motor shaft.

Quote
Right now we have motor + gearbox + encoder combined from the maxon motor.
Well, yippee skippee. Still doesn't tell us anything. Where is the encoder in this mix? On the motor shaft or on the gearbox shaft? If necessary, take a picture!

Quote
Combined motor + gearbox + encoder, I get the 42000 pulses per revolution. 500 counts per turn but from the gear box ratio, I multiplied 500* 84 = 42000. Is this still wrong?
Depends. Where it the encoder? If if is on the motor, then there are 42000 pulses per turn of the gearbox output shaft. If it is on the gearbox output shaft, then there are 500 pulses per revolution of the gearbox shaft.

But, I think you are using the wrong hardware. A couple of linear actuators would be much easier to accurately position, and much faster.

33950  Using Arduino / Programming Questions / Re: How to output digital 5V from Arduino Uno on: November 30, 2011, 04:13:56 pm
You really, and I mean really, need to define what kind of 9V battery you are referring to.

If it is one of those rectangular 9V batteries, put it back in the smoke detector where it belongs, and get a real battery. 9V batteries put out practically no current - nothing like what is needed to make a motor go.
33951  Using Arduino / Programming Questions / Re: switch between soft and hard serial on: November 30, 2011, 04:03:39 pm
You need two constructors - one that takes a NewSoftSerial reference, and one that takes a HardwareSerial reference.

You class needs pointers - two of them - one for each type, and a flag that defines whether to use the NewSoftSerial pointer or the HardwareSerial pointer.

You need to use pointer notation, then, not instance notation.
33952  Using Arduino / Programming Questions / Re: Hex to decmail ASCII encoded on: November 30, 2011, 03:57:53 pm
Quote
Any chance anybody could give me a small snippet on how to get the content of the 8 bytes into the value 660000000?
First off, there need to be 9 bytes, including the terminating NULL;

Code:
char str[] = "2756CD00"; // Automatically NULL terminated
// (what you read from the serial port is not
char *junk;

long val = strtol(str, &junk, 16);

http://www.cplusplus.com/reference/clibrary/cstdlib/strtol/
33953  Using Arduino / Programming Questions / Re: Question about calculating RPM from encoder on: November 30, 2011, 03:51:00 pm
ISR = Interrupt service routine - in other words the function that is called when the interrupt occurs.

Look at the nominal speed column in your link (on page 1). Which specific motor do you have? The nominal speeds shown range from 7,300 RPM to 8,260 RPM. The no-load speeds go up to 12,100 RPM

Quote
and 84 is the ratio of the gear box
Up or down?

Quote
500 is from the encoder
Is the encoder on the motor or on the gearbox?

If you are getting 42,000 pulses per revolution, and turning 12,100 RPM, that's 8,400,000+ pulses per second. At 16Mhz, you'd have 2 clock cycles to call the interrupt, have it do it's thing, and return. The return alone takes one clock cycle.

There is just no way to keep up. If, on the other hand, the motor is turning 7,300 RPM, geared down 84 to 1, the output is about 87 RPM. If the encoder is on the output shaft, there are 43000+ pulses per minute, or ~7200 per second. That gives you more than 2000 clock cycles to deal with an interrupt.

So, you really need to define what RPM the motor is running at, how it is geared, and where the encoder is positioned. It makes the difference between difficult and impossible.

Interrupts really need to be disabled while you copy the values used to compute RPM, and then re-enabled before computing anything and before trying to print anything.

You also need to describe your overall project in more detail. There may be better motor choices or better means of stopping the motor with more precision. But, right now, all we have to go on is the minimal, conflicting information you are providing.
33954  Using Arduino / Programming Questions / Re: Inconsistency using strdup() on: November 30, 2011, 03:35:37 pm
Quote
I'm only really interested in knowing why there is the apparent glitch in the memory.
Because you are reading/writing beyond the bounds of your arrays, in many places.

Code:
  TRACELN(delim);

  char* pStr_  = strtok(dataIn,delim);
Both uses expect more than a 0 length array. But, that is what you are providing.

Code:
    TRACELN(*pStr_);
    TRACELN(*aCommands[field_]);
Why are you printing the pointer, rather than what is pointed to?
33955  Using Arduino / Programming Questions / Re: Array related class problem on: November 30, 2011, 12:56:02 pm
This statement references some element in the array:
Code:
  list[l];
It does nothing with the value in that array. It is NOT setting the size of the array.

You still have an array that can hold 0 elements.

Code:
  for(int i=0;i < l;i++){list[i] = rij[i];}
It is generally not a good idea to write more values to an array than the array can hold.

You either need to define some static sized array that defines an upper limit on the size of the array, or make list a pointer, and dynamically allocate space for the data (not necessarily advised, given how little memory the Arduino has).

You can not set the size of an array at run time the way you are trying to do it. Period.
33956  Using Arduino / Programming Questions / Re: Hex to decmail ASCII encoded on: November 30, 2011, 12:45:25 pm
Quote
The additional problem is that I have collected all these bytes seperately into an array.
Why is this a problem? The strtol() function expects a NULL terminated array of chars. That sounds like what you have (except that it isn't clear whether you are NULL terminating the array).
33957  Using Arduino / Programming Questions / Re: C++ code converting to Arduino on: November 30, 2011, 12:36:19 pm
If you really want help, you'll make your code readable. Modify your posts. Select the code, and press the # button to put the text in a scroll box.

Where are Latti and Long defined?

You have a lot of arrays, and very little memory. I'm going to guess that you are running out of memory.
33958  Using Arduino / Programming Questions / Re: Hex to decmail ASCII encoded on: November 30, 2011, 12:30:51 pm
Quote
The answer contains 4 bytes (so 8 ASII characters)
Wrong. If the answer is 4 bytes, that's 4 characters.

Is the "modulator" sending you a frequency as a hex string?

If so, the strtol() function will convert a string containing hex data to a long ("2756CD00" -> 660,000,000).

33959  Using Arduino / Programming Questions / Re: Loop question on: November 30, 2011, 12:24:20 pm
The Serial.print() function is for sending strings to the Serial Monitor (or other serial device). That string can be a literal:
Code:
Serial.println("The sensor is HIGH");
or created from a numeric value:
Code:
Serial.print("analog reading: ");
Serial.println(analogValue);
33960  Using Arduino / Programming Questions / Re: Inconsistency using strdup() on: November 30, 2011, 12:13:55 pm
Quote
The empty brackets are there to show that the object exists.  It is then defined properly in the constructor (of which there may be many different constructors in the future).
Wrong. Wrong. Wrong.

You can not, in the constructor, change the size of an array that is a member of a class.

Even if you could, where do you try?
Code:
Input::Input(){
  pBreaker_ = breaker_;
  pEquals_ = equals_;
  pnCommands_ = &nCommands_;
}

Get rid of the useless breaker_ and equals_ arrays. In the default constructor:
Code:
pBreaker = strdup(";");
pEquals = strdup("=");

(Lose those annoying _ on the end of every name, too.)

In other constructors, you can have something like this:
Code:
Input::Input(char *sepSetOne)
{
  pBreaker = sepSetOne;
  pEquals = strdup("=");
}

Input::Input(char *sepSetOne, char *sepSetTwo)
{
  pBreaker = sepSetOne;
  pEquals = sepSetTwo;
}
Pages: 1 ... 2262 2263 [2264] 2265 2266 ... 3361