does this piece of code look ok?


Closed Thread
Results 1 to 27 of 27

Hybrid View

  1. #1
    Richardco's Avatar
    Richardco Guest

    Default does this piece of code look ok?

    im using the example code and changing it around as listed below and i wondered if instead of just having portc.6 as the input pin, i could have several input pins?? as listed below



    ' PicBasic Pro Code that demonstrates the use of modifiers
    ' with the Serin2 and Serout2 commands.

    testword VAR WORD ' Define word variable
    testbyte VAR BYTE ' Define byte variable
    test8 VAR BYTE[8] ' Define array variable with 8 locations
    pinin1 VAR PORTC.1 ' Define serial pinin1 as PORTC.1
    pinin2 VAR PORTC.2 ' Define serial pinin2 as PORTC.2
    pinin3 VAR PORTC.3 ' Define serial pinin3 as PORTC.3
    pinin4 VAR PORTC.4 ' Define serial pinin4 as PORTC.4
    pinin5 VAR PORTC.5 ' Define serial pinin5 as PORTC.5
    pinin6 VAR PORTC.6 ' Define serial pinin6 as PORTC.6
    pinout VAR PORTC.7 ' Define serial pinout as PORTC.7

    ' For these examples, assume that the following string
    ' is being received continuously at 2400 baud on PORTC.7:
    ' "X-1011Y-546Z-F7ZZ-0001"

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Richardco
    does this piece of code look ok?
    The answer to this question simply is:

    YES it does!
    regards

    Ralph

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



  3. #3
    Richardco's Avatar
    Richardco Guest


    Did you find this post helpful? Yes | No

    Default

    Thankyou very much NavMicroSystems, i assume you know what project i am working on having read many of your posts, so could you just answer me this question as well please. If i was sending data to a device (nmea) what would be the maximum interval between transmissions before the nmea device detects an error and displays the error or is this not defined in the standard?

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


    Did you find this post helpful? Yes | No

    Default

    Richardco,

    there is no need to start two different threads regarding the same thing.

    see my reply HERE

    and please see THIS

    We are willing to help you help yourself, but we will certainly not provide you with a ready to run piece of code for your particular application.
    regards

    Ralph

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



  5. #5
    Richardco's Avatar
    Richardco Guest


    Did you find this post helpful? Yes | No

    Angry

    Im sorry for starting two threads but i began the first one in the wrong place and i saw a comment from someone regarding posting in the correct place so i changed it to here, Next the suggestion that you provide me with the completed piece of code was not a serios one as i would have thought the tone of the following statement in the post would have suggested, getting a ready built piece of code is not what i am after at all as this would teach me nothing.

    Now in the post that i started in the wrong place there is a picture, this picture shows that i do not wish to use more than one chip.

    so i assumed that although related to your method using more than 1 chip that there would be a new set of complexities involved in using 1 chip so i started a new thread. Again if this was not the correct thing to do i am sorry.

    i would now like to know where this question has been answered
    so that i can read this information and maybe get some use out of the replies

    quote:
    If i was sending data to a device (nmea) what would be the maximum interval between transmissions before the nmea device detects an error and displays the error or is this not defined in the standard?

    i do see similarities between the above question and the one below that has been posted, However it does not answer my question,

    quote:
    As there is no defined timing between the different talkers

    all that aside please forgive me if i have upset anyone.

    Now here is my code so far, and although not completed and there are no timeouts yet , being new to this i want to iron out mistakes before the code gets to complicated for me, running before i can walk as it were. I do not mind if i miss some sentances from a pin while i read another unless the recieving device minds the break in information for that particular device, im not sure how long a device can go without update from a particular talker before it objects, which i asked about it in the question above.

    If you see anything you dont think is right or you know of a more efficient way of achieving the same thing could you please let me know thanks.

    the code:-

    ' Routine to read imea sentance from a pin and send it
    ' then do the same from another pin and send it.

    testbyte VAR BYTE ' Define byte variable
    pinin1 VAR PORTC.1 ' Define serial pinin1 as PORTC.1
    pinin2 VAR PORTC.2 ' Define serial pinin2 as PORTC.2
    pinout VAR PORTC.7 ' Define serial pinout as PORTC.7

    ' For these examples, assume that the following string
    ' is being received continuously at 4800 baud on PORTC.7:

    start1:
    Serin2 pinin1,188,[testbyte] ' read portc.1
    if testbyte = "$" then begin1
    goto start1

    begin1:
    Serout2 pinout,188,[testbyte]
    goto loop1

    loop1:
    Serin2 pinin1,188,[testbyte]
    if testbyte = "$" then start2
    Serout2 pinout,188,[testbyte]
    goto loop1

    start2:
    Serin2 pinin2,188,[testbyte] ' read portc.2
    if testbyte = "$" then begin2 '
    goto start2

    begin2:
    Serout2 pinout,188,[testbyte]
    goto loop2

    loop2:
    Serin2 pinin2,188,[testbyte]
    if testbyte = "$"then start1
    Serout2 pinout,188,[testbyte]
    goto loop2
    Last edited by Richardco; - 25th November 2005 at 22:48.

  6. #6
    Join Date
    Nov 2005
    Posts
    10


    Did you find this post helpful? Yes | No

    Default

    Your code hurts my head and is very hard for me to follow the logic because it jumps in and out so much, so this is the same code rewritten. Is this what you were intending?

    start1:
    Do
    Serin2 pinin1, 188, [testbyte] ' read portc.1
    If testbyte = "$" Then
    Serout2 pinout, 188, [testbyte]
    Do
    Serin2 pinin1, 188, [testbyte]
    If testbyte = "$" Then
    Do
    Serin2 pinin2, 188, [testbyte] ' read portc.2
    If testbyte = "$" Then
    Serout2 pinout, 188, [testbyte]
    Do
    Serin2 pinin2, 188, [testbyte]
    If testbyte = "$" Then start1
    Serout2 pinout, 188, [testbyte]
    Loop
    End If
    Loop
    Serout2 pinout, 188, [testbyte]
    Loop
    End If
    Loop

Similar Threads

  1. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 21:55
  2. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 21:31
  3. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  4. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  5. Re-Writing IF-THEN-AND-ENDIF code?
    By jessey in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 18th August 2006, 17:23

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