loading
 
Serial Module skips/sends/returns wrong data
Brother.Ed from United States  [3 posts]
3 years
Greetings STeven! Thank you for this impressive software.

I am trying to identify and sort various Legos on a  moving belt and blow them off with air into the correct bin.  I am using an Arduino Uno that looks for a RelayNumber (integer) on the serial port, then calculates the number of counts from a proximity switch before firing the correct relay.  It seems to work well when I send numbers from the keyboard, but now I want to send them from RoboRealm.

RoboRealm is able to identify the parts going past the camera but I can't seem to get the "ID" number to reliably make it to the serial port. While watching the serial Console, some ID numbers never get sent even though display_variables shows a proper ID.  Sometimes the Arduino reports back a number that was not sent.

I have been studying thread 4995 and have modeled my system similarly.  Please see attached.  I have checked "Wait for Reply".

Do you think I have a computer error? (Old XP Machine)
Do I have a strategy error? (I hope to control 20 relays eventually)
Is it possible that the Console is not fast enough to catch the return string from Arduino?

Thanks in advance.  I am very new to vision systems!

Brother.Ed

Brother_Ed.zip
Steven Gentner from United States  [1371 posts] 3 years
Ed,

We found in the past that communicating with an Arduino can cause issues. That's why the Arduino modules include a CRC (checksum) to ensure that the data was sent correctly. Its possible for characters to go missing so you have to watch for that.

What I would do in your case is convert the number to a single byte. You can do this in the serial module by using

\[RelayNo]

which would send a single byte instead of a bunch of ascii characters which could be received out of order. With a single byte, there isn't anything to get lot and is also a lot faster.

You will have to ensure that no relay is above 255 but I think that's ok in your situation.

You will also have to change your Arduino code to now receive a single binary character and use that directly ... which again is actually easier than dealing with an ascii string.

Try that change and see how it fairs.

STeven.
Brother.Ed from United States  [3 posts] 3 years
Thanks for the info. I will try it as soon as I can!
Brother.Ed from United States  [3 posts] 3 years
Sending only a byte seemed to help a lot!  I also added a short delay in the Arduino code to give the serial time to finish processing before moving on and that seemed to help also.
    . . .
    readByte=Serial.read();
    delay(20);
    . . .
Thanks!

Brother.Ed

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index