Software Multiplexing???
tommyc
Posts: 7
I am reading serial data into a BS2 from two sensors, and would like to reduce the program space required to process the input data (which is handled identically).·
Is there a way to use the same subroutine for two sets of I/O pins and variables?
Is there a way to use the same subroutine for two sets of I/O pins and variables?
Comments
Sure, make the pin port number a variable name, and set it as you see fit.
Regards,
Bruce Bates
SensorPin··· DATA··· 12, 15
sensorDat··· VAR··· ·Byte(2)
idx··········VAR···· Nib
Get_Sensors:
· FOR idx = 0 TO 1
··· READ SensorPin + idx,·sio
··· SERIN sio, Baud, [noparse][[/noparse]sensorDat(idx)]
· NEXT
· RETURN
If your serial pins are contiguous (grouped together), you can set the value of sio with math instead of reading the pin numbers from a table.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax