newbie needs help!!!!


Closed Thread
Results 1 to 6 of 6
  1. #1
    fishingsetx's Avatar
    fishingsetx Guest

    Default newbie needs help!!!!

    Hello,

    I need some help writing a program. I have some experience with Vbasic, but I have no experience programming chips other then copying them. Ive been using tlc 555 timers in hobby projects, but I want to use something more powerful and easier to modify. Im using a 12F629. I wrote a simple program, but im sure ive left ALOT out:

    Symbol pir = GP5
    symbol cam = GP4
    Loop:
    IF pir = high THEN
    high cam
    PAUSE 1000
    low cam
    PAUSE 180000
    ENDIF
    GOTO Loop

    where GP5 is an input and GP4 is an output.

    Ive tried reading 20 different help files, but they all pertain to the 16xxxx series chips. And I just Seem to get lost.

    could someone please post a sample program along these lines, or could someone please edit my programand repost it?

    If I just knew the proper format and how to set the chip up, this wouldn't be a porblem, but I just cant seem to figure it out. What I need is the entire thing. not just the loop section of the code.


    Thanks,
    Fish

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


    Did you find this post helpful? Yes | No

    Default

    must be more like this
    Code:
    CMCON=7 ;disable internal voltage comparator
    
    pir VAR GPIO.5 ;define GPIO.5 pin as pir
    cam VAR GPIO.4 ;define GPIO.4 pin as cam
    loop100times  VAR BYTE ;define variable for big delay loop
    
    
    
    loop:
                   loop100times=100  
                   if pir then ;mean if pir=high
                        cam=1 ; do the same thing as HIGH cam
                        pause 1000 ; pause 1 sec as request
                        cam=0 ;same as LOW cam
    
                        ; now do the big delay
                        while loop !=0                
                              pause 1800
                              loop100times=loop100times-1
                        wend
                   endif 
                   goto loop
    if i well understand what your project do is waiting for a high state on pir pin then send 0 level to cam pin 1 sec after send high level to cam pin during 180 sec (3 minutes) right??? but i think something is missing!!! let me know the exact thing you want to do...

    As i read you're a newbie so take care of MCLR (pin 4) is pulled up with resistor(4.7K-10K) to 5 volt supply.

    it's suppose to work well now.

    regards
    Last edited by mister_e; - 14th October 2004 at 05:24.
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    if you don't have the datasheet of your device, get it there
    http://ww1.microchip.com/downloads/e...Doc/41190c.pdf
    Steve

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

  4. #4
    Join Date
    Jul 2003
    Location
    Sweden
    Posts
    237


    Did you find this post helpful? Yes | No

    Post

    Hi Fish,

    1. "pir" is very similar to "PIR1" which is register in the pic. I'd use a different name. It probably will work but i'd still pick a different name, just to be safe. I'll leave it alone for now.

    2. You should declare your variables(pins) in a different manner.

    3. You need to tell PBP that "pir" is an input. This could be done with the INPUT command.

    4. It's probably also a good idea to set "cam" in a known state at startup. I'm guessing LOW.

    5. The pause command can only accept values less than 65536. This means that you need to change pause 180000 to three pause 60000 instead.


    Soooooo, with the changes made your program looks like this.

    pir VAR GPIO.5
    cam VAR GPIO.4

    LOW cam
    INPUT pir
    Loop:
    IF pir = 1 THEN
    HIGH cam
    PAUSE 1000
    LOW cam
    PAUSE 60000
    PAUSE 60000
    PAUSE 60000
    ENDIF
    GOTO Loop

    I'd also recommend that you read the PBP manual(all of it) aleast a couple of times. You should also get familiar with you pic, read the datasheet ........ boring, i know but it's essential to know what resources you have to play with.

    Cheers
    /Ingvar

  5. #5
    fishingsetx's Avatar
    fishingsetx Guest


    Did you find this post helpful? Yes | No

    Default

    Thanks guys,

    I'll try those codes as soon as I can. I've been using picbasic pro at www.compilespot.com, but it wont let me compile either of those code samples. It tells me that they are too big for my account (thats what I get for using a free compiler). They compile into ASM, but not to hex.

    Mister_e,

    That is exactly what I want to do. I want to set up a security camera to catch tresspassers/poachers on my property, and I dont have the cash for a security system or to purchase a compiler. I will have to add some more code before it will work, but I want to get a simple program working so that I will have an idea on how to write it. I have a few other projects im working on that need timers too.

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


    Did you find this post helpful? Yes | No

    Default

    hi fishingsetx ,
    i see what you mean. For now, for your purpose, for your budget why not using Visual Basic to acces to LPT1 port ??? everything will be done as you wish with a minimal investement and time but will need a PC to run it. Depending if you have one PC in extra.

    Or in the worst case, you can learn Assembly language of Microchip. With MPLAB (free IDE of microchip) you'll be able to compile your stuff. You can also build your own PIC programmer see this one
    http://www.lancos.com/prog.html

    or this one
    http://www.myke.com/elcheapo.htm

    but it support only a few PIC. Maybe some others free stuff can be avalaible on the net too. Have a look. let us know.

    good luck.

    regards
    Last edited by mister_e; - 20th October 2004 at 03:53.
    Steve

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

Similar Threads

  1. Newbie making an ignition timer
    By ChrisHelvey in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 5th August 2012, 17:45
  2. Newbie HELP :(
    By TheOne in forum mel PIC BASIC
    Replies: 3
    Last Post: - 27th March 2009, 17:15
  3. Newbie: Temperature measurements
    By Budda in forum General
    Replies: 10
    Last Post: - 30th March 2007, 09:56
  4. PIC Newbie
    By azmax100 in forum Schematics
    Replies: 7
    Last Post: - 23rd February 2007, 04:52
  5. request for a newbie forum
    By nimonia in forum Forum Requests
    Replies: 1
    Last Post: - 20th May 2006, 09:01

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