PC serial port funny


Closed Thread
Results 1 to 14 of 14

Hybrid View

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

    Default

    O.K. i'll look at that. So you're using a 16F628 right? for serial comm, i would suggest you to use a crystal. To make sure to don't miss incoming stuff, i always suggest to use a USART interrupt.

    this
    Code:
    ["aa", stepcnt]
    can't work because it will send a WORD ascii character... wich is impossible. So instead, you should work around and use
    Code:
    ["aa", #stepcnt]
    but use VAL on the VB side.

    I'll do a little something here, totally different, so you could use some part of it in your actual code.
    Steve

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

  2. #2
    Join Date
    Aug 2006
    Posts
    20

    Talking

    Thanks, I,m using a Xtal, found that out the hard way, could'nt work out why there were so many errors, after puting xtal in cct, errors disappeared. And yes, I'm using a 628.

    I kind of figured that "aa" stepcnt was a word representation of stepcnt and that on the other end it would need to be split in two to find the original values. I started off with #stepcnt but on the vb side after sending a whole bunch of words, errors started appearing. Never thought of the VAL function though. I just placed the value from the PIC straight into a txt box. Anyway, I hope my code is not to painfull.

    Thanks again

    John

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

    Default

    OK then, so i'll stop it here and skip the USART interrupt. In meantime, maybe you could use/read some part of what i've include.

    What i did is to use a fixed string format using DEC5 modifier on the PIC side
    Code:
    hserout ["aa",DEC5 WordA]
    So it always send 7 bytes to the PC

    and on the PC side, i split the incoming string in 2 parts
    Code:
            sWichOne = Mid(IncommingData, 1, 2)     ' get the header (two first character)
            wValue = Val(Right(IncommingData, 5))   ' get the value (5 last character)
    Where IncommingData = MSComm1.Input, sWichOne hold the "aa", "bb" or else 2 character header, wValue hold the decimal value after the header.

    no big deal.
    Attached Files Attached Files
    Last edited by mister_e; - 12th January 2007 at 23:40.
    Steve

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

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

    Default

    Bah, why not after all. This one use the USART interrupt. Thanks to Darrel instant interrupts... reduce indeed RTFM sessions to a minimum
    Attached Files Attached Files
    Steve

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

  5. #5
    Join Date
    Aug 2006
    Posts
    20

    Smile

    Thanks Steve,

    I've just opened up the files the files you sent and begin to incorporate into my project. I'll let you know how I went, hopefully all good.


    Cheers

    John

  6. #6
    Join Date
    Aug 2006
    Posts
    20

    Thumbs up

    Thanks Steve. Eventually got back to my project. (To much time spent on this thing, so the missus says). Anyway, it works a treat. Iv'e added a couple more things to it as now the comms side of it works fine. I am considering using the picf88 for its ADC to measure battery voltgae.

    Thansk again Steve,

    John

  7. #7
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343

    Talking Beware the Dark Side of the PIC!!!

    Quote Originally Posted by nicjo View Post
    ...To much time spent on this thing, so the missus says...
    Listen to her! Mister_e (and Darrel Taylor) can attest to the "life ruining power " of the humble PIC if not dealt with in moderation.

    LOL,
    SteveB

    "Problems lead to Learning...Learning leads to Feature Creeep... Feature Creep leads to Obsession...
    Obsession leads to the Dark Side of the the PIC"
    Last edited by SteveB; - 19th January 2007 at 13:27.

Similar Threads

  1. Send binary file to pic over pc serial port
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 3rd May 2011, 13:47
  2. interfacing to the pc serial port
    By kelangfei in forum General
    Replies: 4
    Last Post: - 7th October 2007, 22:35
  3. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  4. Replies: 2
    Last Post: - 28th April 2006, 12:10
  5. PC Serial Port Connections
    By BigH in forum Serial
    Replies: 1
    Last Post: - 20th January 2006, 08:24

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