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

    Default Which chip do i use?

    Hi. I need a PIC chip that can output software PWM to 24 pins, on/off to 3 pins and have serial in/out. It needs to have at least 2 bytes of EEPROM. It needs to use an external oscillator.

    Can anyone tell me which chip would best suit me or even better how do i figure it out myself? Is there a list somewhere that will allow me to select the features i want and run a search?

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


    Did you find this post helpful? Yes | No

    Default 18F- or 16F-

    Hi,

    Most PIC:s can do what you have asked for as long as they have enough PORTs availible.

    Do you plan to make a small, big or huge program ?
    Are you going to make one or one millions units (is price per unit a big factor)?
    What will the future look like (USB or anything more special)?

    A first choice would be 16F887 since it is cheap, has a reasonable big program space, internal EE-prom, UART and is pincompatible with other pics such as 18F4620 (for later emergency upgrades using the same footprint).

    The 18F series will give you more speed (40 MHz compared to 20) and much more program memory compared to 16F887.

    You didn't say if the PWM is running contantly or not. Maybe the need for speed is more important than price per unit.

    Just to make sure:

    I am talking about the 16F887 (eight eight seven), not the 877 or 877A which are the older chips doing more or less the same thing.

    /me

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

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

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

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

  7. #7
    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 13:52.

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

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

  10. #10
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    I knew my ears were burning for some reason today.

    Quote Originally Posted by The Master View Post
    Hi. I need a PIC chip that can output software PWM to 24 pins, on/off to 3 pins and have serial in/out.
    Don't want much, Do you?

    Let's see, you want 24 software PWM's, plus + ...
    Maybe we can just make it a moot point by determining your PWM resolution requirement.

    1. What frequency PWM do you need?
    2. What resolution? 4, 8, 10 bit ?

    The reason I ask can be found here ...
    http://darreltaylor.com/DT_INTS-14/SPWM.html
    In particular, read how many Interrupts/Instructions per second it takes to accomplish software PWM.

    I would guess that the reason you had problems with Instant Interrupts previously Today, is because you were using a 16F84A.
    Kind of like running windows on an original IBM PC. (you might get it working, but it'll suck)

    Switch to at least the 16F877, but I'll bet you're going to need an 18F.

    .
    DT

  11. #11
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Oh, and if that makes it sound impossible to you?

    Here's something else to ponder.
    It's just that, Nobody's written it yet.

    http://www.picbasic.co.uk/forum/showthread.php?p=45597

    .
    DT

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


    Did you find this post helpful? Yes | No

    Default

    Darrel. I changed the design yesterday. I only need 16 PWM pins now. Someone made some circuits for me years ago that do exactly what im trying to do now and they work perfect. They only used smaller chips i think PIC16F84's. The person who made them lost the origional code in a format and i hardly ever see him online now. I guess he wasnt using your code though. Ive swapped to a PIC16F877A now. I hope that will do better.

    Im not sure about the frequency/resolution. I want a brightness control that is 0-100%. Here in the UK we have 50Hz which means 100 zero-crossings per second so i think for 100 brightness levels i should split each half cycle into 100. That should mean for a brightness level of 50% i wait 5ms before turning the output on. Im not sure how this would work though because 1% would be 100ns but isnt that faster than the chip can handle?
    Im sure im going about this bit the wrong way too.

    I checked the datasheet for PIC16F877A and it says it has USART So that should be ok.

    mackrackit. Its all becoming clear now. Im about to read through that thread now but i think i understand how it should work.

    Random thought. I can upload the .HEX file from one of the chips i have already doing this kind of thing with 8 PWM outputs. I dont know if anyone can do anything with it. Maby decompile to assembly?

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


    Did you find this post helpful? Yes | No

    Default

    Just read through that thread and the PDF in it. I only understood some of it through. Im using triacs so i cant use bi-phase angle modulation. Phase angle modulation is what i was thinking of. Turn an output on at a set point durin the half cycle and let the triac turn itself off at the next zero-crossing. I dont think the drawbacks of that method will affect me because im not using LEDs. I got completely lost at BAM.

    The idea i had would work like this

    Code:
    interruptpoint: 'This is where it goes on interrupt from the zero-crossing pin RB0
    if brightness(0)=100 then
    high porta.0
    endif
    if brightness(1)=100 then
    high porta.1
    endif
    .........
    pause (100th of a cycle)
    if brightness(0)=99 then
    high porta.0
    endif
    ......
    'by now it should be right at the end of the half cycle
    'set the pins to low so the triacs dont all come back on in the next half cycle
    low porta.0
    low porta.1
    resume
    Obviously i wouldnt type out hundreds of if statements, i would use a loop instead but thats what i was thinking of. It looks a little slow though

    I know ive got to learn serial now without using serin2.
    Which interrupt method do i need? (or which one should i start learning?)

  14. #14
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Should I also guess that the serial is comming in at 250kbaud?
    There are 512 frames, at ~40hz.
    A.K.A. ... DMX

    .
    DT

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


    Did you find this post helpful? Yes | No

    Default

    I was going to use 9600n. Thats what everything else uses including the origional boxes my mate made

    EDIT: The plan wasnt to use these as DMX lights but how hard would that be? IVe got a DMX controller and i think its faster than anything ive done using the serial port (My DMX box is USB>DMX)
    Last edited by The Master; - 27th November 2007 at 07:03.

Similar Threads

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