Go Down

Topic: Inserting Start bit and Stop Bit in a serial communicatiom (Read 24132 times) previous topic - next topic

PaulS

Quote
i am sending data from one serial monitor to an other using PLC module and arduino.

Over noisy electrical power lines? And, you get noise. I'm shocked. Absolutely shocked, I tell you.

Since it appears that what you send does actually make it across, unmolested and continuous, though mixed in with the noise. The usual solution is to use specific start and end of packet markers to delimit the data. If you send "<Here is some data>", instead of "Here is some data", you have away of determining where data vs noise happens.
The art of getting good answers lies in asking good questions.

Robin2

I think the problem here is the use of language.

What you want is not start and stop BITS but start and stop BYTES

This demo of communicating with a PC shows how to use <  and  > as start- and end-markers. It assumes you only want to send (or receive) readable characters not including either < or >. This is the same concept as @PaulS has mentioned.

If you need to be able to send every possible byte value the code at the start of the same Thread demonstrates a way to do that.

You may also (I hope) have noticed that it is a good idea to check the Forum regularly so as to answer any questions as soon as possible.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

steinie44

OK, it's PLC witch is worse then wireless. Use PaulS example. Also put the  Serial.print(a); inside the if statement. Then you won't see the garbage.
Code: [Select]

if(Serial1.available())
  {
    char a=Serial1.read();
    if(a=='A')
    {
      digitalWrite(13, HIGH);
    }
   
    if(a=='a')
    {
      digitalWrite(13, LOW);
    }
    Serial.print(a);
   
  }


Code: [Select]

if(Serial1.available())
  {
    char a=Serial1.read();
    if(a=='A')
    {
      digitalWrite(13, HIGH);
      Serial.print(a);
    }
   
    if(a=='a')
    {
      digitalWrite(13, LOW);
       Serial.print(a);
    }
   
  }

AWOL

'a' and 'A' differ only by a single bit - in a noisy environment, that leaves scope for misinterpretation due to corruption by noise.

surajveer37

i am trying to google it since many days.. can't come up with anything yet!

PaulS

Quote
i am trying to google it

I googled "it" and got bazillions of hits. Perhaps you need to be a bit clearer on what you are trying to google, and why.
The art of getting good answers lies in asking good questions.

surajveer37

well @Paul are you trying to say that i should try to send the data inside of these signs "< >" from my serial monitor?  and that's it?

surajveer37

@steinie, well thank you :) i will make these changes and will see if there is any improvement or not ! will let you know :)

PaulS

Quote
well @Paul are you trying to say that i should try to send the data inside of these signs "< >" from my serial monitor?  and that's it?

Or have the Arduino collect all the data from the serial monitor application, and then add them before sending the data out.

I'm confused, now. Is the Arduino sending data to the PLC that is having problems understanding it? Or, is the PLC sending data that the Arduino is having a hard time understanding?
The art of getting good answers lies in asking good questions.

surajveer37

I think it is due to  the medium (AC POWER LINES) that we are not getting the exact data over the serial monitor!

Grumpy_Mike

#25
Sep 24, 2014, 06:32 pm Last Edit: Sep 24, 2014, 06:34 pm by Grumpy_Mike Reason: 1
So what are you doing to modulate the serial data so you can send it over the power lines?

It sounds like a problem with your demodulator rather than anything on the signal.

The phrase:-
Quote
I am working on a Power line Communications.

and
Quote
I am actually a beginner!

do not sit well together.

surajveer37

i am using a KQ330 PLC module at both transmitting and receiving ends that are working as a modulator and demodulator and since it is a built in device , i dun think there is any fault in the demodulation!

Grumpy_Mike

Quote
i am using a KQ330 PLC module

Can you post a link to the data sheet I can't find one.

surajveer37

here it is
http://digipak.org/zencart/index.php?main_page=product_info&cPath=4&products_id=212

Robin2


here it is


It would have been nice if you had provided that link in your first post.

Do you have a link to a datasheet for the product?

My sense is that that module does a lot of signal conditioning. It mentions 120-135kHz and also "the true baud rate is 100bps"

I have absolutely no idea where you got the idea that you need to add start or stop bits or bytes. It would still be helpful if you can explain that so I understand your thought process.

It seems to have regular TTL Rx and Tx pins and it says it interfaces at 9600 baud.

So what happens with simple code that sends a byte at 9600 baud at one end and listens for a byte at 9600 baud at the other end?

I reckon if simple serial sending and receiving does not work the problem is in the power line device and not in the Arduino.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Go Up