Go Down

Topic: Problem with bilateral communication between Arduino and Processing (Read 3288 times) previous topic - next topic

Kyle3194

of course you can send a message that includes data from several sensors.

What I don't understand is why you think it is not possible and if you can explain that we might get somewhere. Clearly there is a mismatch between your understanding of what we are saying and our understanding of what you are saying.

Maybe if you provide a few examples of the typical data that you want to send.

The code in your GitHub link is much too long to study (or I am just lazy).

...R
From my understanding, in order for the ardunio IDE to transmit data to processing you have to use the serial library to do so. So, when I set up the servo on the ardunio board, I have the information that is gathered from the ardunio be sent to the serial monitor. Now, if I don't run the processing code I can simply view the serial monitor on the ardunio IDE and see the correct distance data. However, once I run the processing code, when I go to view the serial monitor I am unable to do so because the serial is "busy" since that information is being sent to processing (from what I understand). So once that is done I am able to get the processing code to read that data that was sent over from the ardunio IDE to be displayed on my GUI perfectly fine on processing. At this point the lidar sensor works perfectly fine. However, in the processing GUI there is connection for the two servo motors that you have to click "connect" and it displays that this is connect through the COM3 port. This is where the issue is. It seems that the lidar data being sent over from ardunio through the serial connection is already in use so the servos are unable to connect (their data from the ardunio board is also being sent to processing via the same serial method as the lidar sensor). Then, once I comment out the lidar code in the ardunio code, the servos will connect perfectly fine and function properly. I'm assuming this is the case because the way I have it set up, multiple data is being sent to that serial port and the ardunio cannot find which data to send. So it will only send the data which I have set up to appear first (not sure if this is the case, just an observation).

This is the part that I am having difficulties with. I know it may be possible to have them both communicate at the same time, but not sure what the best way to go about this is. I'm thinking I would have to be more specific about where the data from the servos and lidar sensor that the ardunio takes in are being sent to prevent this overload through the serial. I'm thinking it's just the way I have it set up currently. Hope this clears it up a bit, thank you for the help.

Robin2

I can't be sure if you understand that Processing is one PC program and the Arduino Serial Monitor is a different PC program. That is the reason why you can't talk to both of them at the same time.

I can't get my head around this
Quote
It seems that the lidar data being sent over from ardunio through the serial connection is already in use so the servos are unable to connect (their data from the ardunio board is also being sent to processing via the same serial method as the lidar sensor).
If the one Arduino is sending Lidar data and receiving servo data I can't understand why there is a problem. Unless of course the code is not written properly to keep track of the different messages.

If you can produce a short program that illustrates the problem I will study it. But the stuff on your Github link would take far too long to figure out.

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

Kyle3194

I can't be sure if you understand that Processing is one PC program and the Arduino Serial Monitor is a different PC program. That is the reason why you can't talk to both of them at the same time.

I can't get my head around this
If the one Arduino is sending Lidar data and receiving servo data I can't understand why there is a problem. Unless of course the code is not written properly to keep track of the different messages.

If you can produce a short program that illustrates the problem I will study it. But the stuff on your Github link would take far too long to figure out.

...R
The ardunio board itself has both the lidar sensor and the two servos connected to it. Then I have code running that runs the servos and the lidar sensor. So basically the ardunio board is taking the servo input and lidar input data and then sending that over to processing to provide the GUI and display everything. I'm thinking, like you said, that I don't have the code written properly to keep track of both these inputs separately, I probably have it set up to where the inputs are both just being sent to the same place so once the ardunio board gets that info and sends it to processing, it can't differentiate between the different data so only either the lidar works or servos work depending on what I have the code set as.

I will try to trim down the code and create a sample program to more clearly show the issue, I realize the current code is a bit much to see the issue.

Robin2

Have a look at the 3rd example in Serial Input Basics. I know it is intended for receiving data into the Arduino but the same technique can be used in a PC program.

For example you could send something like <123, 45, 67> where 123 is the Lidar value, 45 is the servo1 value and 67 is the servo2 value. The PC program will know which is which by the order in which they are presented. The < and > mark the start and end of the message.

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

Kyle3194

Have a look at the 3rd example in Serial Input Basics. I know it is intended for receiving data into the Arduino but the same technique can be used in a PC program.

For example you could send something like <123, 45, 67> where 123 is the Lidar value, 45 is the servo1 value and 67 is the servo2 value. The PC program will know which is which by the order in which they are presented. The < and > mark the start and end of the message.

...R

Update: We got it to work! Followed this "hand shaking" tutorial and we were missing a function lol. Thank you for your help.

Go Up