I have GPS, SONAR and two BLDC motors connected. I have to send data to my PC. I have radio-link. How can I send this data?

Thread Starter

umerrai1

Joined Mar 29, 2021
246
Sir, the reason behind using the 4800 baud rate is this I cannot increase the baud rate of my echosounder. so I set all of my devices to 4800.
I do not want to display all the GPS messages. I can block GPS messages which I don't need. But the requirement is to display a GPS message whenever I get an Echosounder message.
 

ericgibbs

Joined Jan 29, 2010
18,872
hi ume,
OK,
The problem with displaying a GPS message when a echo sounder message is received, is that the sounder is usually running at 10 soundings per second,,, the GPS messages only update every 1 second.

What is your sounder output rate.? & data Format.
I will try to program a demo Sketch.


E
BTW: For interest ONLY checkout this .ino program.
 

Attachments

Thread Starter

umerrai1

Joined Mar 29, 2021
246
I am facing one problem. Whenever I add my motor data message to the serial monitor display, all my messages get distorted. As shown in the picture the message starting with Kordil is my Motor message. But it always changes. My GPS and Echo sounder messages are set to 2Hz.
 

Attachments

ericgibbs

Joined Jan 29, 2010
18,872
hi,
Images shows that I get the same problem as you, will try to fix , if possible

Why have you declared this Serial block twice>
I have added 'int BaudRate=9600;' so that we can switch easily fro 4800 to 9600.


void setup()
{
Serial.begin(BaudRate); // user local
Serial1.begin(BaudRate); // gps sensor port
Serial2.begin(BaudRate); // dep sensor port
ESC_1.attach(m_1); // (pin, min pulse width, max pulse width in microseconds)
ESC_2.attach(m_2); // (pin, min pulse width, max pulse width in microseconds)
pinMode(LED, OUTPUT);

Serial.println("$Kordil System Started");
ESC_1.writeMicroseconds(APwm);
ESC_2.writeMicroseconds(BPwm);
Serial.begin(BaudRate); // user local
Serial1.begin(BaudRate); // gps sensor port
Serial2.begin(BaudRate); // dep sensor port
GPSmessage.reserve(100); // reserve 100 bytes for the GPSmessage:

}
 

Attachments

ericgibbs

Joined Jan 29, 2010
18,872
hi,
A Serial Event means that the program, as soon as it gets a Serial character into its Input buffer from an external source, will start reading the external input String and storing it in the serial buffer, until an end of line code is detected CR or LF.

In the main Void Loop, the program will execute the other program code and as it does so, it will check 'if string complete'.
If the string complete is True [EOL] it will print that String in its buffer and the buffer will be cleared.

If you make the Serial Event also under program control with say a Print command, as the Print and Serial Event are asynchronous, so you could make a Print Call in the middle of a Serial Event cycle, this will most likely cause corruption to the message string.

Post the section of program code that is causing you a problem.

E
 

Thread Starter

umerrai1

Joined Mar 29, 2021
246
Here I used it. The problem I am facing is when I put the print command here I am getting my messages in synchronized form. But when I add these commands in loop structure it is not giving me results in synchronized form. The complete program is also attached with this message.

void serialEvent2() {
while (Serial2.available()) {
char depChar = (char)Serial2.read();
DEPmessage += depChar;
if (depChar == '\r')
{
depEOL = true;
}
if ((msgEOL == true) && (depEOL == true))
{
Serial.print(DEPmessage);
DEPmessage = "";
Serial.print(GPSmessage);
GPSmessage = "";
Serial.print(Broadcast);
Broadcast = "";
}
}
}
 

Attachments

ericgibbs

Joined Jan 29, 2010
18,872
hi ume,
The program coding and layout is unworkable.
Do you have a Flow Chart for this project that I could see.??

If one does not exist, I would strongly recommend that you and your client create a Flow Chart, else your project development problems will never end.

From that I should be able to suggest a suitable outline program.

If you ever go into business for yourself, NEVER accept a contract that does not have a clearly documented and agreed specification.

E
 

Ya’akov

Joined Jan 27, 2019
9,170
hi ume,
The program coding and layout is unworkable.
Do you have a Flow Chart for this project that I could see.??

If one does not exist, I would strongly recommend that you and your client create a Flow Chart, else your project development problems will never end.

From that I should be able to suggest a suitable outline program.

If you ever go into business for yourself, NEVER accept a contract that does not have a clearly documented and agreed specification.

E
You can never succeed if there is no definition for success.
 

Ya’akov

Joined Jan 27, 2019
9,170
I only ever made the mistake once, in accepting a verbal specification from a client, lost money on that project.
Behavioral scientists call that “one trial learning”. You see it in animals that get sick after eating something… I suppose there is an analogy there.
 

Thread Starter

umerrai1

Joined Mar 29, 2021
246
Today my Boss is too much angry with the workers so tomorrow I will get a complete working plan that what we have to do.
I am really feeling the effect of your messages on my brain. I am sorry for disturbing you again and again but on the other hand, I am learning a lot from you. I was zero in programming when I first posted here. but now I can understand a programming little bit.
 
Top