PIC16F88 senior design


Closed Thread
Results 1 to 40 of 72

Hybrid View

  1. #1
    Join Date
    Apr 2007
    Posts
    21

    Default

    I'm now working on sending serial data from our bluesmirf through the pic straight into the serial input port of our LCD. One of my partners currently is working on his java program and has the pic at home so I can't test the code that I have till tomorrow afternoon, but the code I wrote compiles fine and uses a similar format to the code that skimask showed me (baring the backlight activation part).

    @ DEVICE MCLR_OFF, PROTECT_OFF, WDT_OFF
    INCLUDE "modedefs.bas"
    DEFINE LCD_LINES 2
    ANSEL = %00000000
    SERIALDATA var byte
    STORAGE VAR BYTE
    MAIN:
    SEROUT PORTB.0,T9600,[STORAGE]
    SEARCHLOOP:
    SERIN PORTA.0,T9600,[SERIALDATA]
    if SERIALDATA <> "A" then goto SEARCHLOOP
    SERIN PORTA.0,T9600,STORAGE: SEROUT PORTB.0,T9600,[STORAGE]
    GOTO MAIN

    I'm not sure if SERIN, and SEROUT work this way, but what I understand from what I've read and seen is that the serin command will put it's data in the variable byte "STORAGE" that I created and then the SEROUT will send out the serial data that is stored in that variable byte. Does the code look good? Or am I a bit off on my logic. Also I'm not fully sure what the first line does, but I saw it on another project doing serial communication with a PIC16F88 and what I do know about those commands it seems to make sense, it also hasn't hurt anythign I've done so far.

    PS:
    Skimask your smart "S-M-R-T....... I mean S-M-A-R-T" thanks a lot for your help so far.

  2. #2
    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.

  3. #3
    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

  4. #4
    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?

  5. #5
    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...

  6. #6
    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

  7. #7
    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.

  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?

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