Newbie question:


Closed Thread
Results 1 to 3 of 3
  1. #1
    Izone's Avatar
    Izone Guest

    Default Newbie question:

    How can I recompile the PicBasic code found on this page;

    http://www.rentron.com/PIC16F84.htm

    With PBC?

    I am getting errors due to the missing bs2defs.bas file.

  2. #2
    Join Date
    May 2004
    Location
    New England
    Posts
    164


    Did you find this post helpful? Yes | No

    Default

    Well, I don't know about the PBC issues, but to get around needing the "bs2defs.bas" file you should give the variables your own names (don't use the generic "b1", etc), and not use numbers for pins:

    Instead of "high3" ; make pin 3 high

    Write high PORTx.x ; x.x is port letter & pin number EX: PORTA.1

  3. #3
    Izone's Avatar
    Izone Guest


    Did you find this post helpful? Yes | No

    Default

    Thanks for your help, much appreciated.

    Is it possible to use the SERIN command in PicBasic. but use a pin on port A as the input?

    I have changed the code to this:

    Symbol PORTA = 5
    Symbol TRISA = $85
    Symbol PORTB = 6
    Symbol TRISB = $86
    symbol relay = B0
    symbol stat = B1
    symbol serpin = porta.4
    POKE TRISA,16 ' set porta.4 to input all others output
    POKE TRISB,0 ' set output to all PORTB pins

    poke porta, $00 'clear port A and B.
    poke portb, $00




    serin serpin, N2400, ("A"),relay ,B1
    loop:
    IF relay = 1 THEN outr1 ' if request is for relay#1 then goto relay#1 routine
    IF relay = 2 THEN outr2
    IF relay = 3 THEN outr3
    IF relay = 4 THEN outr4
    IF relay = 5 THEN outr5
    IF relay = 6 THEN outr6
    IF relay = 7 THEN outr7
    IF relay = 8 THEN outr8
    IF relay = 9 THEN outr9
    IF relay = 10 THEN outr10
    IF relay = 11 THEN outr11
    IF relay = 12 THEN outr12
    goto loop



    outr1:
    IF stat = 1 THEN high1 ' If status request is I/O pin#0 logic 1 [high]
    LOW 0: GOTO loop ' then make I/O pin#0 high, else make it [low]

    high1:
    HIGH 0: GOTO loop ' Make I/O pin#0 logic 1 [high]

    outr2:
    IF stat = 1 THEN high2
    LOW 1: GOTO loop

    high2:
    HIGH 1: GOTO loop

    outr3:
    IF stat = 1 THEN high3
    LOW 2: GOTO loop

    high3:
    HIGH 2: GOTO loop

    outr4:
    IF stat = 1 THEN high4
    LOW 3: GOTO loop

    high4:
    HIGH 3: GOTO loop

    outr5:
    IF stat = 1 THEN high5
    LOW 4: GOTO loop

    high5:
    HIGH 4: GOTO loop

    outr6:
    IF stat = 1 THEN high6
    LOW 5: GOTO loop

    high6:
    HIGH 5: GOTO loop

    outr7:
    IF stat = 1 THEN high7
    LOW 6: GOTO loop

    high7:
    HIGH 6: GOTO loop

    outr8:
    IF stat = 1 THEN high8
    LOW 7: GOTO loop

    high8:
    HIGH 7: GOTO loop

    outr9:
    IF stat = 1 THEN high9
    poke portA, $00: GOTO loop

    high9:
    poke porta, $01: GOTO loop

    outr10:
    IF stat = 1 THEN high10
    poke porta, $00: GOTO loop

    high10:
    poke porta, $02: GOTO loop

    outr11:
    IF stat = 1 THEN high11
    poke porta, $00: GOTO loop

    high11:
    poke porta, $04: GOTO loop

    outr12:
    IF stat = 1 THEN high12
    poke porta, $00: GOTO loop

    high12:
    poke porta, $08: GOTO loop

Similar Threads

  1. Newbie 74hc595 question
    By manjero in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 22nd January 2008, 22:22
  2. newbie with serial com question...
    By kevlar129bp in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 16th December 2006, 05:34
  3. Newbie Question - Info Please
    By ehoskins in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 2nd October 2006, 14:50
  4. Greetings from Newbie and a question
    By ChrisHelvey in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 24th July 2006, 15:52
  5. Newbie question
    By senojlr in forum General
    Replies: 7
    Last Post: - 11th April 2006, 21:23

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