Serial Communication


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default converting array data

    If you know WHERE the data digits are, you can simply do math on the ascii characters.

    result=100*(array[5]-48)+10*(array[6]-48)+array[7]-48

    As for bringing in the 2nd sensor, can you look at using a chip enable if they're open collector outputs, and then just select one or the other on the same hserin input?

    -------------------Picster-----------------

  2. #2
    Join Date
    Feb 2006
    Posts
    89


    Did you find this post helpful? Yes | No

    Default Maybe I am not doing something right

    My array is 13 bits long. Assuming the array numbers start with 0 and ends at 12. Here is the string (the x's represent numbers in ascii) H xx.x T xx.x with the spaces (I assume) part of the array. I need to use the numbers after T xx.x (which is temperature in Celsius) and convert it to Fahrenheit. Here is what I used:

    temp=(humidity1[9]* 90) / 5
    temp1=(humidity1[10]*9)/ 5
    temp2=(humidity1[12]*9)/50
    tempfin=temp+temp1+temp2+32

    Humidity is the str array variable that holds the information. When I get the final value and output it on the lcd, I get an unrecognizable character. Any suggestions? thanks

  3. #3


    Did you find this post helpful? Yes | No

    Default Ascii vs value

    Yep, you need to subtract 48 from each ASCII value to come up with the numerical value before you do the factoring.

    ------------------Picster-----------------

  4. #4
    Join Date
    Feb 2006
    Posts
    89


    Did you find this post helpful? Yes | No

    Default Works

    It works now. thanks. Just out of curiosity, why do you subtract 48? I forgot to mention earlier, I am using HS-2000D humidity sensor made by PRECONUSA.

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    the answer is located in the ASCII table in your PBP manual. Character 0 is decimal ASCII 48.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    Join Date
    Mar 2006
    Location
    Garden Grove, Ca
    Posts
    5


    Did you find this post helpful? Yes | No

    Default serial communication

    Hi,
    check the thread R/H Temp sensor.
    Bruce used the same sensor and posted the code to show H and Temp in C and F.
    I am using the same sensor and some of Bruces work in my code.
    Works like a champ!!!

    Joe

Similar Threads

  1. Wireless serial communication question
    By Ahmadabuomar in forum Serial
    Replies: 3
    Last Post: - 21st December 2009, 03:49
  2. PIC to PIC "wired" serial one-way communication - SERIN2/SEROUT2
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 14th April 2008, 20:02
  3. Bootloader,MCSP and Serial communication
    By surfer0815 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 3rd March 2006, 10:52
  4. Serial Communication using 12F629
    By charudatt in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 14th March 2005, 04:24
  5. Replies: 8
    Last Post: - 11th November 2004, 20:08

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