9 bit optical encoder input to SX28 or how to read the ports
I need help on this one...............
Am learning to program the SX chips·so I'm not sure of how to read 9 input pins at once. I've got a rotary optical encoder giving me 9 bits in parallel that represent 0 to 360 Degrees of rotation. I need to use 9 pins to read the encoder as it doesn't have a serial output.
Does anyone know the instruction that would read 9 pins at one time and store the state (1 or 0, high or low status) of each pin? I'm looking to·develop a binary number 9 digits long like 101010101 to use in the code I'm writing. I would then convert this binary number to degrees rotation·as a·decimal number.
Let me say thanks in advance to anyonethat can help me with this one.
Am learning to program the SX chips·so I'm not sure of how to read 9 input pins at once. I've got a rotary optical encoder giving me 9 bits in parallel that represent 0 to 360 Degrees of rotation. I need to use 9 pins to read the encoder as it doesn't have a serial output.
Does anyone know the instruction that would read 9 pins at one time and store the state (1 or 0, high or low status) of each pin? I'm looking to·develop a binary number 9 digits long like 101010101 to use in the code I'm writing. I would then convert this binary number to degrees rotation·as a·decimal number.
Let me say thanks in advance to anyonethat can help me with this one.

Comments
Something like this... Clock VAR RA.5 ' shift clock (74HC165.2) SerData VAR RA.6 ' serial data (74HC165.7) Load1 VAR RA.7 ' input load (74HC165.1) switches VAR BYTE 'Probably can change this to a WORD Get_165: PULSOUT Load1, 50 ' load switch inputs SHIFTIN SerData, Clock, MSBPRE, switches ' shift them in RETURN DO Get_165 'Read 74HC165 button inputs PAUSE 200 IF switches.1 = 1 THEN 'Check upper button and increment hours INC tmpB3 ENDIF IF switches.2 = 1 THEN 'Check 2nd button and decrement hours DEC tmpB3 ENDIF IF switches.0 = 1 THEN 'Ready...Go to the next selection (Minutes setting...) GOTO HRS_EXIT_HERE ENDIF LOOP·
These things were designed/marketed to be Virtual Periferals - use them like that - use them as their own extenders.
encoder VAR WORD
encoder = RBC AND 511
Note that RBC is a virtual 16 bit I/O port. It is actually read as two seperate reads, so you have to make sure the value from the encoder doesn't change between the reads.
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.iElectronicDesigns.com
·