jcarlyle Posted August 25, 2009 Share Posted August 25, 2009 I have 6 Modbus radios that I'm getting data from successfully using a sequence. The way I'm doing it is a bit clunky, though. In the Channel table I define 4 variables per radio, using a nomeclature like AI1_1 and AI1_2, where the last digit corresponds to the Modbus device number. To retrieve the data I use the following sort of code (this example limited to 2 radios): try // Slave Radio 1 data = Device.ModBus_1.ReadInputS16(1,0,10) private.data[0][0] = Ana_In*private.data[0][0] private.data[0][2] = Ana_In*private.data[0][2] private.data[0][8] = Bat_In*private.data[0][8] AI1_1.AddValue(private.data[0][0]) AI2_1.AddValue(private.data[0][2]) Vbatt_1.AddValue(private.data[0][8]) degC_1.AddValue(private.data[0][9]) catch() // Make sure sequence doesn't halt because of error ? strLastError endcatch delay(Acq_Dly) // Give radio time to settle try // Slave Radio 2 data = Device.ModBus_1.ReadInputS16(2,0,10) private.data[0][0] = Ana_In*private.data[0][0] private.data[0][2] = Ana_In*private.data[0][2] private.data[0][8] = Bat_In*private.data[0][8] AI1_2.AddValue(private.data[0][0]) AI2_2.AddValue(private.data[0][2]) Vbatt_2.AddValue(private.data[0][8]) degC_2.AddValue(private.data[0][9]) catch() // Make sure sequence doesn't halt because of error ? strLastError endcatch delay(Acq_Dly) // Give radio time to settle What I'd like to do is define the variables AI1_1, AI1_2...AI1_6, AI2_1, AI2_2...AI2_6, Vbatt_1, Vbatt_2...Vbat_6, degC_1, degC_2...degC_6 in the Channel table to be arrays like AI1[n], AI2[n], Vbatt[n] and degC[n], where n is the radio number. But I can't find any examples of how to do this, and I'm stumped because I know the channel variables are not variables but a two dimensional array. Can you show me a method to handle this problem? Thanks! -John Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.