Shop OBEX P1 Docs P2 Docs Learn Events
Auxio and var — Parallax Forums

Auxio and var

T ChapT Chap Posts: 4,217
edited 2006-05-26 16:35 in BASIC Stamp
I am having trouble making auxio and var work when using mainio but to control auxio output. Here is an example:

MAINIO

INPUT 1
BUT1 var in1


AUXIO

output 1

AUXTEST_LED var OUT5


MAIN:

IF BUT1 = 1 THEN

AUXTEST_LED = 1

ENDIF

GOTO MAIN


Things work fine if I do this:


main:

auxio

main:
auxtest_led = 1
pause 500
goto main


BUT, unless MAINIO or AUXIO preceeds their respective commands, they don't work.

Why can't you assign a varable to an auxio output, and then to a mainio input and have them talk to each other using their alias?

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-05-26 06:34
    You cannot do it this way.· Valid pins are only 0 through 15.· So you must precede each access with the approrpiate·bank command if you need to change which bank you're accessing.

    Typically you would set up pins as follows:

    ' Main I/O Definitions
     
    LED1      PIN    0
    LED2      PIN    1
    CalSwitch PIN    2
     
    ' Aux I/O Definitions
     
    ADC_Clock PIN    0
    ADC_Data  PIN    1
    ADC_CS    PIN    2
    

    Notice no MAINIO or AUXIO commands?· You would use those in the code for example:

    MAINIO
    HIGH LED1
    LOW LED2
    Temp = CalSwitch
     
    AUXIO
    SHIFTOUT (ETC.)  <---Just an example of switching to Aux bank
    

    The same goes for variables...You cna't lock them to a bank.· Whatever bank is active gets assigned based on its pin number or port group.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • T ChapT Chap Posts: 4,217
    edited 2006-05-26 06:57
    Ok I got it, seems little clunky but if that is the trade off so be it. So, how to do an AND statement containing one part from MAINIO and one part from AUXIO?

    ie IF (LOCKBUT_M = 1) AND (LOCK_LATCH_M = 0) THEN TURN_LOCK_LATCH_M_ON


    whereas LOCKBUT_M = 1 is on mainio and LOCK_LATCH_M = 0 is on auxio


    Thanks a lot Chris!
  • T ChapT Chap Posts: 4,217
    edited 2006-05-26 10:08
    Chris I solved it with a round about method still using the variables, see below to note that instead of putting the mainio var and auxio var on the same AND line, I read first the mainio determinant, then if the first part was met, I sent it to a location that then read the auxio part and made the decision from there. Also note that I sent it further to a "hold" place to keep it from looping around again. Maybe there is abetter way but it works.

    Thanks



    CHECK_LOCKBUT_M:
    MAINIO
    IF LOCKBUT_M = 0 THEN RETURN
    IF (LOCKBUT_M = 1) THEN CHECK_Lock_Latch_M

    CHECK_Lock_Latch_M:
    AUXIO
    IF lock_latch_m = 0 THEN TURN_LOCK_LATCH_M_ON
    IF lock_latch_m = 1 THEN TURN_LOCK_LATCH_M_OFF

    TURN_LOCK_LATCH_M_ON:
    AUXIO
    LOCK_LATCH_M = 1
    GOTO HOLD_FOR_LOCKBUT_M_RELEASE

    TURN_LOCK_LATCH_M_OFF:

    AUXIO
    LOCK_LATCH_M = 0

    GOTO HOLD_FOR_LOCKBUT_M_RELEASE

    HOLD_FOR_LOCKBUT_M_RELEASE:
    MAINIO
    IF LOCKBUT_M = 1 THEN HOLD_FOR_LOCKBUT_M_RELEASE
    IF LOCKBUT_M = 0 THEN RETURN
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-05-26 13:59
    I was going to suggest something close...Note this example is not related to your code, but it does do a conditional on information from each bank.

    MAINIO
    Status1 = IN0
    AUXIO
    Status2 = IN0
     
    IF Status1 = 1 and Status2 = 0 THEN
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • T ChapT Chap Posts: 4,217
    edited 2006-05-26 16:35
    that is nice too essentially using an extra set of variables when auxxio and mainio needs to intermingle. so it is a simple extra step or two no big deal.

    thanks
Sign In or Register to comment.