Probobilly very easy to solve, but i'm stumped

AlexanderB

New Member
A2 work now for me and i'm having trouble with my PICAXE 28x1, with the inputs to be eaxct.
is there a way to configure the inputs to be digital instead of analog?

Kind of something like:

pin1 high then do...

cheers in advance
 

eclectic

Moderator
A2 work now for me and i'm having trouble with my PICAXE 28x1, with the inputs to be eaxct.
is there a way to configure the inputs to be digital instead of analog?

Kind of something like:

pin1 high then do...

cheers in advance
Do you mean something like this:
Code:
#picaxe 28X1

main:
if portA pin2 = 1 then high 4
else low 4

endif

goto main
Haven't got a 28X1, but
it passes syntax and Simulation

e
 

John West

Senior Member
If you have the program editor there (I assume you do,) then you should find all three picaxe manuals available through the HELP command, as they are included with the Editor install. Start-up manual is Manual 1. BASIC commands manual is Manual 2. Interface is Manual 3.
 

westaust55

Moderator
@Alexander,

Only a limited number of commands will work with the PortA pins.
Port A is primarily the analogue inputs for the PICAXE 28X1 and 40X1 chips

Within PICAXE BASIC programming you are limited to testing the state (high or low) for each PortA pin individually. See PICAXE manual 2 page 127
so the syntax is in the form
IF PORTA <pin#> <test condition> value {AND/OR variable <test condition> value ...} THEN {GOTO} address/label​


If you wanted to simultaneously test the state of several pins on PortA you can use the PEEK command to read the entire PortA register which is at address SRF address 5 (you need to read the PIC datasheet to identify that location). So,
PEEK 5, b9​
will put the status of the entire set of portA pins into variable b9.

Say you wanted to see if any of pins 0, 1 or 2 were then high, you could then use
PEEK 5, b9
b9 = b9 AND %00000111 ; only keep data from pins 2,1 ,0
IF b9 > 0 THEN dosomething ; goto label/action of any of the 3 pins is high (=1)​
 

AlexanderB

New Member
sorry its taken a while to get back, been working a lot on other subjects:
@John West
yes i do have the manuals, however i honistly don't find them all that helpful. i find it much easy to have an explination as well as the syntax.

@westaust55

ok so that seems very hard to understand so i'll read the manual on it and see if that helps, is by any chance the PORTC pins digital?

they have In0/In1... for the names and the PORTA have In a0/In a1...
I'm now guessing that the little "a" means that they are analog (from what you said) and that as the PORTC don't have the A they are just digital inputs
 

hippy

Ex-Staff (retired)
is by any chance the PORTC pins digital?

they have In0/In1... for the names and the PORTA have In a0/In a1...
I'm now guessing that the little "a" means that they are analog (from what you said) and that as the PORTC don't have the A they are just digital inputs
Take a look at Manual 1 pinouts. The names are more convenience to indicate upon which ports they are on. For the 28X1, legs 2-5 are PORTA, are labeled "ADC0 / In a0" etc; those are analogue inputs or digital inputs. Legs 11-16 are PORTC, are labelled "In 0 / Out c0" etc; those are the default digital inputs and can also be used as PORTC outputs.
 
Top