PIC16F88 senior design


Closed Thread
Results 1 to 40 of 72

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest

    Default

    Quote Originally Posted by AlaskanEE View Post
    @ DEVICE MCLR_OFF, PROTECT_OFF, WDT_OFF
    Explanations for all those configurations are in the datasheets under 'Special Features' and elsewhere.

    Skimask your smart "S-M-R-T....... I mean S-M-A-R-T" thanks a lot for your help so far.
    Keep in mind, there's literally dozens of people here much more adept with PBP/MPASM, etc.

  2. #2
    Join Date
    Mar 2005
    Location
    Iowa, USA
    Posts
    216

    Default

    AlaskanEE -
    Don't know if you ever got your hands on a PBP manual, but if you haven't, you can download one from www.melabs.com. Might help with some of those questions regarding syntax.
    Wisdom is knowing what path to take next... Integrity is taking it.
    Ryan Miller

  3. #3
    Join Date
    Apr 2007
    Posts
    21

    Default

    so the @ symbol tells the programmer that the line is asembly code directly and not PBP code and the other text just activates, or in this case deactivates the features of the PIC that I list. The serin command does store my incoming data into the variable that I put at the end and the serout sends that data that's in the brakets. But I'm worried that since I'm using an exterior 20MHz oscillator (with capacitors from the input of the oscillator to ground and from the ouput of the oscillatorto ground) that the timing might be off. I made a IF/THEN loop that sends a high pauses and sends a low then incraments my variable and will continue till my variable reaches 3 and the pauses were much to long when writen as "PAUSE 500". I thought this would pause 0.5 seconds since I used DEFINE OSC 20, but it didn't, it did however pause for about one second when I set it to "PAUSE 2". Any thoughts?

  4. #4
    skimask's Avatar
    skimask Guest

    Default

    Quote Originally Posted by AlaskanEE View Post
    I thought this would pause 0.5 seconds since I used DEFINE OSC 20, but it didn't, it did however pause for about one second when I set it to "PAUSE 2". Any thoughts?
    Show us the whole code again...

  5. #5
    Join Date
    Apr 2007
    Posts
    21

    Default

    Here's the code to activate a loop that incraments the variable x by one each time then stops after x = 4. It's activated when a message has been sent from the blue smirf to the LCD through the pic. My partner precceeds all messages with a capital A to activate the serin command.

    INCLUDE "modedefs.bas"
    DEFINE OSC 20
    INPUTDATA var byte
    X VAR BYTE
    X = 0
    MAIN:
    PORTB.5 = 0
    SEROUT PORTB.1,T9600,[1]
    WAITLOOP:
    SERIN PORTA.1,T9600,[inputdata]
    if inputdata <> "A" then goto waitloop
    LOOP:
    IF (X<4) THEN
    HIGH PORTB.5
    PAUSE 2
    LOW PORTB.2
    PAUSE 2
    X = X+1
    GOTO LOOP
    endif
    goto MAIN

    This is a very simular code that activates the noise alert pulses constantly when the whearer of our device goes out of range then turns off when it comes back in range. It's activated by recieving a low at the input pin.

    DEFINE OSC 20
    TRISB.5 = 0
    TRISB.4 = 1
    X VAR BYTE
    X = 0
    START:
    PORTB.5 = 0
    IF PORTB.4 = 1 THEN GOTO START
    IF PORTB.4 = 0 THEN GOTO LOOP
    LOOP:
    HIGH PORTB.5
    PAUSE 2
    LOW PORTB.5
    Pause 2
    IF PORTB.4 = 1 THEN GOTO START
    GOTO LOOP
    end

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default

    Did you set the OSC type in PBP *.inc file for this chip.

    And if you did what did you set it for.

    Or you can do it on this line that I do not see in the new code.

    @ DEVICE MCLR_OFF, PROTECT_OFF, WDT_OFF,_XT_OSC

    Double check the data sheet on this, I do not have it in front of me.
    Dave
    Always wear safety glasses while programming.

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

    Default

    The guy use a 20MHz, so, should be something like HS_OSC instead of XT_OSC.

    Anyways open the M16F88.inc file and enjoy the config fuse list
    Code:
    					; *** DEVICE Fuses Definitions
    EXTRC_OSC_CLKOUT equ    3FEC0013h       ; XX XXXX XXX1 XX11
    EXTRC_OSC_NOCLKOUT equ  3FEC0012h       ; XX XXXX XXX1 XX10
    EXTRC_OSC       equ     3FEC0012h       ; XX XXXX XXX1 XX10
    INTRC_OSC_CLKOUT equ    3FEC0011h       ; XX XXXX XXX1 XX01
    INTRC_OSC_NOCLKOUT equ  3FEC0010h       ; XX XXXX XXX1 XX00
    INTRC_OSC       equ     3FEC0010h       ; XX XXXX XXX1 XX00
    EXTCLK_OSC      equ     3FEC0003h       ; XX XXXX XXX0 XX11
    EC_OSC          equ     3FEC0003h       ; XX XXXX XXX0 XX11
    HS_OSC          equ     3FEC0002h       ; XX XXXX XXX0 XX10
    XT_OSC          equ     3FEC0001h       ; XX XXXX XXX0 XX01
    LP_OSC          equ     3FEC0000h       ; XX XXXX XXX0 XX00
    WDT_ON          equ     3FFB0004h       ; XX XXXX XXXX X1XX
    WDT_OFF         equ     3FFB0000h       ; XX XXXX XXXX X0XX
    PWRT_ON         equ     3FF70000h       ; XX XXXX XXXX 0XXX
    PWRT_OFF        equ     3FF70008h       ; XX XXXX XXXX 1XXX
    MCLR_ON         equ     3FDF0020h       ; XX XXXX XX1X XXXX
    MCLR_OFF        equ     3FDF0000h       ; XX XXXX XX0X XXXX
    BOD_ON          equ     3FBF0040h       ; XX XXXX X1XX XXXX
    BOD_OFF         equ     3FBF0000h       ; XX XXXX X0XX XXXX
    LVP_ON          equ     3F7F0080h       ; XX XXXX 1XXX XXXX
    LVP_OFF         equ     3F7F0000h       ; XX XXXX 0XXX XXXX
    CPD_ON          equ     3EFF0000h       ; XX XXX0 XXXX XXXX
    CPD_OFF         equ     3EFF0100h       ; XX XXX1 XXXX XXXX
    WRT_1FOURTH     equ     39FF0000h       ; XX X00X XXXX XXXX
    WRT_HALF        equ     39FF0200h       ; XX X01X XXXX XXXX
    WRT_3FOURTHS    equ     39FF0400h       ; XX X10X XXXX XXXX
    WRT_OFF         equ     39FF0600h       ; XX X11X XXXX XXXX
    DEBUG_ON        equ     37FF0000h       ; XX 0XXX XXXX XXXX
    DEBUG_OFF       equ     37FF0800h       ; XX 1XXX XXXX XXXX
    CCPMX_ON        equ     2FFF0000h       ; X0 XXXX XXXX XXXX
    CCPMX_OFF       equ     2FFF1000h       ; X1 XXXX XXXX XXXX
    PROTECT_ON      equ     1FFF0000h       ; 0X XXXX XXXX XXXX
    PROTECT_OFF     equ     1FFF2000h       ; 1X XXXX XXXX XXXX
    
    					; *** DEVICE2 Fuses Definitions
    FCMEN_OFF	equ     3FFE0000h       ; XX XXXX XXXX XXX0
    FCMEN_ON	equ     3FFE0001h       ; XX XXXX XXXX XXX1
    IESO_OFF	equ     3FFD0000h       ; XX XXXX XXXX XX0X
    IESO_ON		equ     3FFD0002h       ; XX XXXX XXXX XX1X
    interesting this DEVICE2 option... for those using PM
    Steve

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

  8. #8
    Join Date
    Mar 2005
    Location
    Iowa, USA
    Posts
    216

    Default

    I know when I was in school, they always made us flow chart out the process first. Would you be able to do something like that for us, because honestly, I'm a little confused by your program.
    some examples...
    Quote Originally Posted by AlaskanEE
    INCLUDE "modedefs.bas"
    DEFINE OSC 20
    INPUTDATA var byte
    X VAR BYTE
    X = 0
    MAIN:
    PORTB.5 = 0
    SEROUT PORTB.1,T9600,[1]
    WAITLOOP:
    SERIN PORTA.1,T9600,[inputdata]
    if inputdata <> "A" then goto waitloop
    LOOP:
    IF (X<4) THEN
    HIGH PORTB.5
    PAUSE 2
    LOW PORTB.2
    PAUSE 2
    X = X+1
    GOTO LOOP
    endif
    goto MAIN
    Quote Originally Posted by AlaskanEE
    SERIN PORTA.1,T9600,[inputdata]
    Code:
    'What is the value of inputdata the first time this runs?  If you are using "A" for a qualifier, the statement should be
    SERIN PORTA.1,T9600,["A"],inputdata
    'This statement will wait for until "A" comes in, then puts data after that into variable inputdata
    Quote Originally Posted by AlaskanEE
    IF (X<4) THEN
    Code:
    'I usually write
    IF X<4 THEN
    Did you ever get your hands on a PBP manual?
    Wisdom is knowing what path to take next... Integrity is taking it.
    Ryan Miller

  9. #9
    Join Date
    Apr 2007
    Posts
    21

    Default

    I'm trying to get the backlight of my LCD to light when a voltage high is recieved on a pin from a push button circuit. I'm testing to see if I can send A to the LCD screen then have it pause then send a B every time I input a voltage high. The loop works and it sends serial data then pauses then sends serial data then goes back to outputing low voltage till a high is recieved again. The problem is that the LCD just is showing solid squares instead of the leters that I am trying to send. I've looked up the ASCII binary, decimal, and hexadecimal equivolents for A and B and sent the numbers with %, nothing, and $ preceeding the numbers equivolently all with the same result. Here's my code.

    @ DEVICE MCLR_OFF, PROTECT_OFF, WDT_OFF
    INCLUDE "modedefs.bas"
    DEFINE OSC 20
    DEFINE LCD_LINES 2
    ANSEL = %00000000
    TRISB.1 = 0
    TRISB.0 = 1
    WAITLOOP:
    LOW PORTB.1
    if PORTB.0 = 0 then goto waitloop
    IF PORTB.0 = 1 THEN
    serout PORTB.1,T9600,[65]
    pauseus 14000
    serout PORTB.1,T9600,[66]
    ENDIF
    goto WAITLOOP

    this is the code with the decimal notation being used. I don't understand should I just try sending A i.e. serout portb.0,t9600,[A] or is that wrong as well?

  10. #10
    skimask's Avatar
    skimask Guest

    Default

    Quote Originally Posted by AlaskanEE View Post
    DEFINE LCD_LINES 2
    If you are using a parallel mode LCD (Hitachi 44780 based), then PBP requires quite a few more defines to get it to work (see the manual).
    If you are using a serial mode LCD (usually a parallel LCD mounted on a PCB with another PIC doing the decoding duties), then the DEFINE shown above isn't going to do anything for you. And you'll want to refer to the manual for the LCD.
    And it would most likely help a lot if we knew what kind of LCD you were using...
    Get the manual! And read it! We can help you with a lot of stuff...but again...I, for one, am not into hand-holding.
    Last edited by skimask; - 25th April 2007 at 23:44.

  11. #11
    Join Date
    Mar 2005
    Location
    Iowa, USA
    Posts
    216

    Default

    OK... now we're on a different subject.

    What type of LCD are you using? If it is a serial LCD, you don't need the following line.
    Code:
    DEFINE LCD_LINES 2
    If it is not a serial display and it has an HD44780 controller, you need some other LCD defines in there. But since I don't know, I'm going to assume it's a serial display. Next the serial part. Try...
    Code:
    serout PORTB.1,T9600,["A"]
    Next, the blocks on the LCD... try adjusting the contrast.

    edit: Looks like Skimask was quicker on the draw. Ignore redundant information from me.
    Wisdom is knowing what path to take next... Integrity is taking it.
    Ryan Miller

  12. #12
    Join Date
    Apr 2007
    Posts
    21

    Default

    I'm sorry, earlier I copied down my old code that was rittled with errors and didn't have the input and outputs set. Here is the new code:

    INCLUDE "modedefs.bas"
    DEFINE OSC 20
    ANSEL = %00000000
    INPUTDATA var byte
    TRISA.2 = 1
    TRISB.2 = 0
    PORTA.2 = INPUTDATA
    X VAR BYTE
    X = 0
    MAIN:
    PORTB.2 = 0
    WAITLOOP:
    SERIN PORTA.2,T9600,[inputdata]
    if inputdata <> "A" then goto waitloop
    LOOP:
    IF X<4 THEN
    HIGH PORTB.2
    PAUSE 2
    LOW PORTB.2
    PAUSE 2
    X = X+1
    GOTO LOOP
    endif
    goto MAIN

    I want pin A.2 to be the input from the bluesmirf, which will be sending messages to our LCD via serial ports. The serial data will come into the pic through porta.2. Each message that is sent by the bluesmirf will be proceeded by the letter A. I'd like porta.2 to not accept any random data and only activate the loop when a message is recieved that is preceeded by the letter A. The output should be a high then low loop that loops four times. The output should come from portb.2

  13. #13
    skimask's Avatar
    skimask Guest

    Default

    Quote Originally Posted by AlaskanEE View Post
    I don't understand should I just try sending A i.e. serout portb.0,t9600,[A] or is that wrong as well?
    Yes, that is also wrong...
    serout portb.0 , t9600 , [ "A" ]
    which is also in the manual...
    Your original line:
    serout portb.0 , t9600 , [ A ]
    will output the value equivalent to the variable A.

Similar Threads

  1. RX TX modules - intermitent communication
    By ruijc in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 11th June 2009, 00:13
  2. pic16f88 & voltage
    By rdxbam in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 17th February 2009, 09:14
  3. Ghange code from PIC16F877A to PIC16F88
    By savnik in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 12th March 2008, 16:09
  4. Replies: 8
    Last Post: - 7th December 2006, 15:42
  5. PIC16F88 problem with TOGGLE command?
    By russman613 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 17th September 2006, 23:31

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