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 mackrackit View Post
    These are in the FACT section.
    True that they are FACTs, but don't you mean FAQ section?

  2. #2
    Join Date
    Apr 2007
    Posts
    21

    Default

    So if I want to use an analog input for port A I need to include a line of code such as this:

    ANSEL = %00001111

    if I want PORTA.0-PORTA.3 to be analog inputs, but if I'm getting serial data in through these pins can I keep them as digital input/output ports and just use the first digital high that comes in from the serial information to activate some output on another pin? Also I found a project that used the code 'ADCON1.7 = 1' to align bit 7 to be right justified and then 'ADCON1.4 = 0' and 'ADCON1.5 = 0' to default to using Vref. When I'm not doing any analog to digital conversion I shouldn't need any of these commands should I?

  3. #3
    skimask's Avatar
    skimask Guest

    Default

    Quote Originally Posted by AlaskanEE View Post
    So if I want to use an analog input for port A I need to include a line of code such as this:
    ANSEL = %00001111
    if I want PORTA.0-PORTA.3 to be analog inputs, but if I'm getting serial data in through these pins can I keep them as digital input/output ports and just use the first digital high that comes in from the serial information to activate some output on another pin? Also I found a project that used the code 'ADCON1.7 = 1' to align bit 7 to be right justified and then 'ADCON1.4 = 0' and 'ADCON1.5 = 0' to default to using Vref. When I'm not doing any analog to digital conversion I shouldn't need any of these commands should I?
    Basically, the deal is, you have to look at the register's default values (the little numbers above the blocks in the register descriptions in the datasheets). If it says 'R/W-0', then it's a read/write register and on RESET(MCLR), it's set to '0'...and so on...

    So basically, you're on the right track with what you said. I don't have the datasheet handy, you could be right on the bits, if that's what you read, then that's what it is.

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

    Default

    Quote Originally Posted by skimask View Post
    True that they are FACTs, but don't you mean FAQ section?
    Details,Details,Details. FACTs in the FAQ section.

    So if I want to use an analog input for port A I need to include a line of code such as this:

    ANSEL = %00001111
    Check the data sheet for the PIC you are using. I have not used the 16F88 yet, some PICs are a little different.

    if I want PORTA.0-PORTA.3 to be analog inputs, but if I'm getting serial data in through these pins can I keep them as digital input/output ports and just use the first digital high that comes in from the serial information to activate some output on another pin? Also I found a project that used the code 'ADCON1.7 = 1' to align bit 7 to be right justified and then 'ADCON1.4 = 0' and 'ADCON1.5 = 0' to default to using Vref. When I'm not doing any analog to digital conversion I shouldn't need any of these commands should I?
    Something like that.
    Each analog pin can be set to digital or analog.
    If you use serial the pin will have to be set as digital - true.
    If you are not using any analog, set all as digital.

    first digital high that comes in from the serial information to activate some output on another pin?
    NO, serial does not work that way. When a serial signal say XYZ comes in something could be made to happen. If serial ABC comes in something else could happen. If serial QST comes in it could be ignored.

    A digital LOW state is 0 to around 2 volts. Digital HIGH is around 3.6 to 5 volts.

    In between is FUZZY
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Apr 2007
    Posts
    21

    Default

    What if I told my partner to have his program send an ASCII character, say, "A" before any message is sent to our bluesmirf which is connected to our LCD through my PIC. Could I use that character to activate a series of commands that would send the correct hexadecimal code to the LCD to activate the backlight then wait 10 seconds then send the code to turn off the backlight? Something like this:

    INCLUDE "modedefs.bas"

    SEROUT PORTB.1,T9600,[1]

    SERIN PORTA.1,T9600,["A"]

    IF PORTA.1 = "A" THEN
    PORTB.1 = $FE
    PORTB.1 = $96
    PAUSE 10000
    PORTB.1 = $FE
    PORTB.1 = $80
    endif

    I'm almost sure that's not right since I'm not sending out serial data just hexadecimal numbers, but can I use the serin/serout commands inside the IF/Then statement? or am I closer than I think.

  6. #6
    skimask's Avatar
    skimask Guest

    Default

    INCLUDE "modedefs.bas"

    SEROUT PORTB.1,T9600,[1]

    SERIN PORTA.1,T9600,["A"] ---- this would only wait for the "A" character, it wouldn't save it anywhere or do anything with it...

    IF PORTA.1 = "A" THEN ---- again, you haven't saved your "A" character anywhere
    PORTB.1 = $FE ---- it's a bit output that you're trying to send a byte out of, that don't work, but I think you already know that...


    What you probably want is:

    INCLUDE "modedefs.bas"
    inputdata var byte
    main:
    SEROUT PORTB.1,T9600,[1] 'trigger something somewhere else
    waitloop:
    SERIN PORTA.1,T9600,[inputdata]
    if inputdata <> "A" then goto waitloop
    serout portb.1,T9600,$FE, $96: pause 10000:serout portb.1,T9600,$FE,$80:goto main
    goto main

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

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

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

Similar Threads

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