Which chip do i use?


Closed Thread
Results 1 to 40 of 78

Hybrid View

  1. #1
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    I was looking at a PIC16F874. It seemed to be alright but i wasnt sure about it.

    Ive changed the 24 outputs to 16 outputs now to save money on triacs and waterproof sockets (i cant believe how much these cost!).

    the PWM could be running constantly. Its to control bulbs (with fading) and it will be possible to fade some bulbs out and hold them at a certain brightness for a while.

    Something i forgot to mention is interrupts. I know i need at least 1 interrupt pin. From reading a few datasheets it seems that most chips have 1 pin EG "RB0/INT" but some say you can use RB4-7 as interrupts too. Whats the difference between RB0 and RB4-7?

    Im not sure how big the program will be. Im hoping pretty small. It will simply accept commands from serial then either use that data to set brightness levels for the bulbs or return a value from the EEPROM (the boxes address).

    I take it and "I/O" pin is any input or output pin (excluding OSC in/out unless the OSC pins work as like RA4 aswell)

    So i think i now need 23 I/O pins
    (16) Software PWM outputs
    (1) Serial in
    (1) Serial out
    (3) Multicolor LED
    (1) Button
    (1) Zero-crossing interrupt

    23 + (2 OSC) + MCLR + VCC + VSS = 28 pins

    Ive just had a quick search and found PIC16F882. Would that work?

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


    Did you find this post helpful? Yes | No

    Default

    if you interface AC, PWM will be useless anyways, you'll need to use a Interrupt to detect the zero crossing and play with your output delays within your ISR.

    Your main program may assign delay to your output.

    Probably also doable to do everything in a tight loop.. but i tend to say it could be a killer situation.
    Steve

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

  3. #3
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    Whats ISR mean?

    I have an idea of how i can write this code in a few simple lines but i dont know how to use interrupts at all. I assume i have 2 interrupts. If one of them goes low then that is the zero-crossing and the code will goto the PWM area. If the second interrupt pin (serial) changes then do i run serin toget the data or wouldnt that work?

    2 main things i need to know at the moment.
    Which chip do i need?
    How do i detect interrupts?

    BTW. Im buying all my parts from http://www.rapidonline.com so it would be nice if i could get the chip from there. I dont think that last one i found is available from them.

    Edit: Do the PIC codes mean anything? Like 16F = 20 pin, 18F = 40 pin etc. Or do they just increment with each new chip?

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


    Did you find this post helpful? Yes | No

    Default

    ISR: Interrupt Service Routine : It's the code area used when an interrupt happen.

    Begin with ON INTERRUPT and/or Darrel's Instant interrupts.
    Steve

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

  5. #5
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    Ive just googled it and based on this satement "Once you try this, you may never use ON INTERRUPT again." I think i should just use Darrel's Instant Interrupts. Ill have a read and see what i can come up with. Thanx

  6. #6
    Join Date
    Mar 2006
    Location
    China
    Posts
    266


    Did you find this post helpful? Yes | No

    Default Hmmm

    Hi,

    I hope you have downloaded the pdf datasheet for the 16F882. There you can see that this PIC belongs to a family of PICs starting with the 882 and ending with the 887. There is a table showing the memory size and partnumber/number of pins for these pics.

    INT0 is the only external interupt source for the 882-887 family and the rest of PORTB has interupt on change support. This means that you can set up the INT0 pin to generate an interupt when this pin goes either high or low (set in SW).
    The rest of PORTB has interupt on change mening it will generate an interupt if any of these pins (that has this function activated) changes state. And then you have to figure out which pin did what and why...

    There is a big table for this too under CPU special features.... interupts :-)

    The microchip webpage has the price for the 882 at USD 1.20 and the 887 USD 1.84. This can be the best spent 64 cents in your entire life :-). Or you can choose a 884 (still basically the same chip for USD 1.64) since this is a 40-pin package and then keeping the options for plugging in a 18F when you run out of speed and program memory)

    Probably you have forgotten a few pins in your idea that you will "remember" later and making a design using a 28-pin device and planning to use more or less all pins is hmmmmm not that smart :-) (unless you really know what you are doing like Melanie and her friends).
    Maybe a LCD... some more buttons..... smoke detection..... automatic fire extinguishing.... you get the idea.... things tend to grow with time and some projects newer really finish.


    But if I were you I would:

    Download the datasheet for the 16F882 (same datasheet as for 883 884 886 887)
    Check if they are supported by PBP (if not memorize which are for later use)
    Not choose a 28 pin PIC since it will kill the future plans and leave no room for misstakes
    Choose a 40-pin PIC (884 or 887 if we only look at this family) unless price and pcb size is really important)


    The 884 is 20 cents cheaper then the 887 but you only get half as much program memory.

    Of course these prices might be different from what you pay in the stores but it will at least give us a chance to compare apples and bananas.

    In the end it all comes down to what can be found in your local hardware store or what can be salvaged from previous projects.

    A start is always a good start!



    /me
    Last edited by Jumper; - 26th November 2007 at 14:52.

  7. #7
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    Hmm. Ill start off with interrupts. IVe been reading this incredibly long thread and i think im starting to understand how it works but i do have a question about it. In one of the posts he says "And, all of this is happening behind the scenes of your normal PBP program." Does that mean for me that i can have serin wait for data (with no timeout) *AND* still have the PWM stuff running at the same time? (Meaning i only need 1 interrupt pin)

    I understand how the other interrupt pins work now. Bit annoying but maybe i dont need them anyway.

    I do always look at the datasheets for chips but i dont completely understand them.

    If i have forgotten any pins then its bad anyway. I can do breadboard testing but once i make this thing it has to work first time. Space is an issue. Im trying to cram so much into such a small box.

    How do i tell if it supports PBP?

  8. #8
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    Right. Ive just connected a PIC up and checked that its working. Now im trying out the hello world example. Ive pasted the code in from that page exactly but i get 3 errors when i try to compile

    ERROR: Variable wsave3 position request 416 beyond RAM_END 79.
    ERROR: Variable wsave2 position request 288 beyond RAM_END 79.
    ERROR: Variable wsave1 position request 160 beyond RAM_END 79.

    I dont understand what they mean or how to fix them. Im testing on a PIC16F84A. I have set the chip correctly in PBP this time :P and ive downloaded the 14 bit version of the interrupt code (for 12F-16F)

  9. #9
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    Ive just loaded the bas file up and theres some comments saying i can comment out the lines that are causing a problem. Ive done that and now theres another error.

    Error PBPIC14.LIB 1141 : [255] undefined symbol 'int_entry'

  10. #10
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    Aha! Ive just read a whole thread of people having digs at each other but in the end i found out that its because i havnt got MPASM turned on. Ive enabled it and got the program to compile. It did give me 2 warnings though.

    Warning[211] c:\picbas~1\pwmtes~1.asm 227 : Extraneous arguments on the line.
    Warning[211] c:\picbas~1\pwmtes~1.asm 227 : Expected (ENDIF)

    I assume that 211 is the error code and 227 is the line. If that is correct then this error is on line 169 of the origional "DT_INTS-14" file. The line says "End If". I think this is because .bas files open with VB and for some reason it added the space in. The origional file doesnt have the space. So, ive copied the origional file back out of the zip, commented out those 3 lines again and now its giving me another error

    Error[113] c:\picbasic\pbppic14.lib 1141 : Symbol not previously defined (INT_ENTRY)

    Ive tried deleting all the files generated for DT_INTS-14 (like the asm file etc). Ive hit compile again and yet another error.

    Error[113] c:\picbas~1\pwmtes~1.asm 115 :Symbol not previously defined (PIR1)

    Now im stuck. Does anyone have any suggestions?

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


    Did you find this post helpful? Yes | No

    Default

    Maybe you should try and learn regular interrupts before going for the big guns Darrel gave us.

    You said that you do not understand interrupts. Search the forum for Olympic Timer or real time clock. Paul B has a good example too. Once you work through these you should have a good understanding of the behind the PBP and using an interrupt pin is not much different.
    The above mentioned threads:
    http://www.picbasic.co.uk/forum/show...=olympic+timer

    http://www.picbasic.co.uk/forum/showthread.php?t=2129
    Dave
    Always wear safety glasses while programming.

Similar Threads

  1. Trouble with PIC16F88 (chip hangs up)
    By nobner in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 20th January 2009, 10:23
  2. Camera with PIC chip
    By The Master in forum Off Topic
    Replies: 5
    Last Post: - 1st July 2008, 15:28
  3. More info on L4620 liquid sensor chip
    By Nicmus in forum Documentation
    Replies: 4
    Last Post: - 2nd June 2008, 00:03
  4. TV Display Chip
    By zadok in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 17th April 2008, 23:17
  5. chip selection aid
    By PICMAN in forum General
    Replies: 4
    Last Post: - 21st February 2005, 19:33

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