Shop OBEX P1 Docs P2 Docs Learn Events
B register partial Schmidt input, partial CMOS inputs — Parallax Forums

B register partial Schmidt input, partial CMOS inputs

jmokiejmokie Posts: 13
edited 2007-07-19 23:11 in General Discussion
I am implementing a line follower with the SX28 using SXB.
I need to have Rb.2 to have a CMOS input, Rb.3 to be an output, and all the other B register pins to be schmidt trigger inputs.
I have figured out how to do Rb.2 & Rb.3, but how to make the others schmidt triggers without bothering the first two?
I have tried using LVL_B, but can't get the compiler to recognize it.· My help says that the Schmitt command only works with SX48 & 52.
I am not a assy code programmer, so help!

Comments

  • JonnyMacJonnyMac Posts: 9,275
    edited 2007-07-09 05:23
    In SX/B...

    LVL_B = %11111011
    ST_B = %00001100
    TRIS_B = %11110111
    



    Double check, please... it's been a long day.
  • BeanBean Posts: 8,129
    edited 2007-07-09 12:19
    UnusedRB  PIN RB INPUT SCHMITT
    AnInput   PIN RB.2 INPUT CMOS NOSCHMITT
    AnOutput  PIN RB.3 OUTPUT
    
    

    Bean.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never argue with an idiot.· They'll drag you down to their level then beat you with experience.
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.hittconsulting.com
    ·
  • jmokiejmokie Posts: 13
    edited 2007-07-19 22:35

    Thanks JohnnyMac & Bean

    Where do I put these statements? In the PIN definitions or in the Initialization code?

    Do they have to be in the order shown?

    I have the A/D working now, but one of the inputs that was working earlier is not now. It is one of the schmitt trigger inputs, Rb.1.· It is changing in the registers as viewed in debug, but not in the "watch" list.· What gives?· I even eliminated all the special code to look at the sensor input only.(see code below), and it still doesn't change in the "watch" list.

    My line follower has 3 ir sensors.

    Left Sensor is Rb.0

    Center sensor is on a/d Rb.2

    Center sensor output for a/d Rb.3

    Right Sensor is Rb.1

    I have the following in the Pin descriptions:

    InPin PIN Rb.2 INPUT CMOS

    OutPin PIN Rb.3 OUTPUT

    lft_lnsnsr PIN RB.0 INPUT SCHMITT 'Set B to schmitt inputs

    rt_lnsnsr PIN RB.1 INPUT SCHMITT 'Set B to schmitt inputs



    last code to test sensor inputs:
    DEVICE········· SX28, OSC4MHZ, TURBO, STACKX, OPTIONX
    FREQ··········· 4_000_000
    ID············· "SXB 7807"

    '
    ' IO Pins
    '

    ································ '
    Direction Truth Table
    lft_lnsnsr·var·rb.0
    ctr_lnsnsr·var·rb.2
    rt_lnsnsr·var·rb.1

    '
    ' Constants
    '

    '
    ' Variables
    '
    Watch lft_lnsnsr
    Watch ctr_lnsnsr
    Watch rt_lnsnsr
    '
    · 'INTERRUPT
    '
    'ISR_Start:
    · ' ISR code here
    ·'ANALOGIN InPin, OutPin, adcval, 2

    'ISR_Exit:
    · 'RETURNINT ' {cycles}································

    '
    ' Subroutine Declarations
    '
    '
    ·Program Start
    '
    Start:
    · TRIS_C = %0000000··'Set C to outputs
    · ST_B =%11111111··'Set B to schmitt inputs
    ·
    · 'LOW Enable_Right·············· 'Turn off Right Motor
    · 'LOW Enable_Left··············· 'Turn off Left Motor
    · 'Pause 5000
    MAIN:
    ·· input ctr_lnsnsr
    ·· input rt_lnsnsr
    ·· input lft_lnsnsr
    ·
    · goto main
  • Sparks-R-FunSparks-R-Fun Posts: 388
    edited 2007-07-19 23:11
    I suggest placing the pin assignments in the pin definition area. That is what makes sense to me. Technically I am not sure it matters much as long as they are defined before they are needed.

    I have had some trouble trying to WATCH single bits through Debug in the past. The following threads contain relevant information about when this problem has been observed.

    WTCHing a pin with SX/B (Without using a variable)
    Watched Bit not Showing Changes

    - Sparks
Sign In or Register to comment.