Inverting Smart Pin mode %01101
JimFouch2
Posts: 26
Description from P2 Docs.... %01101 = Accumulate A-input positive edges with B-input supplying increment (B=1) or
decrement (B=0)
I'm looking at using this mode to keep track of the steps for a stepper motor controller.
Only issue is I don't see a way of inverting the logic for the B pin. Sometimes on an axes, I will want to invert the direction. I know the the simple way would just invert the sign on the reading of the smart pin, but that really only works if you start from zero.
When the device this is attached to hits it's home position, I normally load an offset into a counter. I then add whatever the hardware counter has detected. Without the ability to invert the B Pin logic, I think if I keep my offset separate from the SmartPin's output, I should be ok.
decrement (B=0)
I'm looking at using this mode to keep track of the steps for a stepper motor controller.
Only issue is I don't see a way of inverting the logic for the B pin. Sometimes on an axes, I will want to invert the direction. I know the the simple way would just invert the sign on the reading of the smart pin, but that really only works if you start from zero.
When the device this is attached to hits it's home position, I normally load an offset into a counter. I then add whatever the hardware counter has detected. Without the ability to invert the B Pin logic, I think if I keep my offset separate from the SmartPin's output, I should be ok.
Comments
I remember OzProp telling me there are actually two ways to invert inputs in the WRpin config, I think you get a bit in the 'pin redirect' 4 bits, as well as a bit in the 'cio' field, and if you select both you're back to 'non inverted'. Fwiw
In the logic mode %0000_CIOHHHLLL, the %I bit controls IN inversion.
Thanks Chip.
Every time when that table is referenced somewhere it should also be noted that nobody has to learn any of the bit patterns, theese days. There are predefined symbols that can be used to make everything much easier. See end of Spin2 documentation Chapter "Built-In Symbols for Smart Pins".