Results 1 to 4 of 4
  1. #1
    GoodAsh03 is offline Member
    Join Date
    Jul 2009
    Posts
    2
    Rep Power
    0

    Arrow Question About Using Serial Ports

    Hello. I want to start on a project in which I write the driver software to operate and program a robot arm toy. The toy uses two RS-232 DE-9 serial ports where the wired joysticks are connected. Once upon a time these same toys could be hooked up to an MSX computer and controlled via their serial ports.

    What I want to do is connect two serial cables from my computer directly to the toy and then write some software in Java to control it. The toy operates not by sending complex data to the serial ports but rather by connecting pins together. For example, connecting pin 2 to pin 9 in the right serial connector on the toy may cause the pincers to close, etc. The toy has its own power source of 6V (6 volts also runs through the serial pins when you connect them).

    Is there a way to do this in Java? Any Packages or Classes that will help me?

    Thank you,
    Jeremy

  2. #2
    rdtindsm is offline Member
    Join Date
    Feb 2009
    Posts
    92
    Rep Power
    0

    Default

    I became interested in this problem partially because the use of the term "DB-9" is universally and incorrectly used. A B-shell connector has 25 pins, the DB-9 is correctly called a DE-9. Even if one accepts the misuse of DB, the problem comes with DB-15. You can get D connectors with 15 pins in both E (VGA connector) and A shells - standard low density 2 rows of pins.

    Back to your question. There is a serial port API in Java. A google search on java serial port quickly found the reference from SUN. Not sure this is what you want, but it is unclear exactly what your output has to do. I'm reading your post as saying you basically need a switch between the two pins, rather than simply applying a high or low signal at both pins.

    I am guessing that you will need to a serial to parallel converter with additional circuitry to decode the control signal. This task should be fairly routine and something that could be handled by an upper level student in digital design. If you actually need something to short the two pins together, probably need some sort of fet switch. These devices would be readily available from an electronics supplier. My background isn't recent enough, nor deep enough to tell you more.

    16550 is chip compatible with the 8250 & 16450. Just copied and pasted to get these numbers. The 8250 and 16450 are very date technology, 16550 is newer and faster replacement. The term for the chip is UART (universal asynchronous receiver transmitter)
    is parallel to serial input, and serial to parallel output, features you will probably need at any level. May not be the perfect fit, but the chip is only 5-10$ and readily available.

  3. #3
    GoodAsh03 is offline Member
    Join Date
    Jul 2009
    Posts
    2
    Rep Power
    0

    Default

    Hello and thank you for replying.

    Quote Originally Posted by rdtindsm View Post
    If you actually need something to short the two pins together

    Yes, that's what I'm looking for. The toy works in such a way that I can literally take a wire and connect pin x to pin y in one of the two serial ports and that will illicit a movement from the robot arm.

    My questions are whether the toy can be controlled strictly by a couple of serial cables connected between the toy and the computer with the computer replacing the work of the wire and if so, how? The output from the software I would write would be "connect pin x to pin y" and then the arm would move.

  4. #4
    rdtindsm is offline Member
    Join Date
    Feb 2009
    Posts
    92
    Rep Power
    0

    Default

    Again, I don't know the engineering details of your device. You will need an intermediate device. The rs232 port will not short outputs directly. There is some possibility the output of the UART could sink the current, but the signal lasts for only one clock cycle; you would still need a latch of some sort.

    But the general idea for a cheap and dirty way is to use a UART in your circuit to read the serial input and transfer it to the parallel bus output. This is standard application. The UART converts the serial sequence into the parallel format that can be read by the system bus.

    So lets say the code to activate the arm is 7F (or perhaps 80). Most signals in a computer are actually active low, so call it 7F. Pin D7 low could activate a PNP transistor connected to the coil of a realy which closes and shorts the two pins. Won't be very responsive, but don't think you're looking for more than proof of concept.

    At this point, the way you want this to work depends on what you want to do next, and beyond the scope of what I can suggest to be more explicit. For example, how many functions to you need to control? Let me point out that you will need to latch the signal; that is to keep your relay engaged once the UART receives the byte. My reading of the data sheet indicates that the data is only available when an interrupt signal is generated by the UART, and the RD/!RD signals change state. At this point you read the parallel signal (D7) into a register. To disable the arm, simply send FF and read D7 into the register again. Should take the UART, a flip flop, and a few gates (probably no more than the 4 available in standard 14 pin package), 3 to four chips, a transistor or two (available 4 to a 14 pin package). Not a terribly difficult task, but you definitely need to have some digital design background. Be a good project for an undergrad lab over several weeks. Should be tons of application info out there.

    http://www.national.com/ds/PC/PC16550D.pdf
    is data sheet.

    Your software looks like
    -- Write activate code to serial port.
    -- Wait
    -- Write dectivate code to serial port

    PS: I lied a little. You will need a crystal and at least two gates for the clock. I do have to make the disclaimer that I am no longer intimately familiar with the chip, although I actually have had to work with it at the direct control level in the far distant past. I don't think it will turn out to be a three hour tour, but you may need a small handful of misc. parts - resistors, caps, reset circuitry. Actually had to design & build a simple serial transmitter / receiver in a lab. It would be possible to make the serial to par receiver with about 5 or 6 chips. I know I got it all on a prototype board which won't hold much more. Need a 555 (missing pulse detector), a serial to par register, a counter, and a latch to enable the counter and the shift register. Also, a clock circuit. The missing pulse detector detects the stop bit, at which point the clock loads the shift register. At the end of 8 counts, the control value is read into a latch. The 555 is a very versitile chip; the MPD will be in application notes somewhere.

    d7 d6 d5
    |..|..|..|..| etc
    signal -> --shift register -->
    .|...................../\
    .|.....counter <--|
    .|.......| EOC......-----------| gate |
    .|.......----------- | reset.......|..|
    .|...| - - -|.....|---\/---|........|..|
    ..--| 555 | -> | latch | ->----|..|-----< clock
    ......-----..set .|-------|

    note: periods needed to retain layout. The general idea is that the 555 is configured as a missing pulse detector which detects the start bit. That sets the latch which enables the free running clock to transmit through a gate and clock the shift register. When the counter counts 8 pulses, it resets the latch, leaving the shift register in the correct place. Get the counter to read clock the shift register in the middle of the transmission clock. to eliminate jitter problems.
    Last edited by rdtindsm; 07-28-2009 at 07:46 AM.

Similar Threads

  1. Java ms Access and pc serial ports
    By VanGo in forum New To Java
    Replies: 4
    Last Post: 04-15-2009, 08:16 PM
  2. opening ports
    By prashant in forum Networking
    Replies: 2
    Last Post: 03-22-2009, 09:23 PM
  3. Applets and serial ports question
    By kenshinofkin in forum Java Applets
    Replies: 1
    Last Post: 02-27-2009, 12:30 AM
  4. Looking for servers on ports
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-13-2007, 10:28 AM
  5. How to know the ports opened by JVM
    By sandeepspatil in forum Advanced Java
    Replies: 1
    Last Post: 08-02-2007, 02:51 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •