Go Down

Topic: trouble with rs232 comunication (solved) (Read 972 times) previous topic - next topic

finthugo

Oct 15, 2012, 01:56 pm Last Edit: Oct 15, 2012, 04:39 pm by finthugo Reason: 1
I followed this arduino tutorial http://www.arduino.cc/en/Tutorial/ArduinoSoftwareRS232 exactly how it shows but the "hi" that should apear just apears a strange "number" (its not a number and its not a letter its something stange like ₢° and things like these) and when i type any letter on the keyboard it should send it for me back but it send another strange "number".

Anyone have any idea what it could be ?
Thanks all.

PaulS

Quote
Anyone have any idea what it could be ?

Could be a coding issue. Too bad you didn't post any code.

Could be an issue with the wiring. Too bad you didn't post a schematic.

Could be that the device that the Arduino is talking to isn't doing what you think it is. Too bad you didn't tell us what it is.

finthugo

#2
Oct 15, 2012, 02:18 pm Last Edit: Oct 15, 2012, 03:02 pm by AWOL Reason: 1
Well the schematic i cant post, because as you can see on the tutorial i have posted (http://www.arduino.cc/en/Tutorial/ArduinoSoftwareRS232) it does not show a schematic its just say "plug a capacitor between pin 1 and 3" and things like this, the code is that one:
Code: [Select]
#include <ctype.h>

#define bit9600Delay 84  
#define halfBit9600Delay 42
#define bit4800Delay 188
#define halfBit4800Delay 94

byte rx = 6;
byte tx = 7;
byte SWval;

void setup() {
 pinMode(rx,INPUT);
 pinMode(tx,OUTPUT);
 digitalWrite(tx,HIGH);
 digitalWrite(13,HIGH); //turn on debugging LED
 SWprint('h');  //debugging hello
 SWprint('i');
 SWprint(10); //carriage return
}

void SWprint(int data)
{
 byte mask;
 //startbit
 digitalWrite(tx,LOW);
 delayMicroseconds(bit9600Delay);
 for (mask = 0x01; mask>0; mask <<= 1) {
   if (data & mask){ // choose bit
    digitalWrite(tx,HIGH); // send 1
   }
   else{
    digitalWrite(tx,LOW); // send 0
   }
   delayMicroseconds(bit9600Delay);
 }
 //stop bit
 digitalWrite(tx, HIGH);
 delayMicroseconds(bit9600Delay);
}

int SWread()
{
 byte val = 0;
 while (digitalRead(rx));
 //wait for start bit
 if (digitalRead(rx) == LOW) {
   delayMicroseconds(halfBit9600Delay);
   for (int offset = 0; offset < 8; offset++) {
    delayMicroseconds(bit9600Delay);
    val |= digitalRead(rx) << offset;
   }
   //wait for stop bit + extra
   delayMicroseconds(bit9600Delay);
   delayMicroseconds(bit9600Delay);
   return val;
 }
}

void loop()
{
   SWval = SWread();
   SWprint(toupper(SWval));
}


But i do belive that the problem is in the "schematic" of this tutorial because i found some on the google and thats kinda diferent.

Moderator edit: Now with added Code Tagstm!

tuxduino

Quote
But i do belive that the problem is in the "schematic" of this tutorial because i found some on the google and thats kinda diferent.


And ?

Please post your schematic, what you've found "on the google" and how the two are "kida different".

PaulS

What are you trying to talk to? Why is that such a difficult question?

Go Up