LEDs on RIGHT PWM will not turn off completely and RPI Not Submitting Commands

I am installing blue LEDs on our eVOLVER for optogenetic applications. To do this, I added a light variable to the conf.yml on the RPI and updated the Arduino handling a PWM in SA slot 8. I was able to get control from commands sent over the DPU; however, I am running into a problem someone described on here previously where the lights do not turn off with a zero sent.

Using the TLC test, I can turn off the entire RIGHT_PWM which will blink the array of LEDs, but cannot get individual LEDs to turn off. There are still a few differences in the coding of how the left vs the right PWM are handled beyond the pin assignments. It seems like this may be something that could be resolved through the software libraries but I have extremely limited knowledge of Arduino.

I did testing Friday and I believe I turned off the eVOLVER while server_test.py was going. After that, it started throwing errors and there seemed to be some difficulty in contacting the eVOLVER at the end of day. After returning today, I was not able to connect to the RPI through the electron shell or script. After trying to access by ssh it worked, and for whatever reason, conf.yml had the IP address noted as instead of Additionally, the formatting on the light variable was different. I updated the IP and connectivity to the DPU is restored, but I have not been able to get ANY commands working properly, whether scripted, sent through the desktop Electron GUI, or directly through the eVOLVER touchscreen.

I have attached the conf.yml in case there is something here. As you can see below, it is receiving the commands (I put some stir in at 15 and others at zero), but it is not acting on them. I reuploaded the relevant code for each Arduino to no avail.

acknowledge_char: a
broadcast_timing: 20
calibration: calibration.json
calibrations_directory: calibrations
data_response_char: b
device: evolver-config.json
echo_response_char: e
    fields_expected_incoming: 17 
    fields_expected_outgoing: 17
    recurring: false
    value: ['4095', '4095', '4095', '4095', '4095', '4095', '4095', '4095', '4095', '4095', '4095', '4095', '4095', '4095', '4095', '4095']
    fields_expected_incoming: 17
    fields_expected_outgoing: 17
    recurring: false
    value: ['4095', '4095', '4095', '4095', '4095', '4095', '4095', '4095', '4095', '4095', '4095', '4095', '4095', '4095', '4095', '4095']
  od_135: {fields_expected_incoming: 17, fields_expected_outgoing: 2, recurring: true,
    value: '1000'}
  od_90: {fields_expected_incoming: 17, fields_expected_outgoing: 2, recurring: true,
    value: '1000'}
    fields_expected_incoming: 17
    fields_expected_outgoing: 17
    recurring: true
    value: ['2500', '2500', '2500', '2500', '2500', '2500', '2500', '2500', '2500', '2500', '2500', '2500', '2500', '2500', '2500', '2500']
    fields_expected_incoming: 49
    fields_expected_outgoing: 49
    recurring: false
    value: ['2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2',
      '2', '2', --, --, --, --, --, --, --, --, --, --, --, --, --, --, --, --, --,
      --, --, --, --, --, --, --, --, --, --, --, --, --, --, --]
    fields_expected_incoming: 17
    fields_expected_outgoing: 17
    recurring: true
    value: ['15', '15', '15', '0', '15', '15', '15', '0', '15', '15', '15', '0', '0',
      '0', '0', '0']
    fields_expected_incoming: 17
    fields_expected_outgoing: 17
    recurring: true
    value: ['2200', '2192', '2191', '2194', '2184', '2183', '2182', '2188', '2202',
      '2187', '2195', '2199', '2202', '2193', '2190', '2200']
fitted_data_directory: fittedCal
immediate_command_char: i
num_sleeves: 16
od_calibration_directory: od
port: 8081
raw_data_directory: rawCal
recurring_command_char: r
serial_baudrate: 9600
serial_end_incoming: end
serial_end_outgoing: _!
serial_port: /dev/ttyAMA0
serial_timeout: 0.3
temp_calibration_directory: temp

The server log is just an endless stream of “restarting supervisord”

Update: some combination of moving light to be the last parameter and making the most recent updates on evolver_server.py (courtesy of zheins) restored proper response and function!

So that problem is resolved, there is still the problem of the LEDs not turning off all the way. For our current purposes, it should be fine to just have some with/without LEDs, but we hope to do more complex optogenetic work in the future that having LEDs we can fully shut off will be necessary for

I thought this was solved by this but I guess you are still have problems?

I had raised a related issue with the pin assignments on GitHub. I have tried with both sets of pin assignments and the problem remains, although the registers I updated to seem to have the flickers sparser and more in sync. The other part that differs between the right and left in this part of the code is in the end TLC5490.h line 88, noted below, but I do not have good enough knowledge of Arduinos to know what the reasoning is behind the OR gate or if this could resolve the issue. I do know from my searches some aspects of certain PWMs make turning off all the way difficult or impossible.


//Datasheet page 388
/** Enables the output of XLAT pulses */
#define enable_XLAT_pulses_1()      PORT->Group[g_APinDescription[3].ulPort].PINCFG[g_APinDescription[3].ulPin].bit.PMUXEN = 1; PORT->Group[g_APinDescription[4].ulPort].PMUX[g_APinDescription[4].ulPin >> 1].reg = PORT_PMUX_PMUXO_F; REG_TCC1_CC1 = 1; while (TCC1->SYNCBUSY.bit.CC1)
/** Disables the output of XLAT pulses */
#define disable_XLAT_pulses_1()   PORT->Group[g_APinDescription[3].ulPort].PINCFG[g_APinDescription[3].ulPin].bit.PMUXEN = 0; REG_TCC1_CC1 = 0; while (TCC1->SYNCBUSY.bit.CC1) 

