Modifying c# code that controls NucleoBoard that controls detector used in spectrometer

I’m trying to work my way through some code for a project from long ago that controls the readout from a detector used in a spectrometer. I think success for the project is likely around the corner if I can set the number of readings taken to several hundred or thousand as opposed to the one reading that I’m able to take now. Here is github link. I can program… to some extent… but I’m not a coder so expect some eyebrow raises and some glaring gaps in my coding knowledge to expose themselves.

The short of it is:
Push ‘Read’ Button --> ??? --> Write to file

It’s in the “???” part where I want to add a for loop over the number of readings set by the user and an array that sums the intensity values for each reading from each of the ~3600 pixels of the detector.

The “Read” button is in Spectrometer > Form1.Designer.cs
The Write to file is in the Spectrometer > fileio.cs (I figured this one out all by myself)

So, could someone please tell me

  1. Where to add my for loop and array?
  2. Where to add the variable for the number of readings taken?

Please no kitchen sink syndrome - the goal right now for this project is simply to demonstrate this spectrometer can pick up on the type of optical signal we’re after.

If you want to run the program, that’s Spectrometer > bin > Debug > Raman.exe
The interface looks like this:
Frame

Here’s a pretty… pretty unfocused… rainbow behind where the detector will go:

And here’s some data with a laser shot straight at the detector:

1 Like

Ok. This is a bit of a stab in the dark…

FileIO.cs has a function/method??? that looks like this…

    private void btnRead_Click(object sender, EventArgs e)
    {
        string rdStr, parseStr;
        btnRead.Enabled = false;
        
        _FrmTerminal_.readReg("r", out rdStr);
        parseStr = Re.RepRegex("\t", rdStr, ",");
        parseStr = Re.RepRegex("\r\r", parseStr, "\r");
        FileIO.WriteAll(parseStr, "raw_"+ DateTime.Now.Ticks +".csv");
        fillChart(rdStr);
        btnRead.Enabled = true;
    }

I would guess the rdStr variable contains the raw data that you would average. And I would throw a dart and guess the FrmTerminal line is the command that initiates the hardware to make a measurement.

I’d give myself about a 10% chance of pointing you in the correct direction.

You’ve helped point me in the right direction! Looking at the code a little closer this morning I’ve found what I’m looking for in the Form1.cs file. Had it been a rattlesnake I’d have been bit.

    private void btnRead_Click(object sender, EventArgs e)
    {
        string rdStr, parseStr;
        btnRead.Enabled = false;
        
        _FrmTerminal_.readReg("r", out rdStr);
        parseStr = Re.RepRegex("\t", rdStr, ",");
        parseStr = Re.RepRegex("\r\r", parseStr, "\r");
        FileIO.WriteAll(parseStr, "raw_"+ DateTime.Now.Ticks +".csv");
        fillChart(rdStr);
        btnRead.Enabled = true;
    }
1 Like