First Day and need Help!


Closed Thread
Results 1 to 18 of 18

Hybrid View

  1. #1
    timmoore47's Avatar
    timmoore47 Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e
    If the 16F877 is on the drop list it must work.

    remove your config fuse to see. If there's any other problem, tell us your PBP version, Microcode Studio version and also post your code here.
    Err... I don't know where the drop list is. THe version of Micro Code Studio is v 2.2.1.1

    The Read.me file says this:-
    PICBASIC(TM) Compiler Ver. 1.45 README.TXT
    Copyright 2005 microEngineering Labs, Inc.

    I don't know if it's integrated correctly Into PIC BASIC Standard.

    The code is one of the Samples:-


    ' Simulate BS2 Shiftin and Shiftout

    Symbol DDIR = Dir0 ' Shift data pin direction is Dir0
    Symbol DPIN = Pin0 ' Shift data pin is 0
    Symbol CPIN = 1 ' Shift clock pin is 1

    Symbol I = B2 ' Loop counter


    ' Shift in some data
    Low CPIN ' Start shift clock low

    Gosub shiftin ' Shift in some data

    ' Shift out some data
    Low CPIN ' Start shift clock low

    B0 = 100 ' Data to shift out
    Gosub shiftout ' Go do it

    End


    ' Subroutine to synchronously shift in one byte
    shiftin: DDIR = 0 ' Set data pin direction to input

    For I = 1 to 8 ' 8 bits to a byte
    B0 = B0 * 2 ' Shift result 1 bit to the left
    Toggle CPIN ' Toggle shift clock
    Bit0 = DPIN ' Move data into LSB
    Toggle CPIN ' Toggle shift clock once more
    Next I ' Loop

    Return ' Go back to caller


    ' Subroutine to synchronously shift out one byte
    shiftout: DDIR = 1 ' Set data pin direction to output

    For I = 1 to 8 ' 8 bits to a byte
    DPIN = Bit0 ' Data out is LSB
    Toggle CPIN ' Toggle shift clock
    B0 = B0 / 2 ' Shift byte 1 bit to the right
    Toggle CPIN ' Toggle shift clock once more
    Next I ' Loop

    Return
    Last edited by timmoore47; - 18th May 2006 at 14:48.

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


    Did you find this post helpful? Yes | No

    Default

    Drop list <img src="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=872&stc=1&d=1147960259 ">

    Now with PBC... iiiish i'm sorry i couldn't be much help but i believe that...
    Code:
    Symbol DDIR = Dir0 ' Shift data pin direction is Dir0
    Symbol DPIN = Pin0 ' Shift data pin is 0
    Symbol CPIN = 1 ' Shift clock pin is 1
    
    Symbol I = B2 ' Loop counter
    Is invalid. I know you must use or redefine specific variable name.. about the PORTA, PORTB.. name it's sure you can't use Dir0, Pin0 and 1

    Fortunately, there's some user here who use PBC and can help.
    Attached Images Attached Images  
    Steve

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

  3. #3
    timmoore47's Avatar
    timmoore47 Guest


    Did you find this post helpful? Yes | No

    Default

    Ok, Has anyone got a very simple code fragment I could try?

    So far I've not got off ground zero!

    Maybe I've got a duff install?



    Tim

  4. #4
    mramos's Avatar
    mramos Guest


    Did you find this post helpful? Yes | No

    Default

    I have a few, what type program are you after. I have one that runs two servos, to move my robot dog (PWM commands to servos). It is old and I would have to clean it up.

    I have one that reads and LDR and buzzes a Piezo buzzer every 30 seconds.

    What are you tryig to do?

  5. #5
    timmoore47's Avatar
    timmoore47 Guest


    Did you find this post helpful? Yes | No

    Default

    Thank you for responding.

    I'm building a video switching unit. To choose between 5 video channels and just switch one of them to a DVD Recorder. It's monitoring nocturnal wild Hedgehog activityin a UK garden.

    I've got 5 PIR Sensors which kick out +5 volts when a hedgehog passes by.

    So for each binary pattern on PortA, a single relay attatched to the first 5 of PortB pins is switched.

    So I need to set PortA to be inputs, PortB to be outputs then read portA, make a decision, set a relay and delay, then do it again.

    Easy enough on paper but PBC code seems to use different commands to other PicBasics I've used and I got confused badly on setting up and reading PortA and defining variables.



    Tim

  6. #6
    mramos's Avatar
    mramos Guest


    Did you find this post helpful? Yes | No

    Default

    I am heading for work now. So not much time.

    You need to symbol portA and portB to there locations.
    Then peek portA (say into B0), do any logic on it
    Then poke portB with your results from B0.

    What happened if two PIRs are tripped? Do you have a priority for them?
    You will probably want to make sure there is only one bit set in B0 otherwise
    you will have two or more relays flip on (multiple video coming in).

    If this does not help, later I will see if I can send a sample. Just running late right now.

  7. #7
    timmoore47's Avatar
    timmoore47 Guest


    Did you find this post helpful? Yes | No

    Default

    Yes it does help!

    To avoid two video channels is key to getting this program right.

    With a 5 bit word there are 64 possible input patterns, mostly it will just be a logic '1' with it
    just passing the data staight thro.

    But it gets very interesting when several go off! That will need data translation based on the significance of the pattern.

    IF A0 = 6 then PortB = 7 '4th video channel selected

    etc

    I'm not confident yet I've got the symbol/peek/poke syntax right. I've been posted the manual now, but feel very nervous about producing working code right now, so a code example would be brilliant!

    Many thanks again for responding.



    Tim

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