Show Posts
Pages: 1 2 [3] 4 5 ... 17
31  Using Arduino / Programming Questions / Re: How to send numbers from one Arduino to another using Serial on: November 27, 2012, 08:09:31 am
This works beautifully thanks.

However if I have a set of extra data to also send via another serial port (Serial 3) to a device using a Bluetooth module, then I get missing data again.

So I receive the _rpm from first Arduino to my second Arduino Mega, then I send _rpm with 3 more data to Serial3 and receive these on my phone, the _rpm data is sometimes missing as before
32  Using Arduino / Programming Questions / Re: How to send numbers from one Arduino to another using Serial on: November 26, 2012, 04:11:36 pm
Quote
As PaulS said, you are printing _rpm before it arrives. That's why I made a function processNumber. You are supposed to print it from there, when it has totally arrived. Why are you changing a method that works, to one that doesn't?
That's what I thought initially. But, in processNumber, he's copying the value to _rpm, rather than printing it. Since processNumber doesn't get called until the > arrives, copying the value in processNumber should be OK.

Exactly, I print it after it has arrived and setting _rpm within processNumber.
33  Using Arduino / Programming Questions / Re: How to send numbers from one Arduino to another using Serial on: November 26, 2012, 11:52:04 am
When I do it this way:

Code:
const char startOfNumberDelimiter = '<';
const char endOfNumberDelimiter   = '>';

long _rpm = 0;


void setup ()
  {
  Serial.begin (115200);
  Serial2.begin (115200);
  Serial3.begin (115200);
 
   pinMode(8, INPUT); 
  } // end of setup
 
void processNumber (const long n)
  {
      Serial.println(n);
  }  // end of processNumber
 
void processInput ()
  {
  static long receivedNumber = 0;
  static boolean negative = false;
 
  byte c = Serial2.read ();
   
  switch (c)
    {
     
    case endOfNumberDelimiter: 
      if (negative)
        processNumber (- receivedNumber);
      else
        processNumber (receivedNumber);

    // fall through to start a new number
    case startOfNumberDelimiter:
      receivedNumber = 0;
      negative = false;
      break;
     
    case '0' ... '9':
      receivedNumber *= 10;
      receivedNumber += c - '0';

      break;
     
    case '-':
      negative = true;
      break;       
     
    } // end of switch 
  }  // end of processInput
 
void loop ()
  {
       

        if (Serial2.available ())
        {
          processInput ();
        }
 
  }

the output I get from the second Arduino on the Serial Monitor is correct. So when I send <8000> from the 1st Arduino I get 8000 on the Serial Monitor of the 2nd Arduino.

When I do send <8000> this way from the 1st Arduino however,

Code:
const char startOfNumberDelimiter = '<';
const char endOfNumberDelimiter   = '>';

long _rpm = 0;


void setup ()
  {
  Serial.begin (115200);
  Serial2.begin (115200);
  Serial3.begin (115200);
 
   pinMode(8, INPUT); 
  } // end of setup
 
void processNumber (const long n)
  {
     _rpm = n;
  }  // end of processNumber
 
void processInput ()
  {
  static long receivedNumber = 0;
  static boolean negative = false;
 
  byte c = Serial2.read ();
   
  switch (c)
    {
     
    case endOfNumberDelimiter: 
      if (negative)
        processNumber (- receivedNumber);
      else
        processNumber (receivedNumber);

    // fall through to start a new number
    case startOfNumberDelimiter:
      receivedNumber = 0;
      negative = false;
      break;
     
    case '0' ... '9':
      receivedNumber *= 10;
      receivedNumber += c - '0';

      break;
     
    case '-':
      negative = true;
      break;       
     
    } // end of switch 
  }  // end of processInput
 
void loop ()
  {
       

        if (Serial2.available ())
        {
          processInput ();
        }
                       
       Serial.println(_rpm);

  }


then I don't get the correct values, sometimes I get 800, sometimes 80 sometimes 8 etc.

Hope this is more clear.
34  Using Arduino / Programming Questions / Re: How to send numbers from one Arduino to another using Serial on: November 26, 2012, 11:22:26 am
When it's done the original way when I stream lets say the number 8000 it gets there as 8000. However when I use my code it's sometimes 800, sometimes 80 or even 8.

35  Using Arduino / Programming Questions / Re: How to send numbers from one Arduino to another using Serial on: November 26, 2012, 06:54:29 am
Sorry to bump up this thread:  I have used this and works pretty well.

I only send 1 piece of data from one Arduino to another. First Arduino gathers data and sends it to a second Arduino that received this piece of data. What I'd like to do is to set the received data to a variable. Then re-use it in my "Loop".

Code I am using in my receiving part is this, but doesn't work as expected:-

Code:

const char startOfNumberDelimiter = '<';
const char endOfNumberDelimiter   = '>';

