View Single Post
Old December 5th, 2017, 11:38 AM   #8
MATT116
Member
United States

MATT116 is offline
 
Join Date: Dec 2009
Location: Dallas, TX
Posts: 327
Ok I was able to get everything working in a single program with a "switch"
First I set the address to the first power supply then do the 6 need query's. Then set the address to next power supply, then do the 6 need query's and so on through all the power supply's. This code only runs when there is no "Need to write".
The key was to set the address once then query not set the address before every query and also clearing the port before each query.

switch(State) {
// Query the 1st power supply
case 0:
PortPrint (Port, "ADDS 0" + "\R\N");
break;
// Request Status 0 (Alarms)
case 1:
ClearRx(Port);
PortPrint (Port, "STUS 0" + "\R\N");
Temp = PortInput(Port,0,13,400,6);
PWS1.Status0 = TextToInt(Temp,16);
break;
// Request Status 1
case 2:
ClearRx(Port);
PortPrint (Port, "STUS 1" + "\R\N");
Temp = PortInput(Port,0,13,400,6);
PWS1.Status1= TextToInt(Temp,16);
break;
// Request Actual Voltage
case 3:
ClearRx(Port);
PortPrint (Port, "RV?" + "\R\N");
PWS1.Voltage = PortInput(Port,0,13,400,6);
break;
// Request Actual Current
case 4:
ClearRx(Port);
PortPrint (Port, "RI?" + "\R\N");
PWS1.Amp = PortInput(Port,0,13,400,6);
break;
// Request Temperature
case 5:
ClearRx(Port);
PortPrint (Port, "RT?" + "\R\N");
PWS1.Temp = PortInput(Port,0,13,400,6);
break;
// Request Power Status
case 6:
ClearRx(Port);
PortPrint (Port, "POWER 2" + "\R\N");
Temp = PortInput(Port,0,13,400,6);
PWS1.Power = TextToInt(Temp,16);
break;

// Query the 2nd power supply
case 7:
PortPrint (Port, "ADDS 1" + "\R\N");
break;
  Reply With Quote