Show Posts
Pages: 1 ... 2249 2250 [2251] 2252 2253 ... 3072
33751  Using Arduino / Programming Questions / Re: Tachometer Accuracy using millis ? on: July 08, 2011, 11:42:12 am
Quote
try something like this ...
Code:
  if (millis() - time >= 250)
  {
    // get the exact millis;
    long t = millis() - time;

    // calc the rotations per second
    long rps = (250 * tachCount)/t;

    time = millis();
I'd prefer to see millis() called just once.
Code:
  unsigned long now = millis();
  if(now - then >= 250)
  {
     unsigned long interval = now - then;
     long rps = ...

     then = now;

Also, I'd like to see you get rid of the magic numbers.
#define TIMING 250
if(now - then >= TIMING)
This makes it easier to change the timing period to 100 milliseconds, or 500 milliseconds.
33752  Using Arduino / Project Guidance / Re: Making an Arduino-based Vehicle Data Acquisition (DAQ) module on: July 08, 2011, 11:15:43 am
In your project, the opening and closing the file will consume a significant portion of the cycle of opening a file. writing a record to it, and closing the file.

Buffering the data for some time, then opening the file, writing all the records, and closing the file will result in significantly more data being written per unit of time.

How often to actually open/close the file depends on how much data you write per record (i.e. how much data you must buffer for each write cycle.

You could open the file once every 10 seconds, write to it without buffering (much), and close it again. This way, the most data you would lose is that which was written after the last close/open.

You haven't said how much data is in each record, so definitive answers aren't possible.
33753  Using Arduino / Networking, Protocols, and Devices / Re: Serial Communication between 2 mega on: July 08, 2011, 11:05:21 am
Quote
I am currently trying to communicate between two mega over Serial2 (HardwareSerial).  Code is pretty basic. I am sending 2000 times 17 bytes.
In what period of tome? A week? A day? An hour? A second?

Quote
However, I am always not getting the full 2000 * 17 bytes on the other end.  Is it something I should expect at such a slow baud rate or I have other problem?
The printing of the received data takes time. Depending on the speed that you print at, it could be causing the receive buffer to overflow, since more data is coming in than can be handled.

Try dropping the number of characters send out. Instead of "I received: ", use "In:"
33754  Using Arduino / Programming Questions / Re: Passing arrays to a function on: July 08, 2011, 01:23:58 am
Quote
But if the function is just, say, adding all the elements of that array and returning the result, that's no problem, right?
If the function is not (supposed) to alter the array, the argument should be declared const, so the compiler will complain if you do actually try to write to some position in the array.
33755  Using Arduino / Programming Questions / Re: Passing arrays to a function on: July 08, 2011, 01:22:36 am
The sizeof() function does not care about the contents of an array, so it returns the size of the array.

The strlen() function, on the other hand, will return the position of the first NULL in a char array.
33756  Using Arduino / Programming Questions / Re: Control servo via serial on: July 08, 2011, 01:19:34 am
Send what hex command where?

Perhaps the Arduino could control a couple of servos to move a pen around and write the hex command on a piece of paper. Then, it could push the paper into a folder, and address an envelope, and put the folded paper in the envelope, add a stamp, and drop it in the mailbox.

Nah, too many servos needed...
33757  Using Arduino / Programming Questions / Re: Servo speed control - newbie needs help on: July 08, 2011, 01:14:53 am
This:
Code:
    for (hposval = 0; hposval <= 90; hposval +=1); // turn back to centre
is equivalent to:
Code:
    for (hposval = 0; hposval <= 90; hposval +=1)
{
  ;
}
As you can see, your for loop doesn't do diddly.

Lose the ; on the end, and put the statements that constitute the body of the loop in { and }, even if it is only one statement.
33758  Using Arduino / Programming Questions / Re: noob motor control on: July 08, 2011, 01:10:38 am
What kind of motor controller board are you using? Typically, a motor controller can do more than turn the motor off or on. It can also vary the speed of the motors.

Since the joystick outputs varying values depending on how far it is pushed or pulled, you can use the analog value read to control the speed of the motors.

First, learn how to connect the joystick, and read the various values as you move the stick around. When you can do that, use the map function to map the joystick values from their range of values to the range of values that the PWM pins that the motor controller are connected to expects. Then, send the map() output to the PWM pin, with the enable pin set appropriately (to go forward or backwards at different speeds).
33759  Using Arduino / Programming Questions / Re: ~./P_rfid.cpp:19: error: ‘P_rfid’ has not been declared on: July 08, 2011, 12:51:57 am
Typically, the source code needs to include the header file. Yours doesn't. Without it, the compiler has no idea that P_rfid is a class, or that P_rfid:smiley-razz_rfid() is a constructor.

Why does the begin() method take an argument that is not used?

The available() method should return the number of bytes available, not true or false. The timeout function will not do what it appears that you think it will, unless you plan on calling it with a very, very large number.

What kind of type is unit_8? I've heard of uint_8 (unsigned int, 8 bits), but not unit_8 or unit_16.
33760  Using Arduino / Programming Questions / Re: programming on: July 08, 2011, 12:46:47 am
Why is this a poll?

Did you have a question? There are plenty of comments in the code.
33761  Using Arduino / Programming Questions / Re: newsoftserial query on: July 08, 2011, 12:44:04 am
Besides pins 7 and 8, what other pins are connected? Specifically, are the grounds connected?
33762  Using Arduino / Project Guidance / Re: Newbie |Howto - Controlling a model on: July 07, 2011, 12:34:17 pm
Quote
updated my post as requested !
Adding a picture is not the same as adding a link. With a link, we can go find the data sheet of the product, and see if there is a way to help you. With a picture, we can say "Oh, how cute!". Your choice.
33763  Using Arduino / Project Guidance / Re: Connecting 2 Duemilanove over Serial Port? on: July 07, 2011, 12:30:36 pm
Quote
However, what I wanted to happen didn't happen.
That's a shame.

Now, if you were to describe which code you ran on each Arduino, what you expected to happen, and what actually did happen, we could offer more constructive responses.
33764  Using Arduino / Project Guidance / Re: Connecting 2 Duemilanove over Serial Port? on: July 07, 2011, 12:12:49 pm
Quote
Pretty much, I've been using this http://www.arduino.cc/en/Tutorial/MasterReader
Stick with one thing until you get it working/understand it.

Quote
But, I'm mainly unsure of which wires to use to connect up.
There is a schematic on that site that looks almost like a picture. How can you look at that and not know?

There's even code on that page to prove that it works.
33765  Using Arduino / Interfacing w/ Software on the Computer / Re: Converting Incoming Serial Data to a String on: July 07, 2011, 11:41:07 am
A string in C/C++ is a NULL terminated array of characters. A NULL in any position in the array terminates the array.

Calling that function sets the index to 0, writes in the 0th position, and puts a NULL in the 1st position.

You shouldn't need to initialize the array before calling that function again. If you have some other need, though, simply put a NULL ('\0') in array[0].
Pages: 1 ... 2249 2250 [2251] 2252 2253 ... 3072