28X1 versus 28X2 port designations

hbl2013

Senior Member
I have a problem using the 28X1 in a project I am working on. I wrote the program originally for the 28X2, but wanted to take advantage of the automatic analog features of the 28X1 chip and rewrote the program. The problem is in the different port designations the 28X1 uses. This is the partial code:
Code:
' .---------------------------------------------------------------------------.
' |     Define Input and Output Pins                                          |
' `---------------------------------------------------------------------------'

symbol IRleft		= 1	'analog input-PIN3=A1-7 right LED Array
symbol IRright		= 3	'analog input-PIN5=A3-8 top LED Array
symbol IRup		= 2	'analog input-PIN4=A2-9 left LED Array
symbol IRdown		= 0	'analog input-PIN2=A0-3 bottom LED Array

symbol leftmotor		= B.0	'servo output-PIN21 - Left Motor Servo OUT
symbol rightmotor		= B.1        'servo output-PIN22 - Right Motor Servo OUT
symbol neckupdown		= B.2	'servo output-PIN23 - Up/Down Servo OUT
symbol neckleftright	        = B.3	'servo output-PIN24 - PAN Servo OUT

symbol IRleds		       = B.4 	'digital output-PIN25 - Output Strobe LED Array

symbol LED1OUT		= pinC.0
symbol LED2OUT		= pinC.1
symbol LED3OUT		= pinC.2
symbol LED4OUT		= pinC.3

symbol LED5IN		= pinC.4
symbol LED6IN		= B.5
symbol LED7IN		= B.6

'Start Program

HIGH LED1OUT
It looks like that I can use the B.0-B.7 as well as the straight numerical 0 to 7 to indicate the B ports. The compiler also accept the pinC.0-pinC.7 syntax for the C ports, for it does not issue an error with the above code.

The problem is that the compiler issues an error on the last line, telling me that I should have used an "0" instead of "pinC.0". But does that not indicate the B4 (IC pin25)pin? Or is the above assumption on the B Port designations, wrong?
The question is: How do I choose between the C versus the B port using the 28x1 chip?

Any comments, suggestions?
 

hippy

Technical Support
Staff member
"HIGH LED1OUT" when "LED1OUT" is defined as "pinC.0" for a 28X2 won't pass Syntax Check, will generate an error because it won't do what a user probably wants it to.

If you want to set leg 11 ( C.0 on a 28X2 ) then simply use "HIGH C.0" or "HIGH LEDXOUT" and define LEDXOUT as "C.0".

If you want to set leg 11 ( Port C pin 0 on a 28X1 ) then you need to use "HIGH PORTC 0" or "HIGH PORTC LEDXOUT" and define LEDXOUT as "0".

Though you mention leg 25, B.4 so I am a little confused as to what you are trying to achieve.

If you want to set leg 25 ( B.4 on a 28X2 or Port B pin 4 on a 28X1 ) then use "HIGH B.4" or "HIGH LEDXOUT" and define LEDXOUT as "B.4".

You could also use "HIGH 4" or "HIGH LEDXOUT" and define LEDXOUT as "4" for both 28X2 and 28X1.

It may be worth saying what you are trying to achieve, which leg or port pin you want to take high, and then it will be easier to answer the question.
 

hbl2013

Senior Member
Thanks hippy. What I really am confused about is the different port designations for the X1 and X2 chips. In my case, I wanted to use a mix of Analog Inputs, LEDs and servos and use the different ports available on the A, B and C ports. Because of the confusion, I can not determine which port will operate if I use the designator "0" (or any other numerical) in any of the ports. Is the A0, B0 or C0 port? And how do I choose between them? Is there any information on this subject available that I can refer to?
 

hippy

Technical Support
Staff member
I can not determine which port will operate if I use the designator "0" (or any other numerical) in any of the ports. Is the A0, B0 or C0 port?
I think you are looking at things the wrong way round, are trying to work out what a number will mean or do, when you need to look at what you are doing and then determine what number it should be to achieve that. See below ...

And how do I choose between them? Is there any information on this subject available that I can refer to?
On the 28X1 there is Port A for analogue input, Port B for outputs, and Port C for input. Though it is also possible to use Port C for output it is best to use Port B for output if possible.

So allocate your analogue inputs to Port A, have your digital outputs from Port B, and digital inputs to Port C.

Once you have decided what's connected and to where, the port names to use for those becomes easy to determine.

Analogue input on A.1 ...

Symbol ADC1IN = 1
ReadAdc ADC1IN, b0

Digital Output on B.2 ...

Symbol LED2OUT = B.2
High LED2OUT

Digital Input on C.3 ...

Symbol BTN3IN = pinC.3
If BTN3IN = 1 then
 
Last edited:

hbl2013

Senior Member
I think you are looking at things the wrong way round, are trying to work out what a number will mean or do, when you need to look at what you are doing and then determine what number it should be to achieve that. See below ...
That is because I tried to translate 28X2 in 28X1 code

Once you have decided what's connected and to where, the port names to use for those becomes easy to determine.

Analogue input on A.1 ...

Symbol ADC1IN = 1
ReadAdc ADC1IN, b0

Digital Output on B.2 ...

Symbol LED2OUT = B.2
High LED2OUT

Digital Input on C.3 ...

Symbol BTN3IN = pinC.3
If BTN3IN = 1 then
Ok, I will try that. Thanks.
 

hippy

Technical Support
Staff member
That is because I tried to translate 28X2 in 28X1 code
Are you trying to use the 28X1 in the same circuit which previously used a 28X2 with connections to the same legs, or is this a new project where you can decide where to allocate your connection to legs ?

The reason it's not clear what you are doing is because -

symbol LED2OUT = pinC.1

symbol LED6IN = B.5

Do not make much sense for either a 28X2 or 28X1. An output using HIGH/LOW would not normally be a "pinX.Y", just an "X.Y", and its the opposite for an input, would normally be "pinX.Y" rather than just "X.Y".

I guess you tried to convert, this is what you arrived at, and it hasn't worked. It may be worth just posting a list of connections, whether input or output, and which legs/pins they go to.
 

hbl2013

Senior Member
I guess you tried to convert, this is what you arrived at, and it hasn't worked. It may be worth just posting a list of connections, whether input or output, and which legs/pins they go to.
Yes, you are right. This is a program written for the 28X2, which I tried to adapt for the 28X1.
In any case, the program worked for the 28X2, and wanted to see if the 28X1 was suitable for the same tasks, and there is where I ran into the syntax problems.

Before I go further with this topic, let me try to start all over again, because I am getting utterly confused myself. Once I get it straightened out, I will re-post the problems I still might have.
In the mean time, thanks hippy.
 
Top