+ Reply to Thread
Results 1 to 4 of 4

Thread: Checking a ByteArray Value Used to Store String

  1. #1

    Default Checking a ByteArray Value Used to Store String

    Hello Every Body!

    I'm using a 16F877A Microcontroller connected to a PC using USART, The terminal program on the PC sends some commands to the MUC in order to perform certain task and the MCU should send a message as response for that command:

    for example: the MCU measures the temeperature form its analogue input, if I send the command "Temp" from the PC the MCU should respond to me by sending the temperature read. the problem here is after I read the command I can't check its value as following:

    Code:
    Device = 16F877A
    Xtal 8
     
    Declare LCD_Interface 4 
    Declare LCD_RSPin PORTB.0 
    Declare LCD_ENPin PORTB.1
    Declare LCD_DTPin PORTB.4 
     
    Declare Adin_Res 10       ' 10-bit result required 
    Declare Adin_Tad FRC      ' RC OSC chosen 
    Declare Adin_Stime 50     ' Allow 50us sample time 
     
    ADCON1= %10000000       
    Input PORTA
     
    Dim Digital As Float
    Dim Analogue As Float 
    Dim Temp As Float 
    Dim RSI[3] As Byte
     
    Main:
     
        Digital = ADIn 0 
     
        Analogue = (Digital * 5) / 1024
    Temp = Analogue * 100
     
        Print At 1,1,"Temp.: ",Dec Temp
     
        SerIn PORTC.1,1,1000,[Str RSI]
     
        If Str(RSI) = "Tem" Then 
            SerOut PORTC.0,396,["Temperature: ",Dec Temp ,10,13]     
        End If  
     
    GoTo Main
    I'm getting an error at the IF-Then Statement
    anyway to do the required. In General how can check for a string like this.

    Thank You!

    Hi, its great to see you visiting our forum. Why not try Proton Compiler for FREE?

    Download the FREE version of Proton Compiler, Its called Amicus18 and its available from HERE

    Already using proton Compiler??? Get rid of these pesky messages... get LICENSED USER STATUS




  2. If you're a Licensed user of PROTON DEVELOPMENT SUITE, apply for Licensed User Status to remove these pesky messages
     and get access to additional forum areas, Beta test downloads and more!

  3. #2
    Super Moderator John Drew's Avatar
    Join Date
    Feb 2002
    Location
    Millicent, South Australia
    Posts
    911


    Default Re: Checking a ByteArray Value Used to Store String

    One way to achieve it is to use the
    Rsin Wait("Tem"), SerData
    approach. This won't work if the PIC also has to check for other strings but if it's just this one it should work fine.
    By the way I notice you haven't updated your status. Let me know if you need help doing this.
    John

    It might be better to change to an 18F as the compiler supports a lot more commands for strings.
    Last edited by John Drew; 30th May 2011 at 07:53.

  4. #3


    Default Re: Checking a ByteArray Value Used to Store String

    Thank you John for your replay
    I got what you mean but yes the MUC has to check for other strings.
    I think I have to change to 18F.

    Thank you again

  5. #4
    Super Moderator John Drew's Avatar
    Join Date
    Feb 2002
    Location
    Millicent, South Australia
    Posts
    911


    Default Re: Checking a ByteArray Value Used to Store String

    Alternatively you can bring the information into an array (or individual variables) and then do a While/Wend loop through the array searching for the characters of "TEM" one at a time, drop out if there is no E after a T and so on.
    Bit more coding for you but it would work.
    There must be a reason you are not using HRSin which has the advantage of having a register you can check to see if there is a character waiting - saves hanging around waiting.
    John

+ Reply to Thread

Similar Threads

  1. Store packaging as an enclousure
    By normnet in forum The Lounge
    Replies: 2
    Last Post: 17th June 2011, 01:59
  2. symbol store data missing
    By pdehelly in forum Proton Plus Compiler v3
    Replies: 10
    Last Post: 7th February 2008, 21:27
  3. GLCD store images
    By maximassimo in forum Proton Plus Compiler v3
    Replies: 3
    Last Post: 24th August 2007, 15:45
  4. Got one Error while checking < 0
    By P.N. Shaji in forum Proton Plus Compiler v3
    Replies: 15
    Last Post: 27th May 2007, 19:44

Members who have read this thread : 7

Actions :  (Set Date)

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

Tags for this Thread

Posting Permissions

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