help declaring nibble variables...
kutalinelucas
Posts: 80
Hey guys, I was wondering if somebody could give me a little help
I have a few bs-2 modules controlling stepper motors; the problem is one of the pins remains consistantly high, and the circuit boards are already made up.
In my BS2 program, the coils of the motor are energised by sequencing through OUTA; pins p0->p3 BUT, pin3 is dead so I was wondering if theres a way I can declare a 4-bit variable but with pins P0,P1,P2,& P4?
saying that I guess I could change the step sequence to include a fifth pin and remove the dead pin from the module; so then could somebody help me out with how to declare 5 pins as a variable?, as opposed to declairing a nibble
Any response is greatly appriciated...
Cheers,
I have a few bs-2 modules controlling stepper motors; the problem is one of the pins remains consistantly high, and the circuit boards are already made up.
In my BS2 program, the coils of the motor are energised by sequencing through OUTA; pins p0->p3 BUT, pin3 is dead so I was wondering if theres a way I can declare a 4-bit variable but with pins P0,P1,P2,& P4?
saying that I guess I could change the step sequence to include a fifth pin and remove the dead pin from the module; so then could somebody help me out with how to declare 5 pins as a variable?, as opposed to declairing a nibble
Any response is greatly appriciated...
Cheers,
Comments
Assuming P0,P1,P2 and P4
224 ( %11100000 ) will preserve anything thats going on with P5,P6 and P7 should they be outputs.
The step values in the data table will have to be re written to take into account the faulty pin, so for example %1010 will become %10010
Jeff T.
Lucas.
mask = (OUTL & 224) + StepValue
OUTL = mask
Coils VAR OUTL
Lucas.
and you are right when you say Coils Var OUTL , which I am assuming will replace Coils Var OUTA.
Jeff T.
EDIT: it also requires that the DIR register has P4 set to output in addition to P0,P1,P2
EDIT2 : thinking about it you don't even need the mask variable
I know the way you have it is fine and clarifies the steps so I guess its whatever you prefer.
eg: from the Parallax example
the READ will have to be done separately from the OUT, in the Parallax example Phase is used as the variable to hold the step value
I don't see a way to avoid the extra step at the moment
.
Jeff T.
Another EDIT: looking at the DIRA and DIRB, if they remain as inputs then you will not need the mask of 224 so you could indeed just set the outputs from the READ values
Lucas.