Pass on serial data


Closed Thread
Results 1 to 16 of 16
  1. #1
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697

    Default Pass on serial data

    Hi, hopefully a simple one this time. i want my chips to startup and wait for a serial command. the serial data is (250),lineid then a string of bytes. the chip needs to send out the whole string on another pin but add 1 to the lineid. my code so far is this.

    Code:
    serin2 porta.2,n9600,[WAIT(250),lineid,str tinput\8\0]
    lineid=lineid+1
    serout2 portb.4,n9600,[250,lineid,str tinput\8]
    this works fine aslong as i send 8 bytes after the line id. is there a way i can make it wait for 250 and the lineID then take whatever it can after that and pass it on?

    the chips will be linked to each other but they dont know how many chips there are and the string of bytes is (4 * number of chips) long

    also, how do i tell how many characters came in? is there a len() function like VB or ubound()? if not then i know a way i can work round it

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    If you get 8 characters, you send them off...

    If you get 5 characters, how do you know that's all you're going to get?
    Is it a timed thing? Is the 5th character a CR or LF or something that would be recognizable?

  3. #3
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    If you get 8 characters, you send them off...

    If you get 5 characters, how do you know that's all you're going to get?
    Is it a timed thing? Is the 5th character a CR or LF or something that would be recognizable?
    hmm. good point. i can make it so theres only 2 characters per chip and i can send something like (255) to show the end of the data.

    that means the chip reacts to [250],lineid,[1],[2],[3],[4],[255] AND [250],lineid,[1],[255]. how would i do that?

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


    Did you find this post helpful? Yes | No

    Default

    I could analyse the STR macro, but i'm lazy today

    So you could still fill ALL variable array cells with zero before SERIN, and after SERIN checking which one is still = 0.
    Steve

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

  5. #5
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    yep. thats my workaround way :P i wont have to check them after though, just set them to the correct outputs

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


    Did you find this post helpful? Yes | No

    Default

    One thing i could feel... the internal R0 variable should store the last character. Seems there's no counter variable. For that i would prefer to build my own routine BUT using the PIC USART... no SERIN/DEBUGIN/HSERIN at all.
    Steve

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

  7. #7
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    One thing i could feel... the internal R0 variable should store the last character. Seems there's no counter variable. For that i would prefer to build my own routine BUT using the PIC USART... no SERIN/DEBUGIN/HSERIN at all.
    ill have a look into that later. isnt there a way of doing it with serin2? eventually i will need to use the timeout things too

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


    Did you find this post helpful? Yes | No

    Default

    If your PIC have a USART and you need only 1 SerialInput pin, there's no advantage to use SERIN, SERIN2, DEBUGIN. Even if you need only 1 SerialInput pin, there's no real advantage to not choosing a PIC without USART.

    With a built-in USART, the whole thing could be hapilly managed with interrupts, which it's not really reliable with SERIN... unless you send tons of 'preamble' NULL character or so.

    Yeah, i'm from an old school
    Steve

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

  9. #9
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    i cant do anything with interrupts. ive already made the PCBs up for these circuits and the only interrupt pin is an output. i never thought i would need it

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


    Did you find this post helpful? Yes | No

    Default

    can you post your schematic?
    Steve

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

  11. #11
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    can you post your schematic?
    sure, here it is.


    i spoke with a really clever electronics guy today about that capacitor thing mentioned in the last thread. he showed me the best way to do it but its not done in this circuit obviously.

    the only interrupt pin is RB0 which is the 4th pin up on the left and thats in use on the first triac optoisolator


    Edit: aparently the bmp is too big. sorry for the jpeg quality
    Attached Images Attached Images  

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


    Did you find this post helpful? Yes | No

    Default

    no i meant a real schematic, not a board layout
    Steve

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

  13. #13
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    no i meant a real schematic, not a board layout
    oh, erm. i havnt got one. sorry

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


    Did you find this post helpful? Yes | No

    Default

    mm, so you could move what's on RC7 to RC5, and free BOTH USART pin? yeah some PCB mods... no harm, but bit of pain i agree..
    Steve

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

  15. #15
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    mm, so you could move what's on RC7 to RC5, and free BOTH USART pin? yeah some PCB mods... no harm, but bit of pain i agree..
    i could but as i said ive already etched the PCBs as i didnt have any need to use the interrupt pin. any new circuits i do ill always use the interrupt pin as the serial input.

    suppose if theres no other way to do it then i can just write my VB app to always send out so many characters

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


    Did you find this post helpful? Yes | No

    Default

    Maybe not impossible... still doable... just longer... let's see how your tests will go!
    Steve

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

Similar Threads

  1. Using Nokia LCD
    By BobP in forum mel PIC BASIC Pro
    Replies: 300
    Last Post: - 3rd May 2018, 04:47
  2. Read/Write Problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 10th February 2010, 01:51
  3. Big characters on HD44780 4x20
    By erpalma in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 7th January 2007, 02:21
  4. LCD + bar graph
    By DynamoBen in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 5th October 2005, 14:50
  5. Sinus calculating !
    By Don Mario in forum mel PIC BASIC Pro
    Replies: 29
    Last Post: - 28th November 2004, 23:56

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