does this piece of code look ok?


Results 1 to 27 of 27

Threaded View

  1. #10
    Richardco's Avatar
    Richardco Guest


    Did you find this post helpful? Yes | No

    Question

    Thankyou air1kdf,
    that does look a lot easier to understand, i didnt know you could use 'DO' and am now going to read about it in the manual, Its funny because when you look at the code you have written yourself it looks very clear but when someone such as yourself looks at it and puts a new slant on things it seems obvios, But still i have a good excuse " Im still at primary grade where all this is concerned, i do hope that you realise how thankfull people like me are to have people like you to ask.

    can i just ask this question about your code: this is just a snippet,

    Do
    Serin2 pinin1, 188, [testbyte] ' read portc.1
    If testbyte = "$" Then
    Serout2 pinout, 188, [testbyte]
    Do
    Serin2 pinin1, 188, [testbyte]
    If testbyte = "$" Then


    the data is read from pin 1
    the data is checked to see if it conformes
    if the data conforms the program progresses

    if the data does not conform then what happens??

    it should keep checking the pin till the data conforms but i cant see this with your piece of code.
    i have commented my code now so you can see what i wanted to achieve more easily, and here is a part to read from one pin and move on to the next pin if data is validated and if not to continue checking till it is, i am not sure if i have correctly understood the timeouts (,500,start2,) but ignore them if they are wrong please.


    start1:
    LOW PORTB.0 ' Reset data led to low
    Serin2 pinin1,188,500,start2,[testbyte] ' Read portc.1
    if testbyte = "$" then begin1 ' Test Charactor
    goto start1 ' Loop till correct

    begin1:
    LOW PORTB.6 ' Reset data led to low
    HIGH PORTB.1 ' Show data found at pin
    Serout2 pinout,188,[testbyte] ' Send data out
    high PORTB.0 ' Show data is sent out
    goto loop1 ' Enter main loop 1

    loop1:
    Serin2 pinin1,188,500,start2,[testbyte] ' Read portc.1
    if testbyte = "$" then start2 ' Test Charactor
    Serout2 pinout,188,[testbyte] ' Send data out '
    goto loop1 ' Loop till correct

    Thankyou for your time once more.



    Hi Melanie, ok thankyou for your observation, i am aware of the data that will be missed as im only reading one pin at a time, but i figured that in the time it takes to read the other pins, the data from the other instruments would not of changed that much anyhow, and for instance im chugging along in my little pleasure fishing boat, how far would i have moved in the time it takes to read a pin for the second time?, and the other instruments that will be attached are much the same, there will be a gps, a weather instrument , a sounder and velocity readings. So im HOPING that the missing data will be of no consequence, and untill i try it i will not know. But thankyou anyhow. By the way "I just thought I'd burst your bubble" Sorry that burst the day i realised i would have to work for a living lol

    Ok now here is the question i do not know the answer to if i am mistaken about the missing data.

    I can see that the idea of having a pic to recieve data from each talker and a master pic to combine the data and send it out seems logical, However if all the 4 talkers are transmitting a continuous stream of data to thair respective pics at 4800baud, how will the master ever hope to transmit at 4800baud all the data it collects, i cant see how it will do it for long before it gets overloaded. If you can see what i mean? Again if my thinking is not correct please enlighten me because i know very little and i want to learn.


    And could someone please delete the other thread i started in the wrong place by mistake (and have said sorry for) as it may confuse some people.
    Last edited by Richardco; - 27th November 2005 at 00:29.

Similar Threads

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