PDA

View Full Version : Auxio and var



T Chap
05-26-2006, 12:52 PM
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?

Chris Savage
05-26-2006, 01:34 PM
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 (mailto:csavage@parallax.com)

T Chap
05-26-2006, 01:57 PM
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 Chap
05-26-2006, 05:08 PM
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 Savage
05-26-2006, 08:59 PM
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 (mailto:csavage@parallax.com)

T Chap
05-26-2006, 11:35 PM
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