Anyone ever decoded CAN on a PIC?


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2005
    Location
    Bellevue
    Posts
    125

    Unhappy Anyone ever decoded CAN on a PIC?

    All:

    Compressed Alphanumeric Code, or CAN code, allows a 16 bit value to represent 3 characters from the set A-Z, 0-9 and the colon, period and dollar sign symbols.

    HEX CAN HEX CAN HEX CAN
    0 0 0
    640 A 28 A 1 A
    C80 B 50 B 2 B
    12C0 C 78 C 3 C
    1900 D A0 D 4 D
    1F40 E C8 E 5 E
    2580 F F0 F 6 F
    2BC0 G 118 G 7 G
    32C0 H 140 H 8 H
    3800 I 168 I 9 I
    3E40 J 190 J A J
    4480 K 1B8 K B K
    4B00 L 1E0 L C L
    5140 M 208 M D M
    5780 N 230 N E N
    5DC0 O 258 O F O
    6400 P 280 P 10 P
    6A40 Q 2A8 Q 11 Q
    7080 R 2D0 R 12 R
    76C0 S 2F8 S 13 S
    7D00 T 320 T 14 T
    8340 U 348 U 15 U
    8980 V 370 V 16 V
    8FC0 W 398 W 17 W
    9600 X 3C0 X 18 X
    9C40 Y 3E8 Y 19 Y
    A280 Z 410 Z 1A Z
    A8C0 0 438 0 1B 0
    AF00 1 460 1 1C 1
    B540 2 488 2 1D 2
    BB80 3 4B0 3 1E 3
    C1C0 4 4D8 4 1F 4
    C800 5 500 5 20 5
    CE40 6 528 6 21 6
    D480 7 550 7 22 7
    DAC0 8 578 8 23 8
    E100 9 5A0 9 24 9
    E740 : 5C8 : 25 :
    ED80 . 5F0 . 26 .
    F3C0 $ 618 $ 27 $

    Sample Conversions For "EVI"

    To convert to CAN code from ASCII, locate the letter in the tables from left to right, and summing the values indicated. For example:

    E = 1F40
    V = 370
    I = 9
    22A9

    To convert from CAN code to ASCII, start with the left most column and locate the largest value that does not exceed the CAN code value. Subtract the indicated value and repeat using the remainder for the second and last columns. For example, given the value #35A5:

    35A5
    -3200 H
    3A5
    -398 W
    D M

    The CAN code value #35A5 results in the letters HWM.

    OK - So, for the really smart ones - can you hint at a structure that can figure that out in PicBasic? I really don't want to load the whole table into memory!!

    I need to take in the CAN code, and return the 3-letter result....

    TG

  2. #2
    EDWARD's Avatar
    EDWARD Guest


    Did you find this post helpful? Yes | No

    Default

    you might what to decode the table in like a visual basic program then copy it into picbasic. those are more powerful for database projects. you can load a txt file as a .dat file into vb6 and sequentially read a set of numbers, perform alg and repeat.
    if im way off sory, i didnt know of CAN.

    i have vb6 progs i made but they only read comma seperated values and im not sure how big your table is and if putting comma in there would be an option.

    or



    is the reason you used CAN so that you could compress your data down? and you need it t reside in the memory, but ascii wouldnt fit? or is it like a learning project?
    Last edited by EDWARD; - 7th May 2005 at 07:13.

  3. #3
    Join Date
    Feb 2005
    Location
    Bellevue
    Posts
    125


    Did you find this post helpful? Yes | No

    Smile Figured out CAN conversion - posting in case anyone ever needs it..

    ' Read the TracID into the 3 letters represented

    16 bits are in SSD1-SSD4:

    SSD4= (ssmax[1]>>4)
    SSD3= (ssmax[1] & $f)
    SSD2= (ssmax[0]>>4)
    SSD1= (ssmax[0] & $f)
    TracID_D=(ssd4*4096)+(ssd3*256)+(ssd2*16)+ssd1 ' convert to dec

    TC1=(TracID_D/1600)
    Select Case TC1
    case 0
    TracID1 = " "
    case TC1 < 27 'A-Z
    TracID1 = TC1 + 64
    case TC1 < 37 '0-9
    TracID1 = TC1 + 21
    case 37
    TracID1 = ":"
    case 38
    TracID1 = "."
    case else
    TracID1 = "$"
    End Select

    t2=TracID_D-(TC1*1600)
    TC2=t2/40
    Select Case TC2
    case 0
    TracID2 = " "
    case TC2 < 27 'A-Z
    TracID2 = TC2 + 64
    case TC2 < 37 '0-9
    TracID2 = TC2 + 21
    case 37
    TracID1 = ":"
    case 38
    TracID1 = "."
    case else
    TracID1 = "$"
    End Select

    TC3=t2-(TC2*40)
    Select Case TC3
    case 0
    TracID3 = " "
    case TC3 < 27 'A-Z
    TracID3 = TC3 + 64
    case TC3 < 37 '0-9
    TracID3 = TC3 + 21
    case 37
    TracID1 = ":"
    case 38
    TracID1 = "."
    case else
    TracID1 = "$"
    End Select


    TracID1, TracID2, TracID3 will be the 3 letters..

    TG

Similar Threads

  1. SMS via pic
    By kenandere in forum GSM
    Replies: 15
    Last Post: - 10th March 2010, 10:00
  2. Replies: 67
    Last Post: - 8th December 2009, 02:27
  3. HSERIN & Interupts (aka controlling PIC programs from a remote PC)
    By HankMcSpank in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 17th June 2009, 14:46
  4. pic to pic ir link versus wired link : help please anyone
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 30th May 2008, 21:01
  5. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th March 2005, 23:14

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