<
I am developing Processing GUI for PID control.
I wish to use JSON to share data between the PC and the control board.
But i am having issue packaging the JSON object.
I need send and receive 12 variable (double).
I was able to package upto 9 doubles variables.
If i add one more (10 variables) the packet get truncated
This is the Error package:
{“KP”:41.1,“KI”:23.1,“KD”:10.1,“FSP1”:1.0,“FSP2”:1.2,“TPSP”:36.3,“FL1”:0.9,“FL2”:1.8,“TMP”:34.1"UPT
Well packaged (maximum of 9 variables)
{“KP”:41.1,“KI”:23.1,“KD”:10.1,“FSP1”:1.0,“FSP2”:1.2,“TPSP”:36.3,“FL1”:0.9,“FL2”:1.8,“TMP”:34.1}␊
//===========================================================================
//This Function Send JSON Payload
//===========================================================================
typedef struct
{
double _1FLOWsp;       //1 Flow setpoint
double _2FLOWsp;       //2 Flow setpoint
double _TEMPsp;        //Temperature setpoint
double _kp;          	 //This is PID kp set by user
double _ki;          	 //This is PID ki set by user
double _kd;          	 //This is PID Kd set by user
double _1FLmeas;       //This flow rate measured from sensor1
double _2FLmeas;       //This flow rate measured from sensor2
double _TEMPmeas;
double _PWRmeas;       //This is Power consumed by the system unit
double _1TANKmeas;     //This is water level in the upper tank
double _2TANKmeas; 	 //This is water level in the lower tank
}MPACKET;
void JSONpayload()
{
char PAYLOAD[250];
MPACKET data;
data._kp=41.1;
data._ki=23.1;
data._kd=10.1;
data._1FLOWsp=1.0;
data._2FLOWsp=1.2;
data._TEMPsp=36.3;
data._1FLmeas=0.9;
data._2FLmeas=1.8;
data._TEMPmeas=34.1;
data._1TANKmeas=12.1;
data._2TANKmeas=1.1;
data._PWRmeas=21.1;
sprintf(PAYLOAD,
		  "{\"KP\":%.1f,"		//KP
		  "\"KI\":%.1f,"		//KI
		  "\"KD\":%.1f,"		//KD
		  "\"FSP1\":%.1f,"		//Flow rate set-point
		  "\"FSP2\":%.1f,"		//Flow rate set-point
		  "\"TPSP\":%.1f,"		//Temp set-point
		  "\"FL1\":%.1f,"		//1 Flow rate measured
		  "\"FL2\":%.1f,"		//2 FLow rate measured
		  "\"TMP\":%.1f"		//Temperature measured
		  "\"UPT\":%.1f"		//1 Tank water level
		 // "\"DWT\":%.1f"		//2 Tank water level
		 // "\"PWR\":%.1f"		//Power consumed
		  "}\n"
		  ,data._kp
		  ,data._ki
		  ,data._kd
		  ,data._1FLOWsp
		  ,data._2FLOWsp
		  ,data._TEMPsp
		  ,data._1FLmeas
		  ,data._2FLmeas
		  ,data._TEMPmeas
		  ,data._1TANKmeas
		 // ,data._2TANKmeas
		 // ,data._PWRmeas
		  );
  	  UART0->STREAM(D_PORT, PAYLOAD);
}
/>
How can i package 12 variables (double) into JSON.