View Full Version : Software Multiplexing???
01-21-2006, 01:19 AM
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?
01-21-2006, 01:30 AM
Sure, make the pin port number a variable name, and set it as you see fit.
01-21-2006, 01:38 AM
Here's one way to implement Bruce's suggestion:
SensorPin··· DATA··· 12, 15
sensorDat··· VAR··· ·Byte(2)
· FOR idx = 0 TO 1
··· READ SensorPin + idx,·sio
··· SERIN sio, Baud, [sensorDat(idx)]
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.
Applications Engineer, Parallax