BS2p 40 pin assignment problems.
the_0utsider1
Posts: 13
Here is an abreviated copy of my code:
MAINIO
OUTPUT 0
solenoid con 0
AUXIO
OUTPUT 0
dev1 con 0
.
.
.
In troubleshooting i make the following changes:
start:
MAINIO
OUTPUT 0
solenoid con 0
high solenoid
pause 100
low solenoid
pause 100
AUXIO
OUTPUT 0
dev1 con 0
high dev1
pause 100
low dev1
pause 100
goto start
and the solenoid cycles on\off, dev1 doesnt.
if i move it to after DEV1 CON 0, neither cycle.
I thought i could define AUXIO to an alias instead of having to put AUXIO or MAINIO like 200 times in the code.
Am i wrong?
TIA
MAINIO
OUTPUT 0
solenoid con 0
AUXIO
OUTPUT 0
dev1 con 0
.
.
.
In troubleshooting i make the following changes:
start:
MAINIO
OUTPUT 0
solenoid con 0
high solenoid
pause 100
low solenoid
pause 100
AUXIO
OUTPUT 0
dev1 con 0
high dev1
pause 100
low dev1
pause 100
goto start
and the solenoid cycles on\off, dev1 doesnt.
if i move it to after DEV1 CON 0, neither cycle.
I thought i could define AUXIO to an alias instead of having to put AUXIO or MAINIO like 200 times in the code.
Am i wrong?
TIA
Comments
When designing your circuit, you should try to put frequently used pins on either the Main or Aux I/O pins, so you don't need to put a lot MAINIO and AUXIO statements in your program. But whenever you need to switch between them, you will need one of these commands.
Now to fix my amperage problem...
Thanks.
Mike is right! The reference manual states: "This pin will be placed into output mode."
I've used HIGH and LOW without setting DIRS. You have to be in the correct bank (Main or Aux I/O) though.
MAINIO
high 0
AUXIO
OUTPUT 0
high 0
.
.
so auxio pin 0 should be high, right? cuz on mine, there is no voltage. I get ~5v from mainio pin 0.
Thx.
PS. can u guys answer a trivial Q?
I have another BS2p 24 pin
I have wired a simple NO switch where output 1, output 2, output 3, input 4
I want to use these where output 1 to a NO switch through a resistor back to input 4 to "tell the chip i pressed a button" (i have 3 switches) What size resistor do i use so as not to fry the chip? I try simple ohms law and use a 215ohm R and the dowhile loop is if input 4=1 exit. (In the dowhile loop the led blinks on and off..)
but nothing happens and the led keeps blinking.
TIA!!
The minimum recommended R for connecting input/output pins is 220 ohms, so your calculation is very close. But higher is better, and a 1k ohm resistor would also work. But when the switch is open, there is no connection to your input, so it floats and can report either a 1 or 0. Try adding a pull-down resistor on the input pin, say 10k ohms. Normally switches are wired to either Vdd or Vss, not between an input and output pin. You should post your entire code and a schematic in order to help figure out what is going on.
-i cannot use an output as a power supply, the input did nothing. I switched to powersupply as and bingo.
-for code, i have
INPUT 0
dev1 con 0
in code, if i have if dev1 = 1 then quit it doesn't work. if i have if in0 = 1 then quit this DOES work.
-BUT-
i can use dev1 when it comes to output like high dev1 pause 1000 low dev1 and the led blinks...
Go figure...
...pardon? What do you mean?
I use 12V that also powers some motors to 80Ohm then pull down with a 100Ohm to ground and IT WORKS!!!
THANKS GUYS!!!
Maybe someday ill actually get down and dirty and start playing with more components....