Show Posts
Pages: [1] 2 3 ... 10
1  Using Arduino / Networking, Protocols, and Devices / Re: Serial Problems on: February 19, 2012, 11:00:03 am
the wire can't send a char string but only a byte string
and Serial can't buffer on a byte string but on a char

what else can i do?
2  Using Arduino / Networking, Protocols, and Devices / Re: Serial Problems on: February 19, 2012, 09:45:31 am
i changed the programm

so the slave always updates the OS4000Data

Code:
void loop()
{
  if (command == 'P')
  {
    digitalWrite(3,HIGH);
    command = 'N';
  }
  else if (command == 'p')
  {
    digitalWrite(3,LOW);
    command = 'N';
  }
  else if (command == 'R')
  {
    Serial.write(27);
    delay(20);
    Serial.print("R");
    delay(20);
    CommandLow = Wire.read();
    CommandHigh = Wire.read();
    Command = ( ( (int)CommandLow<<8 ) | ( (int)CommandHigh ) ); 
    Serial.print(Command);
    Serial.write(13);
    command = 'N';
  }
  Capture_OS4000();
}

void  Capture_OS4000()
{
  while ( Serial.read () != '$' );
  BytesRead = Serial.readBytesUntil('*',SerialBuffer,127);
  for(Position=(BytesRead+1); Position<128; Position++)
  {
    SerialBuffer[Position] = B0;
  }
  for(Position=0; Position<128; Position++)
  {
    OS4000Data[Position] = SerialBuffer[Position];
  }
}

void requestEvent()
{
  Wire.write (OS4000Data, 127); 
}



and the master

Code:
void Read_Data()
{
  Wire.beginTransmission(2);
  Wire.requestFrom(2,127);
  Wire.endTransmission();
  for ( int i=0; i<128; i++ ) Serial.write(Wire.read());
  Serial.println("");
}

and its working

but how i will make to only do that

Code:
  Wire.write (OS4000Data, 127); 

if that is completed

Code:
  for(Position=0; Position<128; Position++)
  {
    OS4000Data[Position] = SerialBuffer[Position];
  }

????
3  Using Arduino / Networking, Protocols, and Devices / Serial Problems on: February 19, 2012, 04:19:56 am
Hallo

i have a compass that outputs uart data like that

Quote
$OHPR,21.2,2.3,-2.5,14.2,0.0000,370.48,-298.50,126.78,179.10,1.003,0.040,-0.043,1.002,-0.01*0C
$OHPR,21.2,2.3,-2.5,14.2,0.0000,370.47,-298.50,126.79,179.06,1.003,0.040,-0.043,1.002,-0.01*05

and i wrote this programm to capture them


Code:
 
while ( Serial.read () != '$' );
  BytesRead = Serial.readBytesUntil('*',SerialBuffer,127);
  for(Position=(BytesRead+1); Position<128; Position++)
  {
    SerialBuffer[Position] = B0;
  }
  for(Position=0; Position<128; Position++)
  {
    OS4000Data[Position] = SerialBuffer[Position];
  }

that works great

but when i copy the above to a bigger scetch

like that

Code:
void setup()
{
  pinMode(3,OUTPUT);
  digitalWrite(3,HIGH);

  Serial.begin(UartBaudRate); 
  Wire.begin(I2C_Address); 
  Wire.onRequest(requestEvent);
  Wire.onReceive(ReceiveCommand);
}


void loop()
{
  if (command == 'H')
  {
    command = 'N';
    Capture_OS4000();
  }
  else if (command == 'P')
  {
    digitalWrite(3,HIGH);
    command = 'N';
  }
  else if (command == 'p')
  {
    digitalWrite(3,LOW);
    command = 'N';
  }
  else if (command == 'R')
  {
    Serial.write(27);
    delay(20);
    Serial.print("R");
    delay(20);
    CommandLow = Wire.read();
    CommandHigh = Wire.read();
    Command = ( ( (int)CommandLow<<8 ) | ( (int)CommandHigh ) ); 
    Serial.print(Command);
    Serial.write(13);
    command = 'N';
  }
}


void  Capture_OS4000()
{
  while ( Serial.read () != '$' );
  BytesRead = Serial.readBytesUntil('*',SerialBuffer,127);
  for(Position=(BytesRead+1); Position<128; Position++)
  {
    SerialBuffer[Position] = B0;
  }
  for(Position=0; Position<128; Position++)
  {
    OS4000Data[Position] = SerialBuffer[Position];
  }
}

void ReceiveCommand(int howMany)
{
  command = Wire.read();
}

