Code Compatibility Issue


Closed Thread
Results 1 to 22 of 22

Hybrid View

  1. #1
    Join Date
    Feb 2006
    Posts
    20

    Default Code Compatibility Issue

    Hello, I am working on a program that checks the continuity of several circuits and processes the data to genarate several output signals. I have the code working flawlessly on my 16F84A but when I run the same code on other PICs such as the 16F88 and 16F767 it does not run properly. The code seems to constantly reset the output signals resulting in a signal that rapidly switches from high to low when it should be steady high or low (this is probably not the only thing that the code is doing wrong). I have disabled the ADC module and the comparators on the PICs that have them and I have no idea what I am doing wrong. I have tried disabling the watchdog timers and changing a few other configuration setting but nothing seems to work. My final application will most likly use a PIC16F57 so just using the F84A is not an option. Does anyone have any ideas about what I might be doing wrong.
    Thanks!

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by ALFRED View Post
    Hello, I am working on a program that checks the continuity of several circuits and processes the data to genarate several output signals. I have the code working flawlessly on my 16F84A but when I run the same code on other PICs such as the 16F88 and 16F767 it does not run properly...................Does anyone have any ideas about what I might be doing wrong.
    Thanks!
    PBP, the actual text based source code is relatively transferrable between PICs. However, at the actual binary level, trying to run code for a 16F84a on anything will get you nothing but trouble. You'll probably only have to recompile it for the PIC you want to use. At any rate, you MUST check the datasheets to see the main differences between the 2 types of PICs, the differences in the pins, differences in registers, etc. You can't just go slappin' one PICs code into another type and expect it to work.

  3. #3
    Join Date
    Feb 2006
    Posts
    20


    Did you find this post helpful? Yes | No

    Default

    I have been recompiling the code for the PIC I want to use all along and it still does not work. My hardware is built so that all the corsponding I/O pins on ports A and B are conected to the same things on each PIC. In my own experience I have been able to use the PIC16F767 normaly by disabling the ADC and the comparator but this time that doesnt seem to be enough. Any other ideas?

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by ALFRED View Post
    Any other ideas?
    Without seeing any code, yes, I do have an idea...
    Show some code...

  5. #5
    Join Date
    Jun 2006
    Posts
    20


    Did you find this post helpful? Yes | No

    Smile what compiller

    hi its andrew i just compilled your program using micro code studio (pic basci pro compiller ) and it compiles fine microcode studio is a free download
    i don't know what compiller editor software you are using but you could try these 2 programs


    andrew

  6. #6
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default W. A. G.

    Hi Andrew,
    Just a Wild Arse Guess on my part, but the config registers look much more complicated on that particular chip than the 16f84, which is simple. See 15.1 of the data sheet for more confusion.
    JS
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  7. #7
    Join Date
    Feb 2006
    Posts
    20


    Did you find this post helpful? Yes | No

    Default

    Here's the code:

    TRISA = 0
    TRISB = 2
    CMCON = 7
    ADCON1 = %00001111
    ADCON0 = 0

    symbol Off_1 = PortA.0
    Symbol On_1 = PortA.1

    symbol Off_2 = PortA.2
    symbol On_2 = PortA.3

    Symbol Speaker = PortA.4

    SYMBOL Ground_1 = PortB.0
    SYMBOL Positive_1 = PortB.1
    symbol Lame_1 = PortB.2

    symbol Ground_2 = PortB.3
    Symbol Positive_2 = PortB.4
    Symbol Lame_2 = PortB.5

    SYMBOL Switch = PortA.5
    symbol LED_1 = PortB.6
    Symbol LED_2 = PortB.7


    Positive_Ground_1 var bit
    Ground_Lame_1 var bit
    Positive_Lame_1 var bit
    Positive_Bell_1 var bit

    Positive_Ground_2 var bit
    Ground_Lame_2 var bit
    Positive_Lame_2 var bit
    Positive_Bell_2 var bit

    PG1_Count var byte
    PG2_Count var byte
    PL1_Count var byte
    PL2_Count var byte
    Cal var byte
    Lockout var Word
    Lockout_Cal var word

    On1_Flag var bit
    Off1_Flag var bit
    On2_Flag var bit
    Off2_Flag var bit

    let cal = 18
    let lockout_cal = 373

    '''''''''''''
    high on_1
    pause 500
    low on_1
    high off_1
    pause 500
    low off_1
    high off_2
    pause 500
    low off_2
    high on_2
    pause 500
    low on_2
    '''''''''''''''

    input lame_1
    INPUT LAME_2
    Foil:
    input positive_1
    input positive_2
    input ground_1
    input ground_2
    high positive_1
    let positive_ground_1 = Ground_1
    let positive_lame_1 = lame_2
    let positive_bell_1 = ground_2
    low positive_1

    input positive_1
    input positive_2
    input ground_1
    input ground_2
    high positive_2
    let positive_ground_2 = ground_2
    let positive_lame_2 = lame_1
    let positive_bell_2 = ground_1
    low positive_2
    input positive_2
    high ground_1
    let ground_lame_1 = lame_1
    low ground_1

    INPUT GROUND_1
    high ground_2
    let ground_lame_2 = lame_2
    low ground_2

    if positive_ground_1 = 0 and positive_bell_1 = 0 then
    let pg1_count = pg1_count + 1
    else
    let pg1_count = 0
    endif

    if positive_ground_2 = 0 and positive_bell_2 = 0 then
    let pg2_count = pg2_count + 1
    else
    let pg2_count = 0
    endif

    if positive_lame_1 = 1 AND POSITIVE_GROUND_1 = 0 then
    let pl1_count = pl1_count + 1
    else
    let pl1_count = 0
    endif

    if positive_lame_2 = 1 AND POSITIVE_GROUND_2 = 0 then
    let pl2_count = pl2_count + 1
    else
    let pl2_count = 0
    endif


    if pl1_count => cal then
    high on_1
    let on1_flag = 1
    endif

    if pl2_count => caL then
    high on_2
    let on2_flag = 1
    endif

    if pg1_count => cal AND PL1_COUNT < CAL then
    high off_1
    let off1_flag = 1
    endif

    if pg2_count => cal AND PL2_COUNT < CAL then
    high off_2
    let off2_flag = 1
    endif

    LET LED_1 = GROUND_LAME_1
    LET LED_2 = GROUND_LAME_2

    if On1_flag = 1 or off2_flag = 1 or on2_flag = 1 or off1_flag = 1 then
    let lockout = lockout + 1
    else
    let lockout = 0
    endif


    if lockout => lockout_cal then
    pause 2000
    low on_1
    low on_2
    low off_1
    low off_2
    let on1_flag = 0
    let on2_flag = 0
    let off1_flag = 0
    let off2_flag = 0
    endif
    goto foil

    end

Similar Threads

  1. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 21:31
  2. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  3. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  4. Code Issue - select case or 'if' issue - not sure why
    By jamie_s in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 7th October 2007, 08:52
  5. Code Issue? - Pin Labels
    By jamie_s in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 12th July 2006, 16:28

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