Can a pic do several things at once?


Closed Thread
Results 1 to 32 of 32

Hybrid View

  1. #1
    Join Date
    Mar 2008
    Posts
    79


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Melanie View Post
    Question : Can you get a pic to do more than one thing at once?

    Definitive Answer : Yes and No (answers like this is a girl thing).

    Explanation : The PIC can ONLY execute one program instruction at a time at any instant in time. So technically the answer is NO. However there are two riders to this...

    1. The PICs are packed full of hardware. The hardware elements operate independently from the controlling processor (although they may be synchronised and share elements like the clock). So, YES, you can SIMULTANEOUSLY perform an ADC operation, Hardware PWM, Comparator Function, Capture Compare, SERIAL I/O, Op-Amp operation etc etc (providing you have a PIC with the appropriate hardware built-in) whilst your software is doing something completely different AT THE SAME TIME.

    2. Whilst I said that the PIC can only execute one instruction at any given instant (and this holds true) the definition of an 'instant' is something else altogether. If you now define 'an instant' to be 1mS (one millisecond), a 40MHz PIC can execute 10,000 instructions in that 'instant'. To the casual observer, the PIC can be handling multiple software tasks simultaneously, in truth though, it is still only doing ONE thing at a time (just happens to be doing it damn quick).

    So, here is where you work out EXACTLY what you need your PIC to do, and what your particular definition of 'an instant' is going to be. That will define if you can get your single PIC to perform all the tasks you need it to in your available time slot.
    Thanks Melanie, that was exactly what I was looking for and it answered all my questions in one go

    I realise I've got a lot of learning to do yet as regards and interupts and various other functions, but It's given me the urge to learn a lot more and work hard at ait till I get it doing exactly what I want,
    I'm reasonably good with analogue electronice and originally I was just going to do something the old fashioned way, untill I realised that If I learnt how to program I can do loads more.

    By the way, sorry to all concerned if my previous post seemed to be a bit "hostile" I was getting pretty wound up with everyone assuming things and not taking any notice of what I'd already said.
    Don't worry though, I wont ask stupid questions again, I'll just sit and read from now on

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


    Did you find this post helpful? Yes | No

    Default

    I should probably keep quiet...but

    I thought post #3 did a fair job at answering the question too.

    And about the stupid questions and reading more.
    If people would do that, then we would not need this forum.

    Personally I am happy to see new people come in that want to learn and not just copy paste code.

    As far as the accuracy of the GPS. The only way to be more accurate is to use a DGPS set up. Now that the WAAS system has been in place for a few years, I think most commercial products have that built in.
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    A PIC can indeed do several things at once. It's just a matter of getting familiar with
    hardware options the PIC you're using has. Like Melanie already said, firmware is going
    to execute line-by-line, but built-in hardware goodies open up a whole new avenue to
    real multi-tasking. You just need to get familiar with all your options.

    And don't hold back on posting or asking questions here. That's what this forum is for.

    I learn something new just about every time I login here just by reading & thinking about
    some of the questions asked, so keep em coming. I still have a lot to learn myself..;o}
    Regards,

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

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by karenhornby View Post
    By the way, sorry to all concerned if my previous post seemed to be a bit "hostile" I was getting pretty wound up with everyone assuming things and not taking any notice of what I'd already said.
    Don't worry though, I wont ask stupid questions again, I'll just sit and read from now on
    <font color=red> <h3><b>It did seem hostile, funny thing, big red letters are like that. . .</font color></b></h3>Apology accepted!
    I cannot grasp what <b>Automotive</b> purpose requires a speed measurement which requires accuracy equaling two hundred thousandths of an inch per second (5mmps), weapons systems yes, cars, no.<br>Questions are seldom stupid or unwelcome, often they are well worn due to having been asked several times in the past, but not stupid. Please ask your questions, learn from those who exceed your personal knowledge<b> and</b> from those who do not.
    Last edited by Archangel; - 12th April 2008 at 00:17.
    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.

  5. #5
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Unhappy

    Hi, Karen

    You seem tired ... and should rest some little time.

    I was just explainng you HOW and WHY your different things could be done by the same Pic ...
    By the way, add the regulating calculations to the duties the Pic will have to do ...

    Will you use PID or Fuzzy to drive your Solenoïd ???

    a little question :


    This Doppler shift is directly
    proportional to velocity of the receiver along
    the direction to the satellite, regardless of the
    distance to this satellite.
    Must I think from that it can't work in a deep forest, a narrow mountain valley, or between high buidings, ???

    Alain

    PS: That's you who talked about "blondes" at first ... not me !
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  6. #6
    Join Date
    Mar 2008
    Posts
    79


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    Hi, Karen

    You seem tired ... and should rest some little time.

    I was just explainng you HOW and WHY your different things could be done by the same Pic ...
    By the way, add the regulating calculations to the duties the Pic will have to do ...

    Will you use PID or Fuzzy to drive your Solenoïd ???

    a little question :



    Must I think from that it can't work in a deep forest, a narrow mountain valley, or between high buidings, ???

    Alain

    PS: That's you who talked about "blondes" at first ... not me !
    LOL
    thanks everyone
    The need for 100% accuracy 24/7 isnt essential, I was actually thinking of having the display so I can see when I'm getting near the speed limit the cops WILL ticket me
    and
    Its mainly going to be there as a backup to the actual speedo (they have been known to break) and the other reason.. is the reason someone (wish I could remember who) when asked why he did something said:
    because I can.
    I just thought it would be a good way of learning how several part of the pic work, how to program the various bits, see it working everytime I drive, and more important,. anytime anyone asks about it I can not only say waht it was, but also say "I did it"
    yes.. I admit i'll like boasting once its finished

  7. #7
    Join Date
    Jul 2005
    Location
    Palmdale, CA
    Posts
    37


    Did you find this post helpful? Yes | No

    Default GPS - Speed

    If you are interested in accuracy, don't forget that most commercial GPS units don't display instantaneous velocity. Most of them average over a 5 second window. That is to say that what you see on the screen is the averave velocity of the last 5 seconds. The fastest it can update is once per second. If you really want accuracy and readability, make a speed pickup from a magnetic or optic sensor and put it on the drive shaft as was suggested. Then write the code to read it, translate it, and display it. If you want to split hairs, calibrate it through the operable speed range to compensate for tire expansion.

    This is not PIC related, but it is an example of what can be done with a GPS head.
    A while back the radio guy at work was walking all over the plant with a signal strength meter trying to map blind spots in our radio coverage. It was going to take him a month to get a minimal amount of data. I bought a Garmin GPS head with an RS232 output and fed it into the serial port on a laptop. I routed the signal strength output from one of the hand held radios into a DAQ board in the PCM-CIA slot and wrote some labview code. All he had to do was put the laptop, GPS head and radio into a car and drive around the plant. The code sampled position and signal strength and plotted a colored representation of the signal field overlaid on a map of the plant property. It took about 3 days to put it together and write the code and about 30 min for him to collect all the data needed. If you really want to interface the GPS with the PIC, I suggest you use a 16F876 and get a GPS head with an RS232 output. The NEMA format is real easy to handle.

    Edward A. Nauman
    Senior Staff Engineer

    Lockheed Martin Aeronautics
    "The Skunk Works"
    Mail Stop 0157
    1011 Lockheed Way
    Palmdale, CA 93599
    Voice: (661) 572-7350
    Fax: (661) 572-3507
    Cell: (661) 305 7636

Similar Threads

  1. SMS via pic
    By kenandere in forum GSM
    Replies: 15
    Last Post: - 10th March 2010, 10:00
  2. Replies: 67
    Last Post: - 8th December 2009, 02:27
  3. Midi, Interrupts and Pic better than SX28?
    By Lajko in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 27th September 2008, 00:26
  4. pic to pic ir link versus wired link : help please anyone
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 30th May 2008, 21:01
  5. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th March 2005, 23:14

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