Leading 0's or BCD


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2005
    Posts
    93

    Exclamation Leading 0's or BCD

    let's say i have this command:

    SEROUT serpout, N9600, "A",#RRECADD,"B",#RBITVALUE,"C","227","D"]

    in which RRECADD and RBITVALUE are decimal byte variables which vary in length depending on if its like a 3 or a 255 in between the A - B etc.. ie. there are no leading 0's on the smaller values to "space out" the number of charecters in the string.


    The thing is i think my pc side and it's parsing routines would benefit (our parsing wouldnt fail as much due to incomplete "packets" or packets in which two A's appear in the same received string) if we could limit the input to a fixed number of bytes to receive (which we can do using visual basics mscomm control using the OnComm / comEvReceive events and setting the MSComm1.InputLen to whatever our complete data packet is going to be) then our data to parse would be what we sent and (hopefully) no more or less. The project is trying to implement a 2 way communication via PIC's, PC, and it uses TWS-434 and RWS-434 modules to do so at (eek only) N1200 (ok no so bad it's pretty reliable)

    The major problem is i cant count the length of my outgoing data string before i send it, i wanted to "fill" "packets" that were short charecters based on a subtracted total. But no length or LEN feature, so how to do this?

    I'm even considering converting to BCD (binary coded decimal) to transmit (does seem like much of a solution considering i would be - i think - increasing the amount of transmission for the same amount of actual data). But BCD values would give the desired fixed length

    I understand that this non byte array / buffer method of communication is "lossy" but i'm mostly interested in speed of data exchange (as close to real time as possible), data integrity is secondary, (its mostly reliable using this sort of "push" and "poll" method)
    Last edited by RYTECH; - 27th December 2005 at 02:06.

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Hi RYTECH,

    Use a Fixed width DECimal modifier with SEROUT2.

    SEROUT2 serpout, 16468, ["A",DEC3 RRECADD,"B",DEC3 RBITVALUE,"C","227","D"]
    <br>
    DT

  3. #3
    Join Date
    Jul 2005
    Posts
    93


    Did you find this post helpful? Yes | No

    Default

    Yes, i've made the switch to serout2 and serin2,

    why even have a "serout" and a "serin" they pretty useless, just add's to a newbies confusion.

    Thanks for your reply, i might of still been pulling out my hair trying to figure this one out...lol

  4. #4
    Join Date
    Jul 2005
    Posts
    93


    Did you find this post helpful? Yes | No

    Smile

    I'd like to be using the hardware serial ports on my pic's for my current project.

    The current project is a PC to TRANSMITTER PIC out wireless to remote side which receives wireless and tranmits back to RECEIVER PIC and then to pc. I'm going to use 2 chips on both sides. Currently I dont believe that i'm utilizing the features of the 2 pic's im using (we'll actually soon to be 4) on the "PC side" im using 2 PIC16F767 chips, currently the remote side is just a single 16F84A @ 4mhz. i'm going to be using 2 P16F872's when i put 2 chips on that side...i know pin overkill, I probobly only require 1, but im trying to keep things as "real time" as possible, and 2 chips yeilded speed inprovements for "the system" so i accepted the method. I'm sure there's ways to do with 1 chip a side, if anybody would like to tell me this, while keeping the system close to "real time" i'd appreciate it. Any good howto's i havent read yet. I'm thinking of attaching my holtek encoders to the other pins on the tx and rx chips, adding tx and rx endoder / decoder and have a switching mode to use the pic to send signals and receive, or the encoders /decoders. I may build some "thing" that i want to have feeding into a holtek chip. I wonder how the pic and holtek chips will handle sharing the antenna's. Oh can i use my same antenna thats another big question to work out. currently the RWS-434's and the TWS-434's have their own antenna's. The TWS-434 apparently can operate without the antenna, but i keep em on anyways. It would be ideal, from a design perspective, if all the rx and tx systems on either side could have 1 antenna for tx rx.

    And crystals... 20mhz seems to be what im using (except on the soon to be phased out 16F84A@4mhz). Can we do as Melanie had suggested and hook up the osc pins? ( http://www.picbasic.co.uk/forum/showthread.php?t=575 ) is there a schematic floating around with the exact configuration for the sake of clarity.

    Hardware serial ports, how to use those... they'd likely be better that just using 2 pins assigned as the rx /tx and serin2 seriout2. I've got some reading to do....
    Last edited by RYTECH; - 28th December 2005 at 01:16.

Similar Threads

  1. Bcd Fomat Help
    By Santana in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 28th November 2012, 06:00
  2. Can we suppress leading zero's in LCDOUT?
    By PICn-It in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 16th December 2009, 16:09
  3. DS1302 16F628 Woes
    By idtat in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 15th January 2009, 14:15
  4. Rotary BCD
    By Tobias in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th October 2007, 03:04
  5. Real time clock... what a headache!
    By Eng4444 in forum mel PIC BASIC
    Replies: 2
    Last Post: - 8th June 2006, 21:56

Members who have read this thread : 1

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