Go to Post It's a bit sad, really, because FIRST has already reached other countries and there are some U.S. states that still are unaware of what FIRST is!! - tribotec_ca88 [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 07-05-2015, 14:28
stu54 stu54 is offline
Registered User
None #2458
 
Join Date: Jul 2014
Location: US
Posts: 11
stu54 is an unknown quantity at this point
RoboRio and Serial Data

I have been trying to hook up a MaxSonar range finder to my RoboRio using the ASCII output of the MaxSonar rather than the analog output. I tried both the RS-232 port (using a TTL-to-RS-232 converter) and the MXP port. My programming language is Java for the WPIlib but that should not matter.

It seems like the syntax of the MaxSonar somehow violates the VISA format
that the RoboRIO expects so I get Java crashes when I try to read the serial
port. I don't know anything about the VISA format - I was just trying to read
the simple ASCII string from the MaxSonar. I know if I just use a loopback
to test my code I can read and write the serial ports but that's probably
because everything is using the VISA format deeper in the libraries.

Does anyone have experience with general ASCII devices on the RoboRIO
or would I have to use a device that put out the VISA format (which I
could only do if I passed the data from the MaxSonar though an Arduino
to re-format it for VISA, and that's a lot more trouble than just using the
analog input).

Thanks for any help.
  #2   Spotlight this post!  
Unread 08-05-2015, 00:41
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,041
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: RoboRio and Serial Data

Quote:
Originally Posted by stu54 View Post
I have been trying to hook up a MaxSonar range finder to my RoboRio using the ASCII output of the MaxSonar rather than the analog output. I tried both the RS-232 port (using a TTL-to-RS-232 converter) and the MXP port. My programming language is Java for the WPIlib but that should not matter.

It seems like the syntax of the MaxSonar somehow violates the VISA format
that the RoboRIO expects so I get Java crashes when I try to read the serial
port. I don't know anything about the VISA format - I was just trying to read
the simple ASCII string from the MaxSonar. I know if I just use a loopback
to test my code I can read and write the serial ports but that's probably
because everything is using the VISA format deeper in the libraries.

Does anyone have experience with general ASCII devices on the RoboRIO
or would I have to use a device that put out the VISA format (which I
could only do if I passed the data from the MaxSonar though an Arduino
to re-format it for VISA, and that's a lot more trouble than just using the
analog input).

Thanks for any help.
I find it hard to believe that there would be a VISA-specific format required.

I've not used the serial functionality on the RoboRIO, but typically with serial devices you need to make sure that the baud rate matches (eg, you need to set the port speed to what the device is using) or you'll get unpredictable results similar to what you describe. Typical serial devices tend to be 9600 or 115200 baud, refer to your data sheet to see what your device uses.
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
  #3   Spotlight this post!  
Unread 08-05-2015, 15:43
GeeTwo's Avatar
GeeTwo GeeTwo is online now
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,565
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: RoboRio and Serial Data

It's possible that java somehow thinks that it's getting Unicode instead of ascii, and mangling the strings on the way in. You may want to try getting the raw bytes in a buffer to see if you can use it instead.
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.
  #4   Spotlight this post!  
Unread 13-05-2015, 11:55
stu54 stu54 is offline
Registered User
None #2458
 
Join Date: Jul 2014
Location: US
Posts: 11
stu54 is an unknown quantity at this point
Re: RoboRio and Serial Data

I found that when I did a try/catch on my code and did the single byte unbuffered reads I was getting framing errors (even though everything is set to 9600 N 8 1) and
when I got some reads to work it did not look like the ASCII format as
documented for the MaxSonar. Maybe it is a unicode thing or maybe
the RoboRIO serial reader is not set up for asynchronous reading like would be needed
for the MaxSonar. Guess I will just have to go with analog.
  #5   Spotlight this post!  
Unread 15-05-2015, 15:11
Bonzabonz Bonzabonz is offline
Registered User
FRC #5052 (RoboLobos)
Team Role: Alumni
 
Join Date: Feb 2014
Rookie Year: 2014
Location: Cedar Park Texas
Posts: 13
Bonzabonz is an unknown quantity at this point
Re: RoboRio and Serial Data

Quote:
Originally Posted by GeeTwo View Post
It's possible that java somehow thinks that it's getting Unicode instead of ascii, and mangling the strings on the way in. You may want to try getting the raw bytes in a buffer to see if you can use it instead.
I second this, in my experience, if you read the raw and do your own encoding things seem to work better. If you can post your code, we could probably take a look and see if anything obvious stands out.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 10:04.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi