An affordable and open-source FPGA platform for the electronic control of microscope.
Currently, the laser pulse duration is in microseconds. In order to change the step size, refer to the laser_trigger.luc file of the firmware (line 40):
const NM_CYCLES = 100; // convert to ~us
Since the Alchitry FPGAs have an internal clock of frequency 100MHz, each clock cycle takes about 1/100 us. If we wanted to have a step size for the pulse duration of 100 ns, then line 40 becomes:
const NM_CYCLES = 10;
The firmware then needs to be compiled and updated on the FPGA.
Important note: If you increase NM_CYCLES
, you need to update the counter, to make sure that it can count more cycles than the maximum duration d times NM_CYCLES
: max(c)>d*NM_CYCLES
. By default the pulse duration is 16 bits, which means that the counter needs to go as high as (2^16-1)*NM_CYCLES
. For NM_CYCLES=1000
, the counter does not need to be changed, usually by increasing the number of bits by one. The number of bits need to be x > log2((2^16-1)*NM_COUNTER+1)
, which means larger than 26.
The laser pulse duration is encoded by a 16 bits value. The maximum value is therefore 65535 us pulse length by default. However, the register interface allows values up to 32 bits to be transferred. Therefore, the code can be easily modified to accommodate the whole bit depth, with a new maximum of 429’496’7295. If you follow the previous section with NM_CYCLES=1, this leads to a maximum pulse length of about 43 seconds.
In au_top.luc (line 116), change the bit depth to 32:
dff duration[NUM_LASERS][32];
In au_top.luc (line 180), change the bit depth to 32:
duration.d[reg.regOut.address-ADDR_DUR] = reg.regOut.data[31:0];
In laser_trigger.luc (line 28), change the bit depth to 32:
input dura[32],
In laser_trigger.luc (line 47), adjust the bit depth of counter (see previous section):
dff count_sig[x]; // x > log2((2^16-1)*NM_COUNTER+1
Now, the code on the user side should be changed to accept higher values, for instance:
Important note: the error code for MicroFPGA is defined in au_plus_top.luc (line 97):
const ERROR_UNKNOW_COMMAND = 11206655;
When changing any parameter from 16 bits to 32 bits, reading out the parameter value while it is equal to 11206655 will cause the Micro-Manager device adapter or the Java and Python libraries to produce an error. Indeed, this value will be interpreted as an wrong address request.