pic24 beginner


Closed Thread
Results 1 to 24 of 24

Thread: pic24 beginner

  1. #1
    Join Date
    Aug 2009
    Posts
    63

    Default pic24 beginner

    Hi,

    I'm very sorry to be putting a post that is way under the expectations of questions that seem to be posted on this forum, however i just need basic help with starting up. I've never programmed before, and someone referred me to using PIC BASIC pro (the pro version because for what i will be doing in the near future will require some of the extra functions).

    It's also quite likely that I will be using a pic24, i was going to buy the book "PIC Microcontroller Project Book : For PIC Basic and PIC Basic Pro Compliers" to help me get started and to learn. I was wondering if this was a good basis to learn on? And would it be helpful to learn to program the pic24 series of microcomputer? Also the probably dumbest question, when coding using the PIC BASIC pro is there any big differences for what pic you are specifically using and if so are there enough resources for the pic24?

    Sorry again for a boring post, but any help would be greatly appreciated!

    Regards

    Robert

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


    Did you find this post helpful? Yes | No

    Default

    Welcome! Do not worry about boring post and such. We all started the same way. Well, maybe Melanie did not but...

    I do not think PBP supports the PIC24. http://www.melabs.com/products/pbp.htm
    what are you planning? I am sure there is one that will work.

    As far as learning to program. Personally I am against the books. Seems every one that has used a book still comes here with basic questions. So use the examples on MeLabs web site and read this forum. Ask all of the questions you want/need.

    The basic commands are the same for all of the chips PBP supports. Pretty much each PIC has it's own setup but many are close to the same. I am taking about the configs, analog and such.

    You will probably end up with a handfull of PICs that you use the most so you will become comfortable with those. Need a new PIC and have trouble with it? Ask.

    A couple of PICs that might be good to start with is the 16F877A and the 18F4550. Between the two you should be able to do most anything.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Aug 2009
    Posts
    63


    Did you find this post helpful? Yes | No

    Default

    mack

    I just realised whilst browsing the forums that it didnt support 16bit. but thats ok i have changed my idea on how to complete what i want, so i only need a chip that provides 10bit ADC.

    Ill explain my whole project! basically im working for a wind turbine company, and currently the power from the turbine goes to an analogue rectifier and then into a converter which goes off to the mains. Unfortuantely this has caused alot of noise due to some problems, and also means we can't collect data too easily or send error signals etc. so im using a microprocessor that is programmed to do what i want. First ill explain what i want and then il explain how i think i will do it

    i want to measure the frequency of 3 analogue signals and get the average from them, and then using that i can create a time constant for each average, which will determine the pulse width modulation of the digital signal output. additionally i want to be able to measure the DC voltage after its been modulated, so that it can switch the generator off if the voltage gets to a certain point (since this will cause damage to the resistor inbetween the + and - and then will cause further damage etc)


    First of all i've decided that I am going to run the 3 analogue signals (3 phases from the turbine) through a schmitt trigger (unless there is a schmitt trigger already integrated into a specific pic). Using the now digital signal i can easily measure the drops using an interrupt? with the information from the drops i can measure the frequency? and then using the frequencies from all 3 signals i can get an average (f1+f2+f3)/3 and i can use that to set the time constant for the pulse width modulator.

    im sorry if some of that was completely impossible, but i havnt worked with programming or electronics at all before.

    thanks

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


    Did you find this post helpful? Yes | No

    Default

    Interesting project.
    I would look at the 18F4550 for this and clock it at 48Mhz.

    Also a coulpe of threads that may help
    http://www.picbasic.co.uk/forum/showthread.php?t=3251
    http://www.picbasic.co.uk/forum/showthread.php?t=11571

    What do you have in mind for a programmer? The PICKIT2 from microchip is nice...and cheap.
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Aug 2009
    Posts
    63


    Did you find this post helpful? Yes | No

    Default

    well thats the problem i wasnt too sure on how this works since its my first time, so would i program everything on (in this case) pickit2, and then then how would i compile it? or does that program include that? would that mean not having to purchase picbasic or picbasic pro? just need a run through on the whole process

    thanks, sorry again was the mindless questions, just can't seem to find this ridiculously simple stuff other places

    edit: sorry i think i confused myself massively when i wrote that, so it doesnt make much sense, would it be ok for someone to give me a quick run through on how i would do this, e.g. create program on what, upload program to pic how, etc
    Last edited by robertpeach; - 11th August 2009 at 16:01.

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


    Did you find this post helpful? Yes | No

    Default

    PicBasic compiles the basic code into assembly language.
    If you are using an 18F chip MPASM then converts the assembly into HEX.
    This is all done automatically when you compile your basic code. MPASM is free, it is part of MPLAB. When you purchase PBP a compatibe version of MPASM come with it.

    Now you need a way to "squirt" the hex into the PIC. That is where the PicKit2 comes into play. There are other programmers out there. If you do not go with the PicKit2 MeLabs has some good ones. Beware of the clones though. Nothing but trouble. The last I flecked the PicKit2 war around $50 US.

    So it boils down to needind PBP and a PicKit2 and a bread board or two and you should be good go.
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    Aug 2009
    Posts
    63


    Did you find this post helpful? Yes | No

    Default

    ok thank you! you wouldnt believe how much thats helped!

    also just wondering for what ive described to you, is it important to buy the picbasic pro, or is the picbasic sufficient enough for my needs? or are there other programs i could use that would do the same thing at a lesser price?

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


    Did you find this post helpful? Yes | No

    Default

    To be honest, PB Pro is all I have ever used from MeLabs.

    Other programs... Folks around here seem to like PBP
    a few years ago before I purchased PBP I tried the demos from some of the others. And here I am. I think most would agree that PBP is the most stable one out there and the support from MeLabs if needed is great.

    Once you purchase PBP upgrades are only $25.
    Dave
    Always wear safety glasses while programming.

  9. #9
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    I will 2nd what Dave says. PBP is the only way to go. 90% of everyone that's ever
    purchased PBC from us over the years has returned within around 30 days to upgrade
    to PBP. It's the best out there.

    For your particular application, have a look at the 18F2431. The motion feedback module
    has a capture option specifically for frequency measurements, and makes it incredibly
    simple. It automatically captures the 16-bit timer5 value on every rising-edge.

    It also has 10-bit A/D with up to 200K samples-per-second, with simultaneous 2-channel
    sampling.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  10. #10
    Join Date
    Aug 2009
    Posts
    63


    Did you find this post helpful? Yes | No

    Default

    thanks for the feedback

    to bruce, you say the 18f2431 is specifically for frequency measurements. would that mean I would no longer need to attempt to code my program to measure the 0 points and then measure the frequency from the timings between the zero points? also you say it does two simultaneously? i have 3 phases from my analogue signal, which are split into 3 different signals, all of which i need to measure the frequency of and get an average. is this still possible with this pic?

    and would using the 18f2431 be alot easier than using a schmitt trigger and just measuring the frequency of 3 square waves using interupts? would there be 3 places on the pic i could make these inputs aswell?

    thanks
    Last edited by robertpeach; - 12th August 2009 at 09:55.

  11. #11
    Join Date
    Aug 2009
    Posts
    63


    Did you find this post helpful? Yes | No

    Default

    ive decided after looking through the specifications in high detail, i think the 18f2431 is probably best suited for my needs, since i noticed it does have 3 digital inputs for my 3 signals that need their frequency measured, and it has the schmitt trigger integrated into its inputs.

    im going to purchase the picbasic pro aswell, but im still dubious on the programmer... the pickit2, is a good site to purchase it from? and is the basic pickit2 good enough or is the pickit2 debug express something that is more suited for my needs?
    (i notice the pickit2 startup kit doesnt have enough pin slots for the 18f2431)

    thanks!

  12. #12
    Join Date
    Aug 2009
    Posts
    63


    Did you find this post helpful? Yes | No

    Default

    ok another reply by me...

    basically i was wondering if i bought a picbasic pro, usb programmer with a zif adapter, and pic18f2431 would work?

    additionally would purchasing a development board be something that would be needed? or anything of that such...

    thanks sorry for so many replys ive been pretty active at this, and im trying to learn basic without a program to even write it in yet!

  13. #13
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    you say the 18f2431 is specifically for frequency measurements
    The PIC is not specifically for measuring frequencies. It just has a capture module
    that makes it much easier to do since it will capture the value of Timer5 on every
    rising edge - which is the period of the square wave.

    also you say it does two simultaneously?
    It can take 2 A/D readings simultaneously.

    i have 3 phases from my analogue signal, which are split into 3 different signals, all of which i need to measure the frequency of and get an average. is this still possible with this pic?
    Yes.

    and would using the 18f2431 be alot easier than using a schmitt trigger and just measuring the frequency of 3 square waves using interupts? would there be 3 places on the pic i could make these inputs aswell?
    Yes it has 3 capture inputs, and using built-in hardware to measure frequency is a good
    deal easier than interrupts. All 3 capture inputs just happen to be Schmitt Triggers inputs
    too.

    If you do need to use interrupts, then I definitely recommend you take a look at Darrel
    Taylors' Instant Interrupt routines. He's done some awesome work on these.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  14. #14
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    basically i was wondering if i bought a picbasic pro, usb programmer with a zif adapter, and pic18f2431 would work?
    Yep. A PICKit2 is nice also, but with the U2 USB programmer you can buy ZIF adapters for
    most any package type, use it for in-circuit programming or dropping the PIC into the ZIF
    socket.

    additionally would purchasing a development board be something that would be needed? or anything of that such...
    Development boards are handy, but not necessarily needed You might be in a better
    position to pick out a good development board that best suits your needs once you get
    farther into your project.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  15. #15
    Join Date
    Aug 2009
    Posts
    63


    Did you find this post helpful? Yes | No

    Default

    ok thank you thats cleared a few things up for me!

    also if i buy a picbasic pro, a programmer such as usb programmer with a zif adapter and the pic, is there any need to buy a development board or demo board?

  16. #16
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,810


    Did you find this post helpful? Yes | No

    Default

    If you intent to use the programmer for serious work forget pickit and look for something solid and fast one.

    I use for years the Pikprog2 that is discontinued and replaced by other newer models. The site is www.elnec.com and can program with ICSP or with a ZIF socket, PIC controllers, HCSxxx devices and EEPROMS too. New chips added every two months at no cost.

    There are others of course in the net.

    Ioannis

  17. #17
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,810


    Did you find this post helpful? Yes | No

    Default

    Demo no. But a dev. board in many cases espeacially when you are new to PIC programming might help. But as Bruce stated is not needed. You can just use a Breadboard and lay your circuit on it just fine. Also you can place on the breadborad carefully some header pins and do also ICSP or in fact In-Breadboard Serial Programming!

    Ioannis

  18. #18
    Join Date
    Aug 2009
    Posts
    63


    Did you find this post helpful? Yes | No

    Default

    Thanks, thats made things easier.

    im thinking of buying this programmer startup kit http://www.mecanique.co.uk/products/pic-prog/usb.html because it seems pretty good for what i need and for my pic. just checking it will actually work for me?

    thanks again

  19. #19
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,810


    Did you find this post helpful? Yes | No

    Default

    If you are a hobbist then go for it. Its more than OK.

    Ioannis

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


    Did you find this post helpful? Yes | No

    Default

    The only dev board you need is a breadboard and some parts. Much more versitile and you can many different projects laying around that you are working on for minimal cost.

    I have a serious programmer, a PicStart+, at least it is in the price range of a serious programmer. I got tired of the ZIF thing and the adapters for ICSP. Maybe if I did production work I would look at if differently.

    With the basic PicKit2 all you need is a 6 pin header that can be plugged into a breadboard or made into the finished PCB if you want to tweak things later.

    We all have different ways of doing things or different needs. In the end you have to figure out what works best for you.
    Dave
    Always wear safety glasses while programming.

  21. #21
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default another opinion

    My first programmer was a JDM clone with ZIF 40 way socket $8. US eBay, I bought the PICKit2 with the low pin demo board at the recommendation of several members and a book by Chuck H. I love it. I do not have to fool around with wires to hook up, I can reprogram and debug with 1 button, great for the more simple programs and I never have to pull the chip. I have worn out many PICs pins inserting, removing and programming. Yes it does ICSP with wires too. Definitely worth the 20 or so bucks it costs additional to the PICKit2. Not a replacement for a breadboard but a nice addition.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  22. #22
    Join Date
    Aug 2009
    Posts
    63


    Did you find this post helpful? Yes | No

    Default

    hey thanks again for ur help everybody!

    ill be on here soon enough asking why my codes arent working, so look out for me!

  23. #23
    Join Date
    Aug 2009
    Posts
    63


    Did you find this post helpful? Yes | No

    Default

    ahh also to check since i couldnt find it online, it says on picbasic pro manual i can change what processor im coding for, using some -p command.

    it doesnt make any reference to the 18f series... is this because its just an old manual? so i can still just type:

    pbp -p18f2431 NameOfFile

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by robertpeach View Post
    ahh also to check since i couldnt find it online, it says on picbasic pro manual i can change what processor im coding for, using some -p command.

    it doesnt make any reference to the 18f series... is this because its just an old manual? so i can still just type:

    pbp -p18f2431 NameOfFile
    Yes, but that is for command line work. If you are running windows and use Micro Code Studio or MPLAB for an IDE to write and compile your programs you probably will not need to worry about it.

    But here is an example
    PBPL -e -ampasmwin -p18F4550 test.bas
    Dave
    Always wear safety glasses while programming.

Similar Threads

  1. Replies: 17
    Last Post: - 12th April 2014, 02:17
  2. Replies: 0
    Last Post: - 29th August 2008, 05:54
  3. Beginner at PB
    By alphahr in forum Off Topic
    Replies: 1
    Last Post: - 21st April 2008, 17:43
  4. Beginner trying to use arrays
    By captain in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 3rd November 2007, 07:20
  5. Pic ID Error please help (beginner)
    By ninja in forum General
    Replies: 4
    Last Post: - 11th August 2005, 17:54

Members who have read this thread : 1

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