//Datasheet page 388
/** Enable the GSCLK */
#define enable_GSCLK_1() PORT->Group[g_APinDescription[2].ulPort].PINCFG[g_APinDescription[2].ulPin].bit.PMUXEN = 1; PORT->Group[g_APinDescription[2].ulPort].PMUX[g_APinDescription[2].ulPin >> 1].reg = PORT_PMUX_PMUXE_F


//Datasheet page 388
/** Enables the output of XLAT pulses */
#define enable_XLAT_pulses_2()      PORT->Group[g_APinDescription[8].ulPort].PINCFG[g_APinDescription[8].ulPin].bit.PMUXEN = 1; PORT->Group[g_APinDescription[8].ulPort].PMUX[g_APinDescription[8].ulPin >> 1].reg = PORT_PMUX_PMUXE_E; REG_TCC1_CC1 = 1; while (TCC1->SYNCBUSY.bit.CC1) //These are a problem
/** Disables the output of XLAT pulses */
#define disable_XLAT_pulses_2()   PORT->Group[g_APinDescription[8].ulPort].PINCFG[g_APinDescription[8].ulPin].bit.PMUXEN = 0; REG_TCC1_CC1 = 0; while (TCC1->SYNCBUSY.bit.CC1) 

//Datasheet page 388
/** Enable the GSCLK */
#define enable_GSCLK_2() PORT->Group[g_APinDescription[7].ulPort].PINCFG[g_APinDescription[7].ulPin].bit.PMUXEN = 1; PORT->Group[g_APinDescription[6].ulPort].PMUX[g_APinDescription[6].ulPin >> 1].reg = !!!!PORT_PMUX_PMUXE_F | PORT_PMUX_PMUXO_F!!!!

@skumar Do you have any suggestions? Would really appreciate your advice here!

This is strange. Have you tried just the RIGHT_PWM (without initializing LEFT_PWM) to see if that works on the right slot pwm board? That way you can be sure of which register assignments are correct for the RIGHT PWM.

If I remember correctly from my debugging experience on this, the register assignments are correct now…there was an issue while disabling XLAT pulses together (left and right pwms) which was then resolved with this #17


Perhaps I am misunderstanding what you are asking me to try or am completely misunderstanding the nature of the Arduino/SA slot setup; there is no LEFT_PWM (unless that serves as a placeholder for the ADC board). In the code I have loaded to the Arduino handling the SA slots 7 and 8 which my LEDs are on, RIGHT_PWM is called in Tlc.init and Tlc.set while LEFT_PWM is not anywhere. While the dual PWM setup issues seem to be resolved, was there testing on the main eVOLVER motherboard with an ADC board on the left slot and this on the right?

I also know that LEFT_PWM will not work to control SA slot 8 because the TLC blink test I had done when originally installing only causes the LEDs to go on and off with RIGHT_PWM.

As an aside, zheins comment in the linked forum post also has me confused as to the nature of daisy-chaining in this framework as my understanding was that each Arduino on the motherboard was controlling two SA slots that were daisy-chained in the code?

If worse comes to worse, I can probably swap the positions of the PWM and ADC boards and just crimp, wire, and solder to get the photodiode and LEDs into the appropriate holes, but obviously, a solution that resolves this issue more broadly is preferred.

The PWM boards on the Motherboard are not daisy chained. Slot 7 and slot 8 are controlled independently. For example, below you see that the Arduino D2 - 6 and A1 are going from the Arduino to one SA slot whereas D7 -11 and A0 are going to the other SA slot.

The PWM boards in the fluidic box are daisy chained. You can see that the pins GSCLK, XLAT, and SCLK go from the Arduino to all the PWM boards. The commands are daisy chained by connecting the SOUT pin from the first PWM board (M1_SOUT) to the SIN pin of the second board.

Generally, this was designed this way because if you need to control more than 32 channels, you would need more arduinos, if you didn’t daisy chain. By daisy chaining, you can potentially daisy chain a bunch more boards (up to ~100 channels I think), though we only stop at 3 PWM boards.

One last note, be careful with the notation LEFT_PWM. LEFT would refer to slot 7 and RIGHT would refer to slot 8 in your case. It was named this way for legacy reasons but after the new enclosures they have become confusing.

1 Like

Thank you for the explanation and pin diagrams! And I have not run any LEFT_PWM commands for this on the current vial platform thankfully. My understanding is better but I am more confounded by what could be producing the issue; I’ll think on this to try and come up with some careful troubleshooting and get back to y’all, the guidance is very much appreciated!

Great news! I can control the blue LEDs through serial commands now, and there are no flickering issues! Big thanks to Brandon and skumar for their help throughout this process. I will link to a Notion detailing the installation/set-up process for our blue LEDs once I have compiled the necessary info.

After a week of exhaustive troubleshooting, the solution was frustratingly facile: Adding this code to the setup.

  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);

  digitalWrite(7, LOW);
  digitalWrite(8, LOW);
  digitalWrite(9, LOW);
  digitalWrite(10, LOW);

Seems that in addition to Tlc.init, when you are running a RIGHT_PWM off the eVOLVER motherboard, you also need to initialize the corresponding control pins in order to establish proper control.

You can find the entire Arduino sketch here.


Glad it works! There is probably a modification in the library you can make to initialize properly via Tlc.init? Probably in this section of code. Did you happen to try that?

1 Like

I did not. I am pretty unfamiliar with coding in C++, but would the idea here be to make different logic gates for pwm_val? To verify, RIGHT_PWM gets converted to 2 through this line in Tlc5490.h?

If this understanding is correct, I would just need to have if statements for pwm_val being one or two I believe?