Go to Post Much of what you do in the "real world" has no rules. You have to look yourself in the mirror and make them up as you live; knowing that what you do WILL come back to haunt you sooner or later. - dhitchco [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 01-02-2013, 19:32
9072997 9072997 is offline
Registered User
FRC #3608 (LISA Jaguars)
Team Role: Programmer
 
Join Date: Feb 2013
Rookie Year: 2011
Location: Arkansas
Posts: 4
9072997 is an unknown quantity at this point
Trouble With cRIO Serial Port

We would like to add a ultrasonic sensor to our robot and have one that outputs RS-232. So we wired up an old serial cable to the proper pins, and after some work we got output from hyper terminal in the correct format of
Code:
R000
on each line with 000 representing the distance (up to 255). When connected to the robot though we get a very different result. Below is part of the code we are using:
Code:
    SerialPort sonarSensor;
    
    public static String bytesToHex(byte[] bytes) {
        final char[] hexArray = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
        char[] hexChars = new char[bytes.length * 2];
        int v;
        for ( int j = 0; j < bytes.length; j++ ) {
            v = bytes[j] & 0xFF;
            hexChars[j * 2] = hexArray[v >>> 4];
            hexChars[j * 2 + 1] = hexArray[v & 0x0F];
        }
        return new String(hexChars);
    }  
    
    void updateDashboard() {
        try {
            for(int i = 0 ; sonarSensor.getBytesReceived() > 0 ; i++) {
                System.out.println(bytesToHex(sonarSensor.read(20)));
                if(i > 100) {
                    System.out.println("RESET");
                    sonarSensor.reset();
                    break;
                }
            }
            System.out.println("DONE");
        } catch (Throwable exception) {
            exception.printStackTrace();
        }
    }
the resulting hex dump is:
Code:
434F4D31202D2000000000050000000155706461
434F4D31202D204275696C742D496E0038210010
4153524C313A3A494E53545200000001742E6F75
434F4D31202D2000000000050000000155706461
434F4D31202D204275696C742D496E0038210010
4153524C313A3A494E53545200000001742E6F75
434F4D31202D2000000000050000000155706461
434F4D31202D204275696C742D496E0038210010
4153524C313A3A494E53545200000001742E6F75
434F4D31202D2000000000050000000155706461
434F4D31202D204275696C742D496E0038210010
4153524C313A3A494E53545200000001742E6F75
434F4D31202D2000000000050000000155706461
434F4D31202D204275696C742D496E0038210010
4153524C313A3A494E53545200000001742E6F75
434F4D31202D2000000000050000000155706461
434F4D31202D204275696C742D496E0038210010
4153524C313A3A494E53545200000001742E6F75
434F4D31202D2000000000050000000155706461
434F4D31202D204275696C742D496E0038210010
4153524C313A3A494E53545200000001742E6F75
434F4D31202D2000000000050000000155706461
434F4D31202D204275696C742D496E0038210010
4153524C313A3A494E53545200000001742E6F75
434F4D31202D2000000000050000000155706461
434F4D31202D204275696C742D496E0038210010
4153524C313A3A494E53545200000001742E6F75
434F4D31202D2000000000050000000155706461
434F4D31202D204275696C742D496E0038210010
4153524C313A3A494E53545200000001742E6F75
434F4D31202D2000000000050000000155706461
434F4D31202D204275696C742D496E0038210010
4153524C313A3A494E53545200000001742E6F75
434F4D31202D2000000000050000000155706461
434F4D31202D204275696C742D496E0038210010
4153524C313A3A494E53545200000001742E6F75
434F4D31202D2000000000050000000155706461
434F4D31202D204275696C742D496E0038210010
4153524C313A3A494E53545200000001742E6F75
434F4D31202D2000000000050000000155706461
434F4D31202D204275696C742D496E0038210010
4153524C313A3A494E53545200000001742E6F75
434F4D31202D2000000000050000000155706461
434F4D31202D204275696C742D496E0038210010
4153524C313A3A494E53545200000001742E6F75
434F4D31202D2000000000050000000155706461
434F4D31202D204275696C742D496E0038210010
4153524C313A3A494E53545200000001742E6F75
434F4D31202D2000000000050000000155706461
434F4D31202D204275696C742D496E0038210010
4153524C313A3A494E53545200000001742E6F75
434F4D31202D2000000000050000000155706461
434F4D31202D204275696C742D496E0038210010
4153524C313A3A494E53545200000001742E6F75
434F4D31202D2000000000050000000155706461
434F4D31202D204275696C742D496E0038210010
4153524C313A3A494E53545200000001742E6F75
434F4D31202D2000000000050000000155706461
434F4D31202D204275696C742D496E0038210010
4153524C313A3A494E53545200000001742E6F75
434F4D31202D2000000000050000000155706461
434F4D31202D204275696C742D496E0038210010
4153524C313A3A494E53545200000001742E6F75
434F4D31202D2000000000050000000155706461
434F4D31202D204275696C742D496E0038210010
4153524C313A3A494E53545200000001742E6F75
434F4D31202D2000000000050000000155706461
434F4D31202D204275696C742D496E0038210010
4153524C313A3A494E53545200000001742E6F75
434F4D31202D2000000000050000000155706461
434F4D31202D204275696C742D496E0038210010
4153524C313A3A494E53545200000001742E6F75
434F4D31202D2000000000050000000155706461
434F4D31202D204275696C742D496E0038210010
4153524C313A3A494E53545200000001742E6F75
434F4D31202D2000000000050000000155706461
434F4D31202D204275696C742D496E0038210010
4153524C313A3A494E53545200000001742E6F75
434F4D31202D2000000000050000000155706461
434F4D31202D204275696C742D496E0038210010
Which (acording to http://www.dolcevie.com/js/converter.html) translates to this:
Code:
COM1 - ?????????Upda?4??????'V??B????????ASRL1::INSTR????t.ou?4??????????P????W?F?COM1 - Built-In?8!????5$??????5E ????B???COM1 - ?????????Upda?4??????'V??B????????ASRL1::INSTR????t.ou?4??????????P????W?F?COM1 - Built-In?8!????5$??????5E ????B???COM1 - ?????????Upda?4??????'V??B????????ASRL1::INSTR????t.ou?4??????????P????W?F?COM1 - Built-In?8!????5$??????5E ????B???COM1 - ?????????Upda?4??????'V??B????????ASRL1::INSTR????t.ou?4??????????P????W?F?COM1 - Built-In?8!????5$??????5E ????B???COM1 - ?????????Upda?4??????'V??B????????ASRL1::INSTR????t.ou?4??????????P????W?F?COM1 - Built-In?8!????5$??????5E ????B???COM1 - ?????????Upda?4??????'V??B????????ASRL1::INSTR????t.ou?4??????????P????W?F?COM1 - Built-In?8!????5$??????5E ????B???COM1 - ?????????Upda?4??????'V??B????????ASRL1::INSTR????t.ou?4??????????P????W?F?COM1 - Built-In?8!????5$??????5E ????B???COM1 - ?????????Upda?4??????'V??B????????ASRL1::INSTR????t.ou?4??????????P????W?F?COM1 - Built-In?8!????5$??????5E ????B???COM1 - ?????????Upda?4??????'V??B????????ASRL1::INSTR????t.ou?4??????????P????W?F?COM1 - Built-In?8!????5$??????5E ????B???COM1 - ?????????Upda?4??????'V??B????????ASRL1::INSTR????t.ou?4??????????P????W?F?COM1 - Built-In?8!????5$??????5E ????B???COM1 - ?????????Upda?4??????'V??B????????ASRL1::INSTR????t.ou?4??????????P????W?F?COM1 - Built-In?8!????5$??????5E ????B???COM1 - ?????????Upda?4??????'V??B????????ASRL1::INSTR????t.ou?4??????????P????W?F?COM1 - Built-In?8!????5$??????5E ????B???COM1 - ?????????Upda?4??????'V??B????????ASRL1::INSTR????t.ou?4??????????P????W?F?COM1 - Built-In?8!????5$??????5E ????B???COM1 - ?????????Upda?4??????'V??B????????
Any ideas? Thanks in advance.
Reply With Quote
  #2   Spotlight this post!  
Unread 01-02-2013, 19:38
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,572
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Trouble With cRIO Serial Port

Is the console out switch turned off? Where is your constructor for the sonarSensor?
Reply With Quote
  #3   Spotlight this post!  
Unread 01-02-2013, 19:48
9072997 9072997 is offline
Registered User
FRC #3608 (LISA Jaguars)
Team Role: Programmer
 
Join Date: Feb 2013
Rookie Year: 2011
Location: Arkansas
Posts: 4
9072997 is an unknown quantity at this point
Re: Trouble With cRIO Serial Port

Right now it's:
Code:
sonarSensor = new SerialPort(9600);
But we also have tried:
Code:
sonarSensor = new SerialPort(9600, 8);
and:
Code:
sonarSensor = new SerialPort(9600, 7);
yes the console out switch is off (physical switch since we are useing the 8-slot cRIO).
Reply With Quote
  #4   Spotlight this post!  
Unread 02-02-2013, 23:19
9072997 9072997 is offline
Registered User
FRC #3608 (LISA Jaguars)
Team Role: Programmer
 
Join Date: Feb 2013
Rookie Year: 2011
Location: Arkansas
Posts: 4
9072997 is an unknown quantity at this point
Re: Trouble With cRIO Serial Port

For others, It appears as though while my computer was able to accept +/-5V for the serial data line the cRIO may require the full +/-12V defined by RS-232.
Reply With Quote
Reply


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 11:40.

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