Can serial transfer binary data?


Closed Thread
Results 1 to 7 of 7
  1. #1
    TurboLS's Avatar
    TurboLS Guest

    Default Can serial transfer binary data?

    Can the PIC send out true binary serially or just ASCII representation of it?

  2. #2
    Join Date
    Oct 2003
    Location
    holland
    Posts
    251


    Did you find this post helpful? Yes | No

    Default

    Yes, It is always binairy data what you sent. ASCII is also binairy.
    The recieving unit could be a problem. Don't forget to sent 8 bits.

  3. #3
    TurboLS's Avatar
    TurboLS Guest


    Did you find this post helpful? Yes | No

    Default

    Well, like if I use the BIN8 operator, i do get 10110111 in the serial command window, but Matlab reads it as 49, 48, 49, 49, 48, 49, 49, 49 (which is the decimal value of the ascii characters, 0 and 1. So instead of each bit being sent in 1 bit, each bit requires 5 bits b/c 2^5 is 64. Basically, is there a way to send binary and not ascii?

  4. #4
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    TurboLS,

    A "standard terminal" displays the ASCII representation of each byte received.

    So if you would like to see "BINARY" on your terminal screen you have got to send the (8bit) ASCII value for the every single "1" and "0"

    or

    choose a "terminal-program" that is capable of displaying the binary values of received data.
    regards

    Ralph

    _______________________________________________
    There are only 10 types of people:
    Those who understand binary, and those who don't ...
    _______________________________________________



  5. #5
    TurboLS's Avatar
    TurboLS Guest


    Did you find this post helpful? Yes | No

    Default

    what is the command to send binary values if I have a terminal program that can view them?

  6. #6
    TurboLS's Avatar
    TurboLS Guest


    Did you find this post helpful? Yes | No

    Default

    Is the PIC capable of sending RAW binary data?? ASCII characters take longer to send, so if I can send RAW binary data, that would be optimum. Does anyone know?

  7. #7
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Is the PIC capable of sending RAW binary data??
    I think if you just send the value without any formatting, it's in raw format.
    I.E. X = 10 : HSEROUT [X].

    You can send whatever value's in X directly to the USART TXREG like this,
    and I'm fairly sure the PIC doesn't automatically convert bytes placed in
    TXREG to ASCII;
    Code:
    SPBRG = 64    ' 19200 bps @20MHz
    RCSTA = $90  ' Serial port enable 
    TXSTA = $24  ' Transmit enable, BRGH = 1 for high-speed
    X VAR BYTE
    TRISC.6=0
    
    MAIN:
        FOR X = 0 to 255 
            GOSUB ENCODE
            PAUSE 50
        NEXT X
        X = $0D ' Carriage return
        GOSUB ENCODE
        X = $0A ' Line feed
        GOSUB ENCODE
        PAUSE 100 
        GOTO Main
    
    ENCODE:
    ASM
        movf _X, W     ; Load X into W reg
        btfss PIR1,4   ; Wait for TXREG to be empty after last byte
        goto $-1       ; Not empty, wait
        movwf TXREG    ; Empty, so send next byte
    ENDASM
        RETURN
    I don't have MATLAB to test this, but I can't see why it wouldn't work. I get
    the same results from either method with a standard terminal program.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

Similar Threads

  1. Using Nokia LCD
    By BobP in forum mel PIC BASIC Pro
    Replies: 300
    Last Post: - 3rd May 2018, 04:47
  2. Read/Write Problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 10th February 2010, 01:51
  3. Big characters on HD44780 4x20
    By erpalma in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 7th January 2007, 02:21
  4. LCD + bar graph
    By DynamoBen in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 5th October 2005, 14:50
  5. Sinus calculating !
    By Don Mario in forum mel PIC BASIC Pro
    Replies: 29
    Last Post: - 28th November 2004, 23:56

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

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