output's on as power is supplied


Closed Thread
Results 1 to 13 of 13

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default serial relays

    thanks Skimask for the reply here is my code again:

    INCLUDE "bs2defs.bas"
    keydata VAR b3 'relay number storage variable
    serpin VAR porta.4 'serial input pin
    trisa = %00010000
    trisb = %00000000

    loop:
    gosub loop1 ' I am going to loop one to receive data on the serial pin then I am going to "keyed" to instruct the pic which relay to turn on.

    goto keyed


    loop1:
    SERIN serpin,N2400,[254],keydata
    IF keydata => 1 AND keydata <= 12 THEN GOTO keyed 'goto keyed if key is 'pressed
    return

  2. #2


    Did you find this post helpful? Yes | No

    Default using the branch

    I read in the PicBasicPro manual about using the branch as you suggested,
    branch b3, [outr1,outr2,outr3,outr4,outr5,outr6,outr7,outr8,ou tr9,outr10,outr11,outr12]
    I just compiled and tried the circuit seems to work fine. I am curious about why using many "If, Then" statements is not a good way of doing things.

    Thanks again, as you may have guess I new into this and still learning .

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by tazntex View Post
    I just compiled and tried the circuit seems to work fine. I am curious about why using many "If, Then" statements is not a good way of doing things.
    A lot of If/Then statements, all back-to-back, just kinda looks ugly, and makes it a bit harder to read. You have to scroll up, scroll down, move all around. With the BRANCH, it's all on one line. It doesn't neccessarily save memory, code, or whatever, it just looks better.

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


    Did you find this post helpful? Yes | No

    Default

    Never trust a PIC at boot, it's output level is hard to predict. you should set it yourself at the top of your code and add a little delay
    Code:
        PORTA = 0
        PORTB = 0    
        trisa = %00010000
        trisb = %00000000
        PAUSE 50 ' settle time 
    
    loop:
    It's not a bad idea to enable the Power Up timer in your Configuration fuses as well.
    Code:
    @       __CONFIG _XT_OSC & _PWRTE_ON & _WDT_OFF & _CP_OFF
    http://www.picbasic.co.uk/forum/showthread.php?t=543
    Steve

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

  5. #5
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    It's not a bad idea to enable the Power Up timer in your Configuration fuses as well.
    Code:
    @       __CONFIG _XT_OSC & _PWRTE_ON & _WDT_OFF & _CP_OFF
    I've never really had problems with outputs coming on at power-up. They always seem to be in INPUT mode.

    But assuming you did need to set them manually, wouldn't the Power-ON timer just make it that much longer till they actually got set to output.

    Just a thought.
    <br>
    DT

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


    Did you find this post helpful? Yes | No

    Default

    If the hardware don't care about the 'Tri-State' or 'High impedance' level, yes...about 72mSec longer.

    Unfortunately there's no Brown-Out detect on this one, we have no schematic and we can't measure the PSU behaviours and rise time from where we are.. hard to have the ultimate solution.

    Maybe i misunderstood the original problem...
    Quote Originally Posted by tazntex
    I now have everything working momentary now but at times when I apply power some if not all relays activate.
    Steve

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

  7. #7
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    If the hardware don't care about the 'Tri-State' or 'High impedance' level ....
    Right, and that could be a problem.

    Here's an idea for Taz.
    Try running this program ...
    Code:
    STOP
    Yes, that's the whole program.

    It'll leave the pins in Hi-Z mode.

    Then see if any relays come on?
    <br>
    DT

  8. #8
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by tazntex View Post
    keydata VAR b3 'relay number storage variable

    IF keydata => 1 AND keydata <= 12 THEN GOTO keyed 'goto keyed if key is 'pressed
    And again...b3 does not make any sense.
    When you define a variable, you define it as a type; a bit, a byte, a word, a bucket, a scoop of ice cream, a car, whatever...

    What exactly is a b3?

    And again...in the If/Then, you GOSUB into the LOOP1, and then you GOTO out of LOOP1 back to the main loop. When you GOSUB, you push a return address onto the stack (i.e. a place to remember where I was before, look up GOSUB and RETURN in the manual), and from there, you must RETURN out of it. If you GOTO out of a GOSUB, you keep remembering where you were, but you'll never forget. A PIC only has so many empty spaces to remember, and by RETURNing, you free up one of those spaces. If you never RETURN, eventually, you won't remember either.

  9. #9
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    And again...b3 does not make any sense.
    When you define a variable, you define it as a type; a bit, a byte, a word, a bucket, a scoop of ice cream, a car, whatever...

    What exactly is a b3?
    B3 is defined in the "bs2defs.bas" INCLUDE file.

    It's an alias to W1.HIGHBYTE. W1 is also defined there as a WORD.
    <br>
    DT

  10. #10
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    B3 is defined in the "bs2defs.bas" INCLUDE file.
    It's an alias to W1.HIGHBYTE. W1 is also defined there as a WORD.
    <br>
    Ahhh...that covers why it compiles with errors...

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


    Did you find this post helpful? Yes | No

    Default

    2nd round
    IT COMPILE WITHOUT ERROR, IT'S DEFINED IN THE BS2DEFS.BAS file.

    unless you removed the INLCUDE "BS2DEFS.BAS" linet, IT WILL COMPILE WITHOUT ERROR.

    Once again ?
    Steve

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

Similar Threads

  1. Battery powered applications
    By NavMicroSystems in forum Off Topic
    Replies: 7
    Last Post: - 22nd June 2009, 07:12
  2. Pic getting part power from Analog Port
    By ShaneMichael in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 22nd April 2009, 10:34
  3. Outputs high to power
    By volcane in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 2nd February 2008, 18:29
  4. 12 Servo's together does not seem to work, Power problem
    By macx75 in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 13th December 2006, 19:30
  5. Power up problem
    By Ken McDonald in forum General
    Replies: 1
    Last Post: - 28th December 2004, 17:06

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