Interupts and Command string


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    Join Date
    Feb 2005
    Location
    Essex, UK
    Posts
    154

    Default

    Excellent help, thanks.

    I have now managed to get variables sent from VB to PIC.

    The code now looks like this:

    Code:
    Start:
        '    Main program loop that make the user happy to
        '    see a LED flashing to mean that something is 
        '    running 
        '
        
        Hserout [hours, minutes, seconds]
        
        toggle userled
        for delay = 1 to 5000       ' use a loop delay to ensure
          pauseus 5                 ' getting interrupt as fast as
          next                      ' possible
        goto start
        
    
    disable interrupt
    USARTInterrupt:
        '    Here's the interrupt routine who will make the user
        
        HSERIN [hours, minutes, seconds]
    
        Write 5, hours
        Write 6, minutes
        Write 7, seconds
      
        resume                      ' get out of here
    enable interrupt
    However, i can only send over single numerals, ie 0-9. But in the timing functions for Hrs, Mins and Sec it could be upto 59. How do i get the PIC to reconise the double figures. If i try to send them the PIC just hangs.

    The write command is to just store the variables in EEPROM for later use.

    Thanks for your help,

    Steve

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

    Default

    Suppose the actual time is 1:33:56
    Send it as 013356

    actual time is 1:02:01
    send it as 010201

    THEN you use the DEC2 modifier
    HSERIN [DEC2 hour, DEC2 Minute, DEC2 Second]
    Steve

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

  3. #3
    Join Date
    Feb 2005
    Location
    Essex, UK
    Posts
    154

    Default

    Yup, that worked very well. I'm trying to figure out the methods of sending and receiveing data on 2 languages, PIC and VB.

    I managed to get the combining of the timings and it now it reads and outputs very well. Thank you Steve.

    I've been reading about qualifiers, but can only see the WAIT command, where as i'm using an interupt, this isn't really what i want.

    I want to look for a command sent from VB to signal what routine to jump too. For example in the interupt if the word TIMINGS is received then it reads and stores the subsequent timing variables. But if the word FLAGS is received then it stores the flag variables etc etc.

    In VB i would output something like

    Code:
    MSComm1.Output = "Time" & Format(Hours, "00") & Format(Minutes, "00") & Format(Seconds, "00") & Format(SuSeconds, "00")
    Is this possible?

    As at the moment it will just deal with the 8 numbers it receives, i want it to be more choosy depending what VB sends accross.

    Many thanks,

    Steve

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

    Default

    for the HSERIN modifier refer to SERIN2

    about VB, here's a quote from VB6 Black book pdf
    Attached Images Attached Images  
    Last edited by mister_e; - 16th March 2006 at 14:02.
    Steve

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

  5. #5
    Join Date
    Feb 2005
    Location
    Essex, UK
    Posts
    154

    Default

    Thanks Steve.

    At the moment i have this code for the interupt, it works as long as i send "Time" as the qualifier.

    So in VB it sends:

    Code:
    MSComm1.Output = "Time" & Format(Hours, "00") & Format(Minutes, "00") & Format(Seconds, "00")
    Where the PIC command is:
    Code:
        HSERIN [Wait("Time"), DEC2 hours, DEC2 Minutes, DEC2 Seconds]
    Thing is, I don't want it to wait. I want it to look at the serial command comming in and check for the qualifier. So if the qualifier is TIME, it then takes the DEC2 hours, DEC2 Minutes, DEC2 Seconds strings.

    However, if the qualifier is FLAG, then it performs a different command, such as:
    Code:
        HSERIN [flag1, flag2, flag3]
    If neither of the qualifiers are met (or any depending how many i need), then it resumes and waits for the next serial input.

    Does this make sense, i'm starting to confuse myself !

    Cheers,

    Steve

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

    Default

    bah as you wish. You can even do some handshake between PIC and PC.

    PIC side:
    1. Waiting for Flag (must be Fix format 1,2,3 or more character) Lets'say BEER
    2. choose according procedure to do (Corect HSERIN), Send Confirmation to PC (OK i got Beer, send me another Crate now)

    and there still many other way.. it's up to you
    Steve

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

  7. #7
    Join Date
    Feb 2005
    Location
    Essex, UK
    Posts
    154

    Default

    Sorry Steve, don't understand what you mean.

    Maybe i haven't had enough 'beer'.

    This is what i have come up with so far, but its still not working.

    Code:
    USARTInterrupt:
        '    Here's the interrupt routine
    
        HSERIN [Qualifier]
        Branch QUALIFIER,[Sub1,Sub2,Sub3]
    
    Sub1:
        HSERIN [DEC2 hours, DEC2 Minutes, DEC2 Seconds, DEC2 suseconds]
        Write 5, hours
        Write 6, minutes
        Write 7, seconds
        write 8, suseconds
        HSEROUT ["You sent Red", DEC2 hours, DEC2 Minutes, DEC2 Seconds, DEC2 suseconds]
    return
    
    Sub2:
        HSEROUT ["You sent Blue"]
    
    
    Sub3:
        HSEROUT ["You send Green"]
    
    Resume
    enable interrupt
    I guess i want it to check that the qualifier is either 'Red', 'Blue', or 'Green', If it isn't then come out of the interupt and wait for the next serial string. This is the bit of code i am missing and having problems with !!

    If for example the qualifier Red is received, then it jumps to the Sub1 routine and captures the other 8 bytes.

    Am i on the right tracks with what i have done so far? Can you assist with the qualification side?

    Cheers,

    Steve

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