Changeset 10969 for fact/FADctrl


Ignore:
Timestamp:
06/10/11 08:23:22 (13 years ago)
Author:
neise
Message:
support for Firmware Version 0200
Location:
fact/FADctrl
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • fact/FADctrl/FAD.cc

    r10913 r10969  
    3232   {"roi", &FAD::cmd_roi, true, 2, "<range> <value>", "Set ROI to for channel range to value"},
    3333   {"dac", &FAD::cmd_dac, true, 2, "<range> <value>", "Set DAC numbers in range to value"},
     34   {"execute", &FAD::cmd_execute, true, 0, "", "confirm FAD configuration settings, e.g. DAC, ROI, run#"},
    3435   {"address", &FAD::cmd_address, true, 2, "<range> <value>", "Set addresses in range to value"},
    3536   {"send", &FAD::cmd_send, true, 1, "<value>", "Send arbitrary data to board"},
     
    205206
    206207//
     208// Execute: Confirm new ROI, DAC or what ever settings
     209//
     210
     211void FAD::cmd_execute() {
     212
     213  for (unsigned int i=0; i<Boards.size(); i++) Boards[i]->Send(CMD_Execute);
     214}
     215
     216
     217//
    207218// Set run number
    208219//
    209220void FAD::cmd_runnumber() {
    210 
     221       
     222        unsigned short Buffer[4] = {0};
    211223  int Num;
    212224
     
    215227        return;
    216228  }
     229        Buffer[0] = htons(CMD_Write | ADDR_RUNNUMBER);
     230        Buffer[1] = htons( (unsigned short)( ((unsigned int)Num) >> 16 ) );
     231        Buffer[2] = htons(CMD_Write | (ADDR_RUNNUMBER + 1) );
     232        Buffer[3] = htons( (unsigned short)Num );
    217233
    218234  for (unsigned int i=0; i<Boards.size(); i++) {
    219         Boards[i]->Send(CMD_Write | ADDR_RUNNUMBER );
    220         Boards[i]->Send((unsigned short) (Num>>16));            // Write the HIGH-word first
    221         Boards[i]->Send(CMD_Write | (ADDR_RUNNUMBER+1) );
    222         Boards[i]->Send((unsigned short) Num); // now write the LOW-word
     235        Boards[i]->Send(Buffer, sizeof(Buffer));
     236        Boards[i]->Send(CMD_Execute);
    223237  }
    224238}
     
    351365  for (unsigned int i=0; i<Boards.size(); i++) {
    352366        Boards[i]->Send(Buffer, sizeof(Buffer));
     367        Boards[i]->Send(CMD_Execute);
    353368  }
    354369}
     
    380395  }
    381396
    382   // Disable triggers for all boards and wait (workaround for firmware bug) 
    383   for (unsigned int i=0; i<Boards.size(); i++) Boards[i]->Send(CMD_TRIGGERS_OFF);
    384   usleep(500000);
    385397
    386398  // Send command buffer and enable triggers again
    387399  for (unsigned int i=0; i<Boards.size(); i++) {
    388         Boards[i]->Send(Buffer, sizeof(Buffer));
    389         Boards[i]->Send(CMD_TRIGGERS_ON);
    390   }
     400        Boards[i]->Send(Buffer+R.Min*2, (R.Max-R.Min+1)*2*sizeof(unsigned short));
     401        Boards[i]->Send(CMD_Execute);
     402  }
     403
     404       
    391405}
    392406
  • fact/FADctrl/FAD.h

    r10757 r10969  
    7171        void cmd_trigger();             void cmd_socketmode();
    7272        void cmd_runnumber();   void cmd_reset();
     73        void cmd_execute();
    7374        void cmd_srclk();               void cmd_sclk();
    7475        void cmd_dwrite();              void cmd_domino();
  • fact/FADctrl/FADBoard.cc

    r10813 r10969  
    168168
    169169  vector<unsigned short> ROICmd;
    170   unsigned short DACCmd[] = {htons(CMD_Write | (BADDR_DAC + 1)), 0, htons(CMD_Write | (BADDR_DAC + 2)), 0, htons(CMD_Write | (BADDR_DAC + 3)), 0};
     170  unsigned short DACCmd[] = {htons(CMD_Write | (BADDR_DAC + 1)), 0, htons(CMD_Write | (BADDR_DAC + 2)), 0, htons(CMD_Write | (BADDR_DAC + 3)), 0, htons(CMD_Execute) };
    171171  string Message = string("ACALIBDONE")+Name+"\n";
    172172
     
    183183        InitialStatus = GetStatus();
    184184
    185         Send(CMD_TRIGGERS_OFF);
    186         usleep(500000);
    187 
    188185        for (unsigned int i=0; i<NChips*NChannels; i++) {
    189186          ROICmd.push_back(htons(CMD_Write | (BADDR_ROI + i)));
    190187          ROICmd.push_back(htons(NBins));
    191188        }
     189        ROICmd.push_back(htons(CMD_Execute));
    192190        Send(&ROICmd[0], ROICmd.size()*sizeof(unsigned short));
    193191
    194     DACCmd[1] = htons(0);
    195     DACCmd[3] = htons(0);
    196     DACCmd[5] = htons(0);
     192        DACCmd[1] = htons(0);
     193        DACCmd[3] = htons(0);
     194        DACCmd[5] = htons(0);
    197195        Send(DACCmd, sizeof(DACCmd));
    198 
    199         Send(CMD_TRIGGERS_ON);
    200196
    201197        // Clear sum vector and set state to accumulate
     
    335331  case cleanup:
    336332    // ROI values
    337         Send(CMD_TRIGGERS_OFF);
    338         usleep(100000);
    339333
    340334        ROICmd.clear();
     
    343337          ROICmd.push_back(htons(InitialStatus.ROI[i/NChannels][i%NChannels]));
    344338        }
     339        ROICmd.push_back(htons(CMD_Execute));
    345340        Send(&ROICmd[0], ROICmd.size()*sizeof(unsigned short));
    346341
    347         Send(CMD_TRIGGERS_ON);
    348 
    349342        // DAC values
    350     DACCmd[1] = htons(InitialStatus.DAC[1]);
    351     DACCmd[3] = htons(InitialStatus.DAC[2]);
    352     DACCmd[5] = htons(InitialStatus.DAC[3]);
     343        DACCmd[1] = htons(InitialStatus.DAC[1]);
     344        DACCmd[3] = htons(InitialStatus.DAC[2]);
     345        DACCmd[5] = htons(InitialStatus.DAC[3]);
    353346        Send(DACCmd, sizeof(DACCmd));
    354347       
  • fact/FADctrl/FADFormat.h

    r10504 r10969  
    2727#define CMD_Trigger_C 0xB000    // continous trigger
    2828#define CMD_Trigger_S 0x2000    // stop continous trigger
     29
     30#define CMD_Execute 0x0400              // only after 'execute' Config-RAM changes will have an effect
     31#define CMD_Write 0x0500                // write to Config-RAM
    2932#define CMD_Read 0x0A00                 // read from Config-RAM
    30 #define CMD_Write 0x0500                // write to Config-RAM
    3133#define CMD_RESET_TRIGGER_ID 0x2A00
    3234
Note: See TracChangeset for help on using the changeset viewer.