long _r = 0;

void setup ()
  {
  Serial.begin (115200);
  Serial2.begin (115200);
  Serial3.begin (115200);
 
   pinMode(8, INPUT); 
  } // end of setup
 
void processNumber (const long n)
  {
      _r = n;

  }  // end of processNumber
 
void processInput ()
  {
  static long receivedNumber = 0;
  static boolean negative = false;
 
  byte c = Serial2.read ();
 
  switch (c)
    {
     
    case endOfNumberDelimiter: 
      if (negative)
        processNumber (- receivedNumber);
      else
        processNumber (receivedNumber);

    // fall through to start a new number
    case startOfNumberDelimiter:
      receivedNumber = 0;
      negative = false;
      break;
     
    case '0' ... '9':
      receivedNumber *= 10;
      receivedNumber += c - '0';
      break;
     
    case '-':
      negative = true;
      break;
     
    } // end of switch 
  }  // end of processInput
 
void loop ()
  {
       
        if (Serial2.available ())
        {
          processInput ();
        }
                       
        Serial.println(_r);
 
  }


Any help is appreciated.
36  Using Arduino / General Electronics / Re: Frequency Measurement Library Noise on: November 16, 2012, 01:26:49 pm
BUMP
37  Using Arduino / Project Guidance / Masking parts of an LCD with software on: October 12, 2012, 02:44:39 pm
Hi everyone.

I have a 7" LCD which has a VGA and a RCA input.

It's going to go to in my car eventually. The RCA input will be connected to a reverse camera. I need to make something up to go between the RCA input and the reverse camera to mask (in black) parts of this input. So when you get a square picture of whatever's behind your car, I need some of it to be masked in black.

Is there a device or way of doing this at all?

Thanks. 
38  Using Arduino / General Electronics / Re: Frequency Measurement Library Noise on: October 10, 2012, 06:18:34 am
Thanks again.

Another question while we're at it.

When connected to my car's speed signal, it measures the frequency spot on, however when var is stationary (zero speed) either it measures random values or nothing.

 Is there a way of measuring zero frequency?
39  Using Arduino / General Electronics / Re: Frequency Measurement Library Noise on: October 08, 2012, 01:04:37 pm
Worked like a charm. Thanks man!
40  Using Arduino / General Electronics / Re: Frequency Measurement Library Noise on: October 08, 2012, 11:46:58 am
The range of frequency I am trying to measure in from 0 to about 500 Hz.

@Docedison, unfortunately I have no idea what to do exactly. This pull up resistor, where does it need to go?

41  Using Arduino / General Electronics / Frequency Measurement Library Noise on: October 08, 2012, 09:42:02 am
Hi,

Currently I am making use of this library and circuit to measure the frequency:-
http://interface.khm.de/index.php/lab/experiments/frequency-measurement-library/

However when I put my hand close to the circuit, I get fluctuations from the frequency readings. So I'm guessing I introduce noise some how? How can this be solved?

Thanks.
42  Using Arduino / Project Guidance / Re: Expand flash memory on Arduino on: September 27, 2012, 02:09:21 pm
Arduino DUE looks good, but I can't wait for it to come out.
43  Using Arduino / Project Guidance / Re: Expand flash memory on Arduino on: September 27, 2012, 01:14:49 pm
Sorry about the mistake. That's what I thought, we might still be too slow.

We need the Arduino to measure various sensor values and sent to display.

Cannot be Android tablet as we may wanna output to different size LCDs from 7" to lets say 10".

Pi or similar would be good, but has to have a solid operating system so not to crash all the time. Also if this path is going to be taken, we need it to start up pretty fast (reason why we went with a micro-controller to start with). In addition, we don't want the users to see any start up text or GUI or anything. You turn the device on and bang it starts. Start up time can be 5-7 seconds though.

What you reckon?
44  Using Arduino / Project Guidance / Re: Expand flash memory on Arduino on: September 27, 2012, 12:45:53 pm
Library doesn't work with 115200 bps for some reason.
45  Using Arduino / Project Guidance / Re: Expand flash memory on Arduino on: September 27, 2012, 11:20:49 am
Yes I'm dumping graphics from the uSD.

When I wanna show an image and I call it, it gets drawn fro the top to the bottom and takes probably ~1 second for it to draw, need a faster time than that.



You have 300,000 pixels and write at 3840 bytes per second. I'm surprised you get it done in 1 seconds. I was expecting 10 seconds. You must be writing jpeg at large loss rate, but still the display itself is too slow than anything raw at more than 1 frame a second due to its serial connection. You want something fast, you need 8-16 or 32 bit wide bus at high speed.

Do you think it's the Arduino that's slow and not the actual 4DS module? Not that the images are stored on the uSD car on the module.
Pages: 1 2 [3] 4 5 ... 17