danielcomcom

FlexsQ5 Dump Load Controller

Dec 6th, 2021
1,145
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. //Dumpload Levels 11.1kw, 11.1kw, 6.6kw, 3.3kw, 1920w respectivly
  3. let levels = [];
  4. levels[0] = [0,0,0,0,0];
  5. levels[1] = [0,0,0,0,1];
  6. levels[2] = [0,0,0,1,0];
  7. levels[3] = [0,0,0,1,1];
  8. levels[4] = [0,0,1,1,0];
  9. levels[5] = [0,0,1,1,1];
  10. levels[6] = [0,1,0,0,0];
  11. levels[7] = [0,1,0,0,1];
  12. levels[8] = [0,1,0,1,0];
  13. levels[9] = [0,1,0,1,1];
  14. levels[10] = [0,1,1,1,0];
  15. levels[11] = [0,1,1,1,1];
  16. levels[12] = [1,1,0,0,0];
  17. levels[13] = [1,1,0,0,1];
  18. levels[14] = [1,1,0,1,0];
  19. levels[15] = [1,1,0,1,1];
  20. levels[16] = [1,1,1,1,0];
  21. levels[17] = [1,1,1,1,1];
  22.  
  23.  
  24.  
  25. //Set relay's based on the dump level
  26. function setDumpLoad(level){
  27.  
  28.   setRelay(1,levels[level][1]); //11kw
  29.   setRelay(2,levels[level][0]); //11kw
  30.   setRelay(3,levels[level][2]); //6600W
  31.   setRelay(4,levels[level][3]); //3300W
  32.   setRelay(5,levels[level][4]); //1920W
  33.  
  34. }
  35.  
  36.  
  37. while(run()){
  38.  
  39.     //Get AC Power info for all 3 phases
  40.     let L1 = powermetrics(0);
  41.     let L2 = powermetrics(1);
  42.     let L3 = powermetrics(2);
  43.  
  44.   //if frequency is above 59 Hz and we aren't at the highest dump level
  45.   if(L1.freq > 59 && getFeed(0) < 17){
  46.     let newDumpLevel = getFeed(0) + 1; //Get new dump level
  47.     setFeed(0, newDumpLevel); //Update dump level
  48.     setDumpLoad(newDumpLevel); //Update relays
  49.     print('+1 Dump Level, new level:', newDumpLevel);//Log Dump level change
  50.   }
  51.    
  52.   //if frequency is below 57 Hz and we aren't at the lowest dump level
  53.   if(L1.freq < 57 && getFeed(0) > 0 && L1.freq !== 0){
  54.     let newDumpLevel = getFeed(0) - 1;  //Get new dump level
  55.     setFeed(0, newDumpLevel); //Update dump level
  56.     setDumpLoad(newDumpLevel); //Update relays
  57.     print('-1 Dump Level, new level:', newDumpLevel);//Log Dump level change
  58.   }
  59.  
  60.     //Over Voltage shutdown
  61.     if(L1.frequency > 65){ //Shut down the system if over 75Hz
  62.       print('Over speed shutdown:', L1.freq);//Log Dump level change
  63.       setRelay(8,0);  
  64.     }
  65.  
  66.  
  67.  
  68.     //Set custom feed with total power usage  
  69.     setFeed(2,L1.realpower + L2.realpower + L3.realpower);
  70.  
  71.  
  72.  
  73.   waitMS(500); // wait 500ms
  74. }
RAW Paste Data