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?

ericgibbs

Joined Jan 29, 2010
12,922
hi ume,
It is common practice in most equipment to provide the user with a Baud rate selection option, the common rates are
1200,2400,4800, 9600...

What we would like from you is a block diagram of the complete project, ie: what is connected what.?

E
 

ericgibbs

Joined Jan 29, 2010
12,922
hi ume,
This is a print out of the results of synchronising the RTC with the Arduino millis function.
I am using a DS3231 RTC [ do not have a DS1307] , the Sketch should work OK with DS1307, will need a set up change.

The test Depth is from a Nano set to output the NEMA message you posted, at 10 depth/sec..
The decimal Time is in milli-sec, you can round up the milli-sec value to give a 0.1Sec resolution.

E
 

Attachments

Thread Starter

umerrai1

Joined Mar 29, 2021
206
I did this one the same like as you have done. I used the last 3 digits of Arduino millis and displayed it on the serial monitor and also saved it on SD card.
 

ericgibbs

Joined Jan 29, 2010
12,922
hi ume,
Unless you can program all the external devices to transmit a known set of sequence codes to the main unit, I don't see how you can do auto detect.
E
Use the switch idea I posted earlier.
 

ericgibbs

Joined Jan 29, 2010
12,922
hi ume,

Why is your Boss asking for an auto detect feature , instead of a method that is common use.?
ie: a Bit Switch Baud rate selector.??

Is he an Engineer or a Salesman.?
E
 

Thread Starter

umerrai1

Joined Mar 29, 2021
206
He is not an electronics engineer. He is a geoengineer and wants to make a data logger which can detect auto baud rate.
 

ericgibbs

Joined Jan 29, 2010
12,922
hi ume,
Explain the usual way auto detect works, is that the remote unit repeatedly transmits a known Character that the Master [ Data logger] expects to receive.
In the Master program, the timing of the Bit data of the received known Character is measured and from that the Baud rate can be estimated.

Also point out to him, that it is not Only the Baud rate that can be different, so can the number of Start/Stop Bits, Parity Bit and Data Bit count can be different from one piece of equipment to another.

E
 

Yaakov

Joined Jan 27, 2019
3,156
It seems to me you are going to have to use fingerprints of all supported devices and scan the possible rates until you find one.
 

Yaakov

Joined Jan 27, 2019
3,156
This method will not be universal, but you can add fingerprints as you add supported devices.

Alternatively, you could assume that when you receive ASCII text with a letter frequency that matches normal messages, you've found the right rate.

No good method is really available to you.

If you made your own cables, you could have a set of pins that would provide an ID, using the bits the way a switch would.
 

Thread Starter

umerrai1

Joined Mar 29, 2021
206
Sir, we have an option of capture and compare. Do you have any idea about it? can we use timer interrupts for baud rate calculation?
 

Yaakov

Joined Jan 27, 2019
3,156
Personally, I don't think it is worth the time to write, debug, and maintain this. But were I stuck doing it I think my first idea would be like this:

1) Figure out the normal frequency distribution for characters in the messages from the devices. I am guessing they will be very similar. There will be a variety of ASCII characters mostly in the first 127. If it is true that all devices have comparable distributions then;

2) Scan each valid baud rate and wait for messages. Compare the distribution of character values at each baud rate. When one matches the previously measured distribution assume this is the correct rate, then;

3) Confirm the rate either by polling the device, if possible, or listening long enough to be sure the messages are valid one. Ideally, you would have signatures for each device that you could compare and identify the particular device so any configuration required for that device could be done. Otherwise, just hope you got it right.
 

Yaakov

Joined Jan 27, 2019
3,156
Sir I have to log my data for 15 mins and then 15 mins delay and again 15 mins logging. What should I do?
I don't know why that's relevant. What I described is a setup procedure, it will take some time (seconds?) to recognize the data rate on first connect and power up. Then do what you want with it.
 

ericgibbs

Joined Jan 29, 2010
12,922
hi ume,
In your void set up after you have set the Baud rate and the Begin, try this test.
Let us know the result of the test.

while(Serial.available())
Serial.read();

Note: you need to add the While loop for all your Serial Ports

E
 

Thread Starter

umerrai1

Joined Mar 29, 2021
206
Sir, I am already using this.

void serialEvent1() {
if (flag == 0) {
while (Serial1.available()) {
// get the new byte:
char inChar = (char)Serial1.read();
// add it to the dataString:
dataString1 += inChar;
// if the incoming character is a newline, set a flag so the main loop can
// do something about it:
if (inChar == '\n') {
stringComplete1 = true;
 
Top