Show Posts
Pages: 1 2 [3] 4 5 ... 19
31  Using Arduino / Programming Questions / Re: integer save into single bytes on: March 23, 2012, 08:39:18 am
ok sorry did not ask the right way.

I got the number stored in a long variable eb.
long test = 150216;

and now how can I add an L...
32  Using Arduino / Programming Questions / Re: integer save into single bytes on: March 23, 2012, 08:25:38 am
Hi,
another solution is defining a union:

Code:
union Number
{
  long num;
  byte barray[4];
  
} NN;

then set the long field and get the byte array:

Code:
 NN.num = 123466L;
  byte b0 = NN.data[0];
  byte b1 = NN.data[1];
  byte b2 = NN.data[2];
  byte b3 = NN.data[3];



Hmm I thought I'm not that stupid but can you help me to implement this.
What is in the data array?


EDIT:
Ok found something I cahnged the code to:
Code:
union Number
  {
    long num;
    byte barray[4];
  }
  NN;

  NN.num = 115730L;
  byte b0 = NN.barray[0];
  byte b1 = NN.barray[1];
  byte b2 = NN.barray[2];
  byte b3 = NN.barray[3];

Now it is working perfectly but how can I ad an 'L' to a long integer?

Thx
Andy
33  Using Arduino / Project Guidance / Re: Need advise to simulate GPS data on: March 23, 2012, 06:05:37 am
thats true so sprintf() would be fast enough?

34  Using Arduino / Programming Questions / integer save into single bytes on: March 23, 2012, 06:05:03 am
Hy

I'm right now trying to convert an Integer ex. 115730 into
a 4 byte array.
So I tryed this but it doesn't work...
Code:
long number = 115730:
data[0] = (byte)(number >> 24);
data[1] = (byte)(number >> 16);
data[2] = (byte)(number >> 8);
data[3] = (byte)(number);

Can someone help me, it might be just a little mistake but where....
Andy

35  Using Arduino / General Electronics / Re: MAX232 and FTDI and Arduino on: March 23, 2012, 02:10:28 am
yes, finally got it working, thx for all your help!!!! Great now I can work on the code smiley

Thx to all of you!!!
Andy
36  Using Arduino / Project Guidance / Need advise to simulate GPS data on: March 23, 2012, 02:09:17 am
Hy

I do receive with my Arduino different values which represent altitude, time , log, lat etc.
I collect them all and send it through the serial port back but in the NMEA format.
I store all vlaues in integer and now I need to put them together with checksum
to send it through serial port:

Example:

time = 191410
lat = 47355634
lon = 7393538
etc

=> $GPRMC,191410,A,4735.5634,N,00739.3538,E,0.0,0.0,181102,0.4,E,A*19

How can I achieve this the fastest way?

Thx
Andy
37  Using Arduino / General Electronics / Re: MAX232 and FTDI and Arduino on: March 22, 2012, 05:54:50 pm
Ok thx for the answer.
So maybe something like this would help?
http://www.cutedigi.com/pub/Arduino/arduino_RS232.pdf
38  Using Arduino / General Electronics / Re: MAX232 and FTDI and Arduino on: March 22, 2012, 05:37:36 pm
but since I probably need to use a 2621 baud rate and not 2400 I can't set that with my terminal programs eg. zoc, hterm, x-ctu
Yes with the Arduino it might be possible but since I like to test it first with the Sparkfun Break out board I need another
terminal program.

Still no one could answer me why the Serial to USB cable mentioned does work and the Sparkfun don't...

Thx
Andy
39  Using Arduino / General Electronics / Re: MAX232 and FTDI and Arduino on: March 22, 2012, 03:13:12 pm
hmm ok so is their a terminal program where I can choose baud rates that are not exact as the known one?
But why is the Serial to USB cable working?

Thx
Andy
40  Using Arduino / General Electronics / Re: MAX232 and FTDI and Arduino on: March 22, 2012, 02:27:43 pm
The buffer those fill up quite fast in 3 seconds 128byte are full however
since it does not work with the Sparkfun Break out board it must be something different....

Thx
Andy
41  Using Arduino / General Electronics / MAX232 and FTDI and Arduino on: March 22, 2012, 01:55:15 pm
Hy

I got a problem with a MAX232.
So I got a circuit that is decoding a FSK signal and converting it with a MAX232 so that I can read
it with a Serial Monitor Programm on a PC.
For my Laptop I use a Serial to USB cable to hook it up to an USB port:
http://www.frontierpc.com/cables-adapters/connector-cables/misc/products/iogear-usb-pda-serial-adapter-guc232a-10033386.html
This works without a problem.

