Serial Relays


Closed Thread
Results 1 to 4 of 4

Thread: Serial Relays

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by tazntex View Post
    Is there any supplement to this manual or other clear examples to shed some light on things like i=i+1?
    PBP is PicBasicPro...emphasis on BASIC. There really isn't a supplement to the manual for BASIC, because the whole manual is about BASIC. I can't cite any specific BASIC tutorial other than to Google it and see what you find. Your question on the 'i = i + 1' is reference, albiet indirectly in the manual. i is a variable stored in local memory. = and + are the operators. Whatever is on the right side of the = goes to the left side of the =. Therefore, whatever was in 'i', gets 1 added to it and put back in 'i'.

    And your program needs fixing..........

    Code:
    IF relay = 1 THEN outr1 
    ...............................
    IF relay = 12 THEN outr12
    Check the PBP manual under branch, save some space and headache

    Code:
    outr1:
    IF stat = 1 THEN high1 
    LOW 0: GOTO loop 
    high1:
    HIGH 0:
    gosub loop1
    low 0: GOTO loop
    HIGH 0: will be recognized as a label and not a command, same thing with the rest of the chunks in the rest of the program. You can't have a colon at the end of a line unless it's a label.

    Code:
    IF relay = 1 THEN loop
    .............................
    IF relay = 12 THEN loop
    How about this instead:

    IF relay => 0 AND relay <= 12 THEN GOTO LOOP

  2. #2
    T.Jackson's Avatar
    T.Jackson Guest


    Did you find this post helpful? Yes | No

    Post Few Down-to-earth examples

    As Ski pointed out, i is a variable. It's called a variable because, unlike fixed constants it changes. If i is a byte sized variable it can take on any form between (0-255) Whilst if it's a word sized it can be assigned with anything up to 65,536.

    When we see something like this:
    Code:
    i = i + 1
    It's basically just adding 1 to the existing contents of i. This is referred to as incrementing. So, if i = 100 and we encounter i = i + 1, the new value of i will be 101.

    For Next Loops:
    Code:
    FOR i = 1 TO 10
        j = j + 20
    NEXT
    Strangely enough, more than often we encounter i as a variable within these loops. It could be anything actually. J, K - doesn't matter. FOR NEXT loops will execute the contents between FOR and NEXT a predefined number of times which is set by the numbers after TO minus the numbers after FOR. In the example above, j will have 20 added to it 10 times. The final result of j will be 200 when the loop has finished. However, this assumes that the initial starting value of j was 0.
    <br/>
    Last edited by T.Jackson; - 17th May 2007 at 18:51.

Similar Threads

  1. Replies: 33
    Last Post: - 19th March 2010, 04:02
  2. Dynamic USB Serial Number (PIC18F4550)
    By awmt102 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 16th July 2009, 18:03
  3. PIC18F4680 to PC via MAX232 (RS232 serial) no output
    By opticsteam1 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 14th April 2008, 21:39
  4. interfacing to the pc serial port
    By kelangfei in forum General
    Replies: 4
    Last Post: - 7th October 2007, 23:35
  5. Serious Serial Situation Setbacks...
    By Dansdog in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 7th February 2007, 04:46

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