dubhunter
Computer
- Sep 21, 2007
- 6
Hi,
I am a programmer by trade, so some of the electrical engineering stuff goes over my head. I will do my best to explain my problem and I would love anyones input.
PROBLEM:
I have an Elexol Ethernet IO24 Digital I/O Module, with an Elexol 8 CH Opto-Isolated I/O Board connected to it.
So now I have 8 digital channels to work with.
I need to build a module that connects to the 8 CH I/O board and supports 4 sensors.
If each sensor has 8 bits of precision, I will need to limit them to 6 bits of "readable" precision. And use the last 2 bits (on my I/O module) for control. Here is some pseudo code to explain my logic, hope it makes sense.
//array is io board, pins 6,7 are control pins, while 0-5 are data pins (from sensors)
$ioBoard = array(0, 0, 0, 0, 0, 0, 0, 0);
//poll sensors based on value of pins 6,7
$ioBoard = getSensorData($ioBoard[6], $ioBoard[7]);
//the sensor circuit
function getSensorData($pin6, $pin7)
{
//6 bits data
$data = array(0,0,0,0,0,0);
//magic circuit logic
switch ($pin6.$pin7)
{
//sensor 1
case '00':
$data = SENSOR_1_8_BITS_TRUNCATED_TO_6;
break;
//sensor 2
case '01':
$data = SENSOR_2_8_BITS_TRUNCATED_TO_6;
break;
//sensor 3
case '10':
$data = SENSOR_3_8_BITS_TRUNCATED_TO_6;
break;
//sensor 4
case '11':
$data = SENSOR_4_8_BITS_TRUNCATED_TO_6;
break;
}
return $data + array($pin6, $pin7);
}
I am a programmer by trade, so some of the electrical engineering stuff goes over my head. I will do my best to explain my problem and I would love anyones input.
PROBLEM:
I have an Elexol Ethernet IO24 Digital I/O Module, with an Elexol 8 CH Opto-Isolated I/O Board connected to it.
So now I have 8 digital channels to work with.
I need to build a module that connects to the 8 CH I/O board and supports 4 sensors.
If each sensor has 8 bits of precision, I will need to limit them to 6 bits of "readable" precision. And use the last 2 bits (on my I/O module) for control. Here is some pseudo code to explain my logic, hope it makes sense.
//array is io board, pins 6,7 are control pins, while 0-5 are data pins (from sensors)
$ioBoard = array(0, 0, 0, 0, 0, 0, 0, 0);
//poll sensors based on value of pins 6,7
$ioBoard = getSensorData($ioBoard[6], $ioBoard[7]);
//the sensor circuit
function getSensorData($pin6, $pin7)
{
//6 bits data
$data = array(0,0,0,0,0,0);
//magic circuit logic
switch ($pin6.$pin7)
{
//sensor 1
case '00':
$data = SENSOR_1_8_BITS_TRUNCATED_TO_6;
break;
//sensor 2
case '01':
$data = SENSOR_2_8_BITS_TRUNCATED_TO_6;
break;
//sensor 3
case '10':
$data = SENSOR_3_8_BITS_TRUNCATED_TO_6;
break;
//sensor 4
case '11':
$data = SENSOR_4_8_BITS_TRUNCATED_TO_6;
break;
}
return $data + array($pin6, $pin7);
}