Cable tester code help

XLSERVICE

New Member
Hi Guys

I am building a cable tester and need some assistance with a bit of code.
This bit of code is used when testing the cable for intermittent connections.

This is what I would like to use, but it returns syntax errors..
If b0>0 and pin0 = 0 then : low portb (b0-1) : high portc 5 : b12=1 : endif

The value in 'b0' represents the output port that is connected (via the cable under test) to input 0.
If input 0 goes LOW then turn off the portb OUTPUT that is driving it (in this case the value in b0-1)
This line would be repeated for b0 to b9.

Basically I am asking how do I change the port number in relation to a variable.

Cheers
Alan
 

hippy

Ex-Staff (retired)
You will have to use a temporary variable to hold the value-1 ...

If b0>0 and pin0 = 0 then : b13=b0-1 : low portb b13 ...

Additionally, "PORTB" isn't supported for the current PICAXE range. If these are the normal output pins, simply use "LOW b13".

If it is more complicated than I understand it to be you will have to provide further details on what operation you require.
 

XLSERVICE

New Member
Cheers. That solution should work fine..
portb and Portc seem to work fine. I am using a 40X1 Picaxe.

I will try 'b' and 'c' instead.. May save me a bit of memory..

Cheers
Alan
 

westaust55

Moderator
Cheers. That solution should work fine..
portb and Portc seem to work fine. I am using a 40X1 Picaxe.

I will try 'b' and 'c' instead.. May save me a bit of memory..

Cheers
Alan
Alan,

from your response not sure you have fully understood.
"b" and "c" alone will not work and "portB" as a keyword is not supported.
Port B is the normal outputs on the 28X1 and the 40X1.

as hippy has suggested use:
Code:
b1 = b0 - 1
If b0>0 and pin0 = 0 then : low b1 : high portc 5 : b12=1 : endif
Presume that b1 is not lower than 1. If b0 = 0 then due to "roll-over" b0-1 = 255
 

XLSERVICE

New Member
Thank's Guys
Having read this a couple of times, I think I now understand.

As Port B pins are the default outputs for the Picaxe, the port does not need stating. So LOW Portb 5 should be replaced with LOW 5 or, in my case the port number can be replaced with a variable eg. LOW b13....

The rest of my cable tester is currently working fine, however, I have used Porta, Portb and Portc throughout.

Performing the subtraction within the IF statement should avoid 'rollover' as if the variables b=0 the IF line will not be entered.

Cheers
Alan
 

westaust55

Moderator
Alan,

sorry but you cannot do any maths as part of the IO level (high/low) setting

so LOW (b0-1) is going to give you a syntax error.


please look again at what I wrote at port 4 in the second code box.

Likewise just for your information, you cannot do maths as part of the test within an IF...THEN command

for example
IF b0 > b1+2 THEN GOTO main​
will give a syntax error
 
Last edited:
Top