I am trying to log two types of switching based data: port state (motor on/off state) and count pulses (fuel meter). I have 12 motor state readings to record and four pulse counting readings to record.
The fuel meter provides a TTL-level square pulse and the motor state is a mechanical switch closure. I am fairly confident the electrical side of the system will work as intended (it's worked in other applications with a single signal type).
My main concern is how to ignore the unneeded ports during each of the two calls to the SDMIO16, since I can't mix the types of readings I need (i.e. port state and pulse counting) in one command.
I'm calling the measurement with the following commands:
BeginProg
Scan(1,Sec,1,2)
SDMIO16(Version,IO16Status(2),0,99,2222,3333,3333,3333,1,0)
Next Scan
'Main Scan
Scan(1,Sec,1,0)
'Read motor on/off state
SDMIO16(MotorState(),IO16Status(3),0,92,9999,3333,3333,3333,1.0,0)
'Read pump pulser output
SDMIO16(Pulse(),IO16Status(3),0,20,2222,9999,9999,9999,1.0,0)
CallTable(Table1)
Next Scan
Am I on the right track, or is there a better way to handle what I'm trying to accomplish?
Many Thanks!
* Last updated by: msageng on 3/17/2015 @ 12:43 AM *
I don't understand why you have the mode(s) set to 4 digit numbers instead of 0, as per help those numbers would only apply when you use command 86, 87, 88, 89 or 90 which you don't?
".. Each Mode parameter is used to configure a bank of four ports when a Command code 86 through 90 is used (if any other Command Code is used, enter 0 for the Mode parameters) .."
As for your question:
If you're short on variable memory or fancy ForNextLoops you could try the modes for asking a single port status (1-16) and frequency (24-39) and wrap it up in a For Next Loop with the counter being used as mode selector and array index.
OR
You go down the path you seem to be going already and split it up in 3 commands where you go for 4 ports frequency at once with mode (40-43) and put this in a freq-arrray(4) and the other 2 commands are being used with a mix of mode (17-20 and 22-23) going into a status-array(12). The 2nd command of the latter two will need an offset for the status-array, depending on your choices this will either be status-array(4) or status-array(8).
* Last updated by: Nico on 3/19/2015 @ 8:25 AM *