void requestEvent()
{
  Wire.write (OS4000Data, 127); 
}



then the output is like that

Quote
OHPR,21.2,2.3,-2.4,14.6,0.0000,371.$OHPR,21.3,2.3,-2.4,14.6,0.0000,370.59,-298.45,126.93,179.31,1.003,0.041,-0.042,1.002,-0.01.ÿ
OHPR,21.2,2.3,-2.5,14.6,0.0000,370.40,-298.41,126.96,178.9$OHPR,21.2,2.3,-2.5,14.6,0.0000,371.01,-298.50,127.11,179.97,1.003,0.ÿ
OHPR,21.2,2.3,-2.5,14.6,0.0000,371.$OHPR,21.2,2.3,-2.5,14.6,0.0000,370.70,-298.69,126.98,179.11,1.003,0.041,-0.045,1.001,-0.01.ÿ
OHPR,21.2,2.3,-2.5,14.6,0.0000,370.76,-298.72,126.99,179.1$OHPR,21.2,2.3,-2.5,14.6,0.0000,371.11,-298.72,127.07,179.84,1.003,0.ÿ
OHPR,21.2,2.3,-2.5,14.6,0.0000,371.$OHPR,21.2,2.3,-2.5,14.6,0.0000,370.66,-298.63,127.00,179.10,1.003,0.041,-0.043,1.001,-0.01.ÿ
OHPR,21.2,2.3,-2.5,14.6,0.0000,370.73,-298.65,127.01,179.2.4,14.6,0.0000,371.15,-298.74,127.02,179.92,1.003,0.041,-0.042,1.001,ÿ


where i am wrong

thanks a lot
4  Using Arduino / Networking, Protocols, and Devices / Re: I2C read problems on: February 18, 2012, 01:11:09 pm
i made it

i re-downloded the arduino 1.0
unzip it in dekstop
change the files in dekstop
and then replace it in Programm files

thanks a lot
5  Using Arduino / Networking, Protocols, and Devices / Re: Serial.available() buffer reduced ?? on: February 18, 2012, 05:01:28 am
Quote
while( Serial.available() < 127 );
Why are you not reading and storing the data as soon as it is available? What benefit is obtained by waiting until there is a truckload of data to process?

because then i want to send them over I2C

and because I2C is faster than Uart its not working
6  Using Arduino / Networking, Protocols, and Devices / Re: I2C read problems on: February 18, 2012, 04:59:02 am
i dont have a logic analyzer yet

can you please send me your files to test

thanks a lot
7  Using Arduino / Networking, Protocols, and Devices / Re: I2C read problems on: February 17, 2012, 05:04:26 pm
and from an arduino uno board
8  Using Arduino / Networking, Protocols, and Devices / Re: I2C read problems on: February 17, 2012, 05:00:28 pm
also i get the same output from an atmega1280 at 16Mhz
9  Using Arduino / Networking, Protocols, and Devices / Re: I2C read problems on: February 17, 2012, 04:58:00 pm
Code:
#include <Wire.h>

void setup ()
  {
  Wire.begin ();
  }

void loop () 
  {
  Wire.beginTransmission (25);
  Wire.write ("AbcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789000987654321");
  Wire.endTransmission ();
  delay (1000);
  }

on the 8Mhz board

10  Using Arduino / Networking, Protocols, and Devices / Re: I2C read problems on: February 17, 2012, 04:18:18 pm


and after a while

11  Using Arduino / Networking, Protocols, and Devices / Re: I2C read problems on: February 17, 2012, 04:10:03 pm
also the slave is a custom board
and i am using Arduino Pro at 8Mhz because Atmega328 on a breadboard isnt working any more on Arduino 1.0

12  Using Arduino / Networking, Protocols, and Devices / Re: I2C read problems on: February 17, 2012, 04:00:35 pm
give me 4minutes
13  Using Arduino / Networking, Protocols, and Devices / Re: I2C read problems on: February 17, 2012, 03:30:36 pm
as before i changed the

#define BUFFER_LENGTH 128

into wire.h

and

  #define TWI_BUFFER_LENGTH 128

into twi.h

from 32 to 128
14  Using Arduino / Networking, Protocols, and Devices / Re: I2C read problems on: February 17, 2012, 03:04:29 pm
if you make it work can you send me the files please
because I edit it with wordpad

thanks a lot
15  Using Arduino / Networking, Protocols, and Devices / Re: I2C read problems on: February 17, 2012, 03:22:08 am
yes in these folders
Pages: [1] 2 3 ... 10