PIC16F88 senior design


Closed Thread
Results 1 to 40 of 72

Hybrid View

  1. #1
    Join Date
    Apr 2007
    Posts
    21

    Question PIC16F88 senior design

    Hi everyone,

    I'm going to have to first state that I am the noob of all noobs. I've never taken any courses on or worked with any sort of programming prior to the senior design project that I'm working on. So in short some of my questions might be really dumb or really simple to answer. I'm programming a 16F88 PIC to complete five basic task for my part of the senior design project. We chose the 16F88 simply because it was used in an earlier lab so we had one on hand and it was the only microcontroler that I had seen any programming done on. The five main task I wish for the PIC to accomplish are as follow:

    1. To simply allow serial data in from a bluesmirf and then directly out to a LCD screen. I would like this to be acomplished using one input pin and one output pin.

    2. When the first bit of serial information is recieved from the bluesmirf, use the first high bit recieved to activate the backlight of the LCD. After 10 seconds the PIC should send the serial data to turn the backlight of the LCD off again. Again I'd like to use one input pin and one output pin.

    3. Again the same serial information should be used to send out a high voltage to be used by an audible alert circuit. The voltage should come out in a half second burst then a half second of low voltage and then repeat 3 times.

    4. A high voltage will be sent to the PIC from a push button switch. This high voltage should cause the PIC to send out the serial data to activate the backlight of the LCD for 10 seconds then turn it off.

    5. The final task for the PIC is to recieve a high voltage from the activation of a warning light LED and then send out a series of high low voltages just like in task three.

    I've written out a code that I thought would work, but it doesn't complete any of the tasks that I want it to. Some basic questions would be, can I use a single input port and a single output port for each of the tasks that I'd like to complete? If so am I assigning the ports right by using TRISA.0 = 1 to set port A.0 to input and TRISB.0 = 0 to set port B.0 to an output? I'm using the SERIN and SEROUT commands to send serial data and I understand the first command after SEROUT is the pin you want to use and the next is the baude rate you're using, but what is the next instruction for and how do I know what to assign to it? Finally can you send hexadecimal commands out of the pic Serially to be understood by the LCD? Below is a copy of the code that I have so far. Any and all help is greatly appriciated.
    Attached Files Attached Files

  2. #2
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352

    Smile

    Hi Alaskan,

    I suggest you go to www.microchip.com and download the datasheet on the 16F88 and learn about the chip. Pay particular attention to the part about analog versus digital I/O and comparators. You need to address these issues before your basic program will work. Also your individual TRIS statements can be setup as TRISA=%00000001 with PortA.0 being an input and the rest of PortA are outputs for example.

    Next I would suggest that you spend a little time looking over this forum at some of the code examples and other peoples problem that are listed to get an idea as to how to write a program and troubleshoot problems. You're off to a decent start, but you can learn alot from this forum.

    There's some great minds on this forum but they won't write your program for you. Don't get us wrong, this is YOUR PROJECT. You have to write it. When you get into a snag then ask for help. BUT the two most important things to have on hand is the PBP manual and the specific datasheet. If you don't have the PBP manual, then goto www.melabs.com and download a copy.

    I've got to go to work now.

    Have a nice day!

    BobK.

  3. #3
    skimask's Avatar
    skimask Guest

    Default

    I'm going to have to first state that I am the noob of all noobs.
    Seems like everybody is...

    So in short some of my questions might be really dumb or really simple to answer.
    Maybe so...but what's really 'dumb' or 'really simple' is when the answer is right in front of you in the little green book.

    I'm programming a 16F88 PIC to complete five basic task for my part of the senior design project.
    Why are these simple projects always part of a 'senior design project'? Senior in high school or senior in college? If senior in college, somebody better get their money back.

    We chose the 16F88 simply because it was used in an earlier lab so we had one on hand and it was the only microcontroler that I had seen any programming done on.
    If this is part of some sort of class, you'd think that there would be resources to possibly use more than a 16F88. But, the 16F88 is a good choice for a simpler project...

    I've written out a code that I thought would work, but it doesn't complete any of the tasks that I want it to. Some basic questions would be, can I use a single input port and a single output port for each of the tasks that I'd like to complete? If so am I assigning the ports right by using TRISA.0 = 1 to set port A.0 to input and TRISB.0 = 0 to set port B.0 to an output? I'm using the SERIN and SEROUT commands to send serial data and I understand the first command after SEROUT is the pin you want to use and the next is the baude rate you're using, but what is the next instruction for and how do I know what to assign to it? Finally can you send hexadecimal commands out of the pic Serially to be understood by the LCD? Below is a copy of the code that I have so far. Any and all help is greatly appriciated.
    Most, if not all, of these questions can be answered by looking in the little green book...

    As far as your code goes...
    DEFINE OSC 20 'SET OSCILATION TO 20MHz
    ------------------Doesn't set the oscillation to 20Mhz. It only tells PBP what you are going to use for an oscillator. It's up to you to get the oscillator to work.

    TRISA.0 = %1 'SETS PORTA.0 AS AN INPUT
    TRISA.1 = %1 'SETS PORTA.1 AS AN INPUT
    TRISA.2 = %1 'SETS PORTA.2 AS AN INPUT
    TRISA.3 = %1 'SETS PORT A.3 TO AN INPUT
    -------------- TRISA=$0F does the same thing....
    -------------- same notes for TRISB

    SERIN SERIAL_INPUT,T9600,[1] 'MAKES PORTA.0 A SERIAL INPUT PORT
    SEROUT SERIAL_OUTPUT,T9600,[1] 'MAKES PORTB.0 A SERIAL OUTPUT PORT
    SEROUT BCKLGHTO,T9600,[1]
    -------------- If you are connected to an actual RS232 port, these won't work too well....

    PAUSE 10
    -------------- Read the little green book to see why this won't work for a 10 second pause...

    LOOP: IF (X<3) THEN 'sends out a high voltage for .5 seconds
    -------------- No real need to put X<3 inside parenthesis, but not a bad idea...



    And to tack onto everything BobK has already said (every bit of which I agree with 100%, except the manual part), we'll help you figure out what's wrong...but we aren't going to write the code for you. Apparently, you're in school to learn, SO LEARN!

  4. #4
    Join Date
    Apr 2007
    Posts
    21

    Default

    I'm not sure what little green book you're refering to. The PICBasic pro program is installed in the school computers, thus there is no manual to look at. I've gone online and looked up the manual so I'm assuming that's what you're refering to. I'm a circuits electrical engineer and thus have never worked with programming or microcontrollers, no classes were ever offered so I'm just learning this simply for my senior design. Keep in mind I'm taking 16 other hours, have a part time job am on two sports teams, and am in multiple organizations on campous so I don't have oodles and oodles of time to devote to reading resources on the subject that I have to look up raondomly on the internet. For senior design they allow your groups to choose a project and run with it, they won't hold your hand anymore so I'm just trying to use the resources out there for help. I know I don't know much about these topics and I've read the PICBasic manual I found online and I've looked through the datasheet, but honestly since I've never had any help or classes on any of this stuff most of what they talk about is beyond me without me spending more time to research the research. Hopefully that helps a bit with where I'm coming from, also despite the preceeding ranting I'm extremly thankfull for the help I've recieved so far on this forum, I know you're using your time to help someone that you don't even know so thank you. I know we're not using RS232 to communicate by the way. So the 16F88 doesn't have it's own internal oscilating crystal. Is there any way to get around creating an external oscilating circuit or is that a must? Also I know PAUSE 10 doesn't pause for ten seconds, I just thought you might need a breif pause between sending the first hexadecimal command to the LCD and the second. Can I just send one right after the other with no break?

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

    Default

    Keep in mind I'm taking 16 other hours, have a part time job am on two sports teams, and am in multiple organizations on campous so I don't have oodles and oodles of time to devote to reading resources on the subject that I have to look up raondomly on the internet.
    Are you trying to make us feel sorry for you? It is not working. Ever think about priorities? The time spent playing(sports) could be spent on learning.

    External oscillating circuit is a must. The data sheet gives several examples. I like the crystals with built in caps, one part top do the job and the 20Mhz is cheap.

    I just thought you might need a breif pause between sending the first hexadecimal command to the LCD and the second. Can I just send one right after the other with no break?
    Normally I would say no, but with out knowing exactly which module you are using I can not look up the DATA sheet to give you a good answer.

    Fix the things Shimask pointed out, do some more reading and get back to us if you still need help.
    Dave
    Always wear safety glasses while programming.

  6. #6
    skimask's Avatar
    skimask Guest

    Default

    Quote Originally Posted by AlaskanEE View Post
    I'm not sure what little green book you're refering to. The PICBasic pro program is installed in the school computers, thus there is no manual to look at.
    That right there sounds a bit fishy to me...ok...a LOT fishy...

    For senior design they allow your groups to choose a project and run with it, they won't hold your hand anymore so I'm just trying to use the resources out there for help.
    Well, don't expect me (I can't speak for 'us') to hold you hand, but I expect the sentiment is the same.

    I'm extremly thankfull for the help I've recieved so far on this forum
    Thankful doesn't pay the bills...BUT...if you learn, then usually that's enough, 'cause the more you learn, the less you ask.

    So the 16F88 doesn't have it's own internal oscilating crystal.
    It doesn't? Maybe I've got a different version of the 16F88.

  7. #7
    Join Date
    Apr 2007
    Posts
    21

    Default

    The reason there is no green book is because the university bought the lisence for the PICBasic Pro software for only three computers in the lab(the program isn't on any of the other computers), the manual probably is somewhere in the university, but since it's a large campous I'm at a loss to know where it is, simply it's not inside the lab anymore. So if it got missplaced or taken I don't know. Also I am thankful for the help, I was under the impression that this was an open forum for the exchange of ideas and to help those that need help with the knowlege you have. Thus I can only offer my thanks, if this is some form of a forum that requires money I will remove myself so as to no longer leach off of it. Also there have allready been two insults to my university posted, and I truly love my university, please try to avoid using replies that imply my university is sub-par and trying to cheat the system. I mean no disrespect to anyone, I'm just trying to use the resources around me to get this done. The only reason I'm even doing any programming is because no one else in the group wanted to step up, so I did. Programming isn't part of my major, nor have I ever done it, I'm just trying to finish my part. If this forum isn't supposed to be used to ask questions, I'm sorry for my posting I didn't mean to do anything wrong.

  8. #8
    skimask's Avatar
    skimask Guest

    Default

    Whoa...ease up there Sparky...
    Ya gotta figure...somebody comes on-line, asking questions which should be obvious 'cause they're in the manul, says there is no manual, is doing some sort of senior project at a University... Again, it all sounds fishy to me...but that's not the point...
    The posts I've given here are MINE...nobody's else, just mine and only mine. Don't take my 'opinions' as the rules around here. There may be people around here that are a lot more giving than I am, good for them. I look for a bit of 'one hand washes the other' type thing. You ask a question, I give you the answer, hopefully that answer can lead you to other answers, so you don't have to ask as many questions.

    As a 'for instance'...you stated in post #4 that the 16F88 doesn't have an internal oscillating crystal. Well, you would've known that the 16F88 had it's own internal oscillator block that can run at a number of speeds if you'd have read the datasheet, and not even read it, but at least skimmed over it fairly well.
    That's the kind of thing I'm talking about...the blatently obvious question that could've been avoided by the least bit of 'research'. And there ya go...

    So...after you have taken my advice written in post #3 into account and have made some changes to your code. Recompile the code, work the hardware, try it out, and let us know what's up...

  9. #9
    Join Date
    Apr 2006
    Location
    New Hampshire USA
    Posts
    298

    Smile welcome

    Hi AlaskanEE,

    Welcome to the forum.
    Quote Originally Posted by AlaskanEE
    I'm a circuits electrical engineer and thus have never worked with programming or microcontrollers
    You picked the right microcontroller for an analog guy. The PIC devices have comparators, voltage references, A to D converters, etc.. You are going to love these microcontrollers. A perfect fit with the analog world.
    Quote Originally Posted by AlaskanEE View Post
    So the 16F88 doesn't have it's own internal oscilating crystal. Is there any way to get around creating an external oscilating circuit or is that a must?
    You may have based this on what Dave correctly said:
    Quote Originally Posted by mackrackit
    External oscillating circuit is a must. The data sheet gives several examples. I like the crystals with built in caps, one part to do the job and the 20Mhz is cheap.
    The only (out-side the PIC) components needed for the "External oscillating circuit", are a simple three terminal ceramic resonator or a crystal with two capacitors to ground.
    Some of the serial stuff needs a more stable oscillator than the drifty one internal to the PIC. The one in the PIC is okay for a lot of projects.

    Don’t give up on the forum, you are an equal member. Keep asking questions. That’s what it is here for. When a person comes along with a similar question, they won’t have to ask. Don’t forget to search for your question / answer before posting. Have fun. Learn.
    -Adam-
    Ohm it's not just a good idea... it's the LAW !

  10. #10
    Join Date
    Apr 2007
    Posts
    21

    Default

    Sorry skimask I was just trying to step gengerly in the forum since I'm new, but was trying to get my point across without ticking anyone off. I know it came off pansy, but I was playing it safe. I misunderstood what you were saying about the internal oscilator. I had skimmed the data sheet and accidentally lumped the statement "the PIC16F88 CAN be set to 20MHz" in with the preceeding paragraph saying that the PIC's internal oscilator can be set to multiple frequencies. So when you said that the DEFINE OSC command doesn't set anything to 20MHz I was confused and the sentance "so the 16F88 doesn't have an internal oscilator" should have had a question mark cause I was asking. Also I was just trying to let everyone know what I'm doing and show the code I was using so that they could comment on what I had done, if it would work or not. I wasn't trying to get everyone to write my code for me and I'm sorry for my lack of clarity on that point. Again sorry for the miscommuniactions and lack of clarity. Also thanks Adam for the suport, I just blew this up too quickly, was getting frustrated with the programming. Chalk it up to experience I guess.

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

    Default

    I should have been a little more clear. If you want something reliable, external oscillator is a must. Being that serial communications are involved. The internals work fine but sometimes the timing will get a little off.

    The oscillator you choose will need to be defined in the *.inc file for the chip you are using along with the other fuses. In the *.bas file you tell PBP what the oscillator speed is for timing. These are the same yet different.

    You will find a line in the *.inc file something like this.

    __config _XT_OSC & _WDT_ON & _PWRTE_ON & _BODEN_ON & _LVP_OFF & _CP_OFF

    Look at the data sheet and it will tell you what each one does.
    Dave
    Always wear safety glasses while programming.

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