Need help in code


Closed Thread
Results 1 to 23 of 23

Hybrid View

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


    Did you find this post helpful? Yes | No

    Wink

    Hi, Camolas

    Welcome here ... and do not be sorry for your English.

    YOU made this effort ... some don't dare.

    Back to our subject, Her you won't find "already cooked" code ... except if you do a search over the forums ... for existing applications.


    The habit is : YOU try to make something run ( by the way learn how the processor works , and which PicBasic commands you have to use ....) - and then , we help you.


    The first thing you'll have to do is CONFIGURE your processor:

    - Which will be the Inputs and Outputs ?

    - How to disable Unwanted features like comparators and ADC ... that could interfere with PORTs

    for that ... the '877 is not the simplest ! ... would you own an old 16F84 ??? ( not compulsory - do not buy one ... but would help you a lot ! )


    And, once that done, begin to translate your " text" program into successive elementary PbP ( PicbasicPro ...) commands.

    So, you'll need :

    1) the 16F877a Datasheet ( from Microchip site )
    2) the PicbasicPro Manual corresponding to your release ( which one ? 2.50 ? )
    3) some paper sheets to note the 877 registers and data for the config.
    4) a good pencil and rubber
    5) a HUGE coffee cup (hot is better ...)
    6) LOTs of patience

    ...

    Welcome aboard and read you soon.

    Alain
    ************************************************** ***********************
    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 " !!!
    *****************************************

  2. #2
    Join Date
    Mar 2008
    Location
    Texas, USA
    Posts
    114


    Did you find this post helpful? Yes | No

    Default

    Alain, you forgot one...

    7) A swear jar

    You too can retire rich!

    Camolas, in a month's time you should have some code. Post it so we can take a look at it.
    No, I'm not Superman, but I did stay at a Holiday Inn Express last night!

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Hi,

    Thanks for the starting hellp

    PicbasicPro 2.50





    My code

    @ DEVICE pic16F877A, WDT_ON ' Watchdog Timer
    @ DEVICE pic16F877A, PWRT_ON ' Power-On Timer
    @ DEVICE pic16F877A, BOD_ON ' Brown-Out Detect
    @ DEVICE pic16F877A, LVP_OFF ' Low-Voltage Programming
    @ DEVICE pic16F877A, CPD_OFF ' Data Memory Code Protect
    @ DEVICE pic16F877A, PROTECT_OFF ' Program Code Protection
    @ DEVICE pic16F877A, WRT_OFF ' Flash Memory Word Enable

    TRISB.0=1
    TRISB.1=1
    TRISC.7=0
    LED var PORTC.7

    inicio:

    if PORTB.0 = 0 then
    GOSUB liga
    else
    low LED
    endif
    goto inicio

    liga:
    if PORTB.1=1 then
    high LED
    PAUSE 200
    low LED
    else
    low LED
    endif
    goto inicio


    end

  4. #4
    Join Date
    Mar 2008
    Location
    Texas, USA
    Posts
    114


    Did you find this post helpful? Yes | No

    Default

    At first glance, replace the "goto inicio" at the end of the program with "return" (it was called under a "gosub").
    No, I'm not Superman, but I did stay at a Holiday Inn Express last night!

  5. #5


    Did you find this post helpful? Yes | No

    Default

    I got 2 problems 1 de led dont turn of afther the periode and 2 i need the code to do like a cicle and stops when led off and only start again when "switch" 1 is on again.

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by camolas View Post
    I got 2 problems 1 de led dont turn of afther the periode
    Fixed by post above?

    and 2 i need the code to do like a cicle and stops when led off and only start again when "switch" 1 is on again.
    Ok, so how do you determine if the LED is off?
    How do you determine if 'switch 1' is on again?
    If you can answer those 2 questions, then you should be able to write your code.

  7. #7


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    Fixed by post above?


    Ok, so how do you determine if the LED is off?
    How do you determine if 'switch 1' is on again?
    If you can answer those 2 questions, then you should be able to write your code.
    Quote Originally Posted by skimask View Post
    Fixed by post above?


    Ok, so how do you determine if the LED is off?
    How do you determine if 'switch 1' is on again?
    If you can answer those 2 questions, then you should be able to write your code.

    Hi, not fixed.


    determine LED - i do not now if i anderstand you well (bad Inglish mine) but by having switch2 pressed led if off. (or if switch1 pressed is off to)

    'switch 1' - I only put this switch to try to stop the code there from looping and looping because i only want that led is high 1 time at the time (just when switch1 be pressesd again), then wait for switch2 to be not pressed.

    Thanks

Similar Threads

  1. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 21:55
  2. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 21:31
  3. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  4. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  5. Re-Writing IF-THEN-AND-ENDIF code?
    By jessey in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 18th August 2006, 17:23

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