Reading data from serial port

Discussion in 'The Projects Forum' started by fatwi, Feb 4, 2008.

  1. fatwi

    Thread Starter New Member

    Jan 12, 2008
    6
    0
    hi

    I am usign an 8-bit Parallel In Seial Out shift register to shift data to a max232 ic which is connected to the serial port of my PC. I am not using a UART, but simply clocking the shift register at 9.6Khz

    I have designed a VB aplication to read the data from the shift register and display its value.

    from the 8 bits being sent to the shift register, one is the start bit and one is the stop nit. therefore my data is oly 6-bit long.

    my problem is that i can see the output of the MAX232 being correctly sent to the PC using the the oscilloscope but i cannot interpret the data being sent to the VB application.

    since i could be making an error in the code,(but i am sure that the receive buffer is receiving data), i tried to use HyperTerminal to see the incoming dat but still the data doesnt relate to anything being sent to the pc

    i tried using 2 different setting: 9600,N,6,1 and 19200,N,6,1

    this is wat i get


    i am sending a stream of 6 bits + one start bit + 1 stop bit.

    the problem is that when i send out the folowing streams: 001000, 001111, 100100, 100110, 100111-----i always get an '8'

    the following streams 001010, 001011,101010,101011 always return '&'

    the following stream 000100, 000110, 000111, 100010, 100011 always return a blank space ' '


    the folowing stream 010000, 011000, 011111,,101000 always give me '>'



    these are the only values that i get when reading from HyperTerminal, even VB gave me some of the above results

    i tried the port setting 9600,N,6,1 as well as 19200,N,6,1

    any idea what is wrong? Can someone please help???


    thx in advance



    PS:
    can someone please confirm if HyperTeminal is supposed to display only ASCII charaters or can it display data in any other format?
     
  2. Papabravo

    Expert

    Feb 24, 2006
    10,148
    1,791
    I'm not sure the PC can handle that setup with 6 data bits.

    As you know an 8-bit shift register does not contain enough data for 8-bit characters and the framing bits. For the PC to correctly interpret the data you need to add the framing bits. Namely a stop bit at the beginning which is always 0, and a stop bit at the end which is always one. Add the framing bits, get the baudrate correct and you're in business.

    If you tie the serial input to 1 that will take care of the STOP bit. Add a flip-flop which loads a zero when the shift register is loaded on the output of your shift register. That'll take care of the start bit. You do know that serial ports send and receive the Least Significant Bit first right?

    You should have read a UART datasheet or two and you would know these things.
     
  3. RiJoRI

    Well-Known Member

    Aug 15, 2007
    536
    26
    Re: Hyperterm
    Yes, it will only receive the printable ASCII characters: 0x20-0x7F (maybe0x80-0xFF), and 0x0A, and 0x0D.

    I would also slow the baud rate down to 300 baud. (Get it right, then make it faster.)
    --Rich
     
  4. Papabravo

    Expert

    Feb 24, 2006
    10,148
    1,791
    That does not compute since that range is greater than 64. How can you map 20-7F into 00-3F which is the range of six bit characters. Nobody has used 6-bit charactes since the days of the PDP-6 or the Olivetti accounting machines. AFAIK there is no such thing as 6-bit "ASCII"

    Don't even get me started on the RO-28 and Baudot Code.
     
  5. beenthere

    Retired Moderator

    Apr 20, 2004
    15,815
    282
    Ebsbic? Bcdic?
     
  6. Papabravo

    Expert

    Feb 24, 2006
    10,148
    1,791
    EBCDIC Extended Binary Coded Decimal Interchange Code (IBM ca. 1966) was an 8 bit code.
    http://en.wikipedia.org/wiki/EBCDIC

    The BCD character set was a 7-bit code[!! see below], that was popular on 7-Track magnetic tapes that predated the IBM 360 series of machines. I'm thinking the 7090 and the 7094 and the I/O processor for those behemoths the 1410.
    http://en.wikipedia.org/wiki/Binary-coded_decimal#IBM_and_BCD

    I beg your pardon. It turns out my memory was faulty. BCD is a six bit character set. On a 7-Track magnetic tape the seventh bit was a parity bit. How could I have forgotten the blessed parity bit.

    Edit:
    Here is the reference to the character set used in the DEC computers of the early 60s. It was called Sixbit
    http://en.wikipedia.org/wiki/Sixbit

    It is essentially upper case ASCII with no control characters. As such it was only used for filenames and asembler symbols.
     
  7. RiJoRI

    Well-Known Member

    Aug 15, 2007
    536
    26
    If you look closely, I was talking about the (in)capacity of HyperTerm. Nothing else.

    --Rich
     
  8. Papabravo

    Expert

    Feb 24, 2006
    10,148
    1,791
    Fair enough, but the question is how will sixbit characters in an 8 bit frame with a proper start bit and stop bit be mapped? Hyperterm will allow you to select 6 data bits, but it is less than clear on what it will display for various inputs. In the article on sixbit characters used on the DEC systems of the early sixties it specifically mentions that there were no control characters and they were used for file names and assembler symbols only.

    I'm pretty sure that I've never seen a suggestion that any of the terminal emulators would actually do any kind of complete character set conversion. I seem to remember that Procomm had some facility for building translation tables but I never had any motivation to use the feature.
     
  9. RiJoRI

    Well-Known Member

    Aug 15, 2007
    536
    26
    Actually, if this is not being done as a class exercise, I would look into an SIO chip, such as were used with the 8080 and Z-80. Set up the chip. load in the parallel data, and away it goes, complete with start and stop bits. If you only need 6 bits, keep the upper two bits set to zero.

    Or, get a tiny micro, and use it in place of the SIO chip. Read in the parallel port, and ship it out via the serial port. This will take up less room, but cost time in programming and testing it.

    --Rich
     
Loading...