So now I would like to use the Signal coming from the MAX232 directly with an Arduino. This should be possible by just connection it
to the UART (Pin 0) to receive the Signal. However I do receive something with my Arduino UNO but with the Arduino Mega the port is silent.
With the UNO a lot (all) of the bytes get lost or are corrupted so you can't read the signal it is strange.

The same is true when I use a FTDI Basic Breakout board from Sparkfun. I can read the Signal with my computer but it is not usable for further decoding.

So why is this do I need some filters? Why is it working with the Serial to USB cable?

Thx for your Help,
Andy
42  International / Deutsch / Re: Sensor an der I2C Schnittstelle on: March 22, 2012, 02:55:24 am
uuppps Ich *!*?# ok so ich habs smiley

Code:
byte decToBcd(byte val){
  return ( (val/10*16) + (val%10) );
}

byte bcdToDec(byte val){
  return ( (val/16*10) + (val%16) );
}


void adresseAendern(){
  //Sensor starten
  digitalWrite(13, HIGH);
  delay(2);

  //in Command Mode
  Wire.beginTransmission(adress);
  Wire.send(0xA0);
  Wire.send(0x00);
  Wire.send(0x00);
  Wire.endTransmission();
  delay(100);

  //Adress anfragen
  Wire.beginTransmission(adress);
  Wire.send(0x1C);
  Wire.send(0x00);
  Wire.send(0x00);
  Wire.endTransmission();
  delay(100);

  //Adresse auslesen
  Wire.requestFrom(adress, 3);
  if(Wire.available() > 2){
    byte b1 = bcdToDec(Wire.receive());
    byte b2 = bcdToDec(Wire.receive());
    byte b3 = bcdToDec(Wire.receive());
    /*
    Serial.println((b1), DEC);
     Serial.println((b2), DEC);
     Serial.println((b3), DEC);
     */
    int i2cAdress = b2 << 8 | b3;
    Serial.println((i2cAdress));
  }
  

  //Adress neu setzten
  Wire.beginTransmission(adress);
  Wire.send(0x5C);
  Wire.send(0x00);
  Wire.send(adressNew);
  Wire.endTransmission();
  delay(100);


  //normal Mode
  digitalWrite(13, LOW);
  delay(100);

}
43  International / Deutsch / Re: Sensor an der I2C Schnittstelle on: March 22, 2012, 02:43:34 am
Das ist eine gute Idee, hat irgendwie auch funktioniert denn im Command Mode kann man ja keine Feuchte und Temp auslesen was mir zeigt dass ich im Command Mode drinn bin aber das Auslesen klappt nicht sprich ich verstehe nicht wie ich nun an die Adresse komme.
Hier wäre der Code den ich verwende...

Code:
//Sensor starten
  digitalWrite(13, HIGH);
  delay(2);

  //in Command Mode
  Wire.beginTransmission(adress);
  Wire.send(0xA0);
  Wire.send(0x00);
  Wire.send(0x00);
  Wire.endTransmission();
  delay(100);

  //Adress anfragen
  Wire.beginTransmission(adress);
  Wire.send(0x1C);
  Wire.send(0x00);
  Wire.send(0x00);
  Wire.endTransmission();
  delay(100);

  //Adresse auslesen
  Wire.requestFrom(adress, 3);
  if(Wire.available() > 2){
    int b1 = Wire.receive();
    int b2 = Wire.receive();
    int b3 = Wire.receive();
    Serial.println((b1));
    Serial.println((b2));
    Serial.println((b3));

    int i2cAdress = b2 << 8 | b3;
    Serial.println((i2cAdress));
  }
 
44  International / Deutsch / Re: Sensor an der I2C Schnittstelle on: March 21, 2012, 03:52:41 pm
oops habe das Falsche Dokument hochgeladen dort steht es nicht drinn... sorry

Es ist ein HYT 271 (DIGITALER FEUCHTESENSOR)

45  International / Deutsch / Re: Sensor an der I2C Schnittstelle on: March 21, 2012, 03:23:07 pm
Hmm naja ich weiss im Moment nicht wie ich den Snesor reseten kann um dann direkt in den Command mode zu gelangen....
Kann ein Reset auch per Command genügen denn anders kann ich es mir nich vorstellen....
Pages: 1 2 [3] 4 5 ... 19