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

    Default Can a pic do several things at once?

    I'm pretty new to pic programming and am still learing, I dont mind admitting I've got a LONG way to go yet
    However what I'd like to know and I cant find an easy answer anywhere is:
    Can you get a pic to do more than one thing at once?
    What I've got in mind is Im using a pic to control solenoids in my car, measure and display temperature using a DS1820 and sending all the info to an lcd, but what I'd like to know is ...
    Is it possible for the SAME pic to take a serial input, decode it and display the readings on 7 segment displays while doing all the above?

    Put simply I'm trying to interface (once i figure out how properly) serial data from a GPS receiver to the pic, interrogate that data and when the NMEA sentence I'm looking for arrives, strip the SPEED from the NMEA sentence, convert it from Knots tro MPH and display it on a 2 7 segment LED display

    Can I do all that with one PIC or would I be better off using a second pic and circuit for the GPS section of my project?

    I need the speed reading to be taked once a second as its going to be used in my car as an accurate speedometer.
    The Pic I'm using at the moment for the first half of the circuit is a 16F877A simply because thats what came with my easypic5 development board

  2. #2
    Join Date
    Oct 2003
    Location
    holland
    Posts
    251


    Did you find this post helpful? Yes | No

    Default

    Yes you can do all of that. When taking a 20Mhz xtal and that big pic. it's no problem. And all of that can be done in pbp and not 1 line in asm.

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


    Did you find this post helpful? Yes | No

    Default

    Can a pic do several things at once?
    NO, even your PC on your desk can not.

    That is where interrupts come in.

    In you case an interrupt on the serial input should do the trick.

    What happens with an interrupt, when an event takes place that is tied to the interrupt routine (internal or external) a "flag" is set. When the PIC or your PC gets time (finishes whatever it is doing ) it will then do the routine called by the interrupt. Then go back to normal operations until the next "flag" is set.

    One PIC will work. If speed is a factor , Darrel's Instant Interrupts will be what you want.

    First I would play with interrupts with an pin going high to be the trigger to get the feel of things.

    A little of what the coding looks like for the above example.
    Code:
    ON INTERRUPT GOTO MYINT
    
    INTCON = %10010000
    
    '###################
    'MAIN PART OF PROGRAM
    '###################
    
    DISABLE
    
    MYINT:
    
    IF PORTB.0 = 1 THEN
    
        PC = PC + 1
    
    	WRITE 3,PC.BYTE0
    
    	WRITE 4,PC.BYTE1
    
        READ 3,PCNT.BYTE0
    
    	READ 4,PCNT.BYTE1
    
        pause 100
    
    ELSE
    
    	PC = PC
    
    ENDIF
    
       
    
    INTCON.1 = 0
    
    RESUME
    
    ENABLE
    
     'THE ABOVE WILL ALSO DEBOUNCE THE SWITCH
    This is a snippet from one of my programs just so you can see what to do. It has nothing to do with your app. But it does show how to write to the EEPROM.
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Mar 2008
    Posts
    79


    Did you find this post helpful? Yes | No

    Default

    Time to learn about interupts I think ...
    as well as how the serin command works
    Oh just as a matter of interest, would a gps receiver that has a usb interface be using serial data or would it be some obscure data thing thats going to be hard to talk to?

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


    Did you find this post helpful? Yes | No

    Default

    PIC are peripheral only, if you need to talk to another USB peripheral you need to use or a Microcontroller with USB OTG feature (some Microchip PIC32 now have it), or an external interface between your PIC and your GPS. Something like uALUSB, MAX3421 and so on. Maybe your GPS have another easier to use serial communication port?
    Last edited by mister_e; - 10th April 2008 at 19:07.
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    I have not used GPS with a PIC myself... But serial data is pretty easy, USB can be a bit difficult.

    Does your GPS plug into a serial or USB port?
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    Mar 2008
    Posts
    79


    Did you find this post helpful? Yes | No

    Default

    Haven't bought the gps unit yet, but the one I'm probably going to buy is either bluetooth (too much work for me to learn how to use that with a pic) or usb as it's designed for use with a pda
    I'm guessing it might be some kind of serial output using the usb connector, but it's unlikely i'll be that lucky.
    According to the user manual, there are 3 types of cable/connector, USB, PS2 and RJ45 http://www.transystem.com.tw/pdf_gps..._Rev%201.3.pdf

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


    Did you find this post helpful? Yes | No

    Default

    There's probably reasons why they came with installation CDs...

    I heard few times about Falcom modules.. never tried them though.
    <hr>
    EDIT: FSA02 seems to be a cute little one
    Last edited by mister_e; - 10th April 2008 at 22:47.
    Steve

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

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