Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
firmware code for LED control
#1
Hi Josh,

Regarding the Port interface: I wanted to run our emitter through the LED port so that I can control the sensitivity of our photogate (we don't need LED's since we're using video monitors).

I need to initialize the LED at startup in the firmware, it looks like the code will relate to the PWM, however there are two locations for this, one is pwmWrite (which looks like it may control the Bpod status LED) and the other relates to the SPI, which I recall from our previous communications relates to ethernet communication. 

My guess is that you initialize the emitter in the startup to always be on, and I'd like to do that for the LED port (then use the potentiometer to adjust sensativity.)

I saw in a previous thread that the emitter is on Ethernet jack 4, LED on jack 3.

Question 1: Is the emitter initialized at startup to always be on. If so then in the setup I could just swap the emitter line for the LED line and it would turn the LED port on at startup.

Question 2:, if (1) isn't true, then do you have any suggestions for coding this in the firmware?

If you have any concerns with doing this let me know.

Thanks!
Reply
#2
(08-12-2018, 02:21 AM)Travis Wrote: Hi Josh,

Regarding the Port interface: I wanted to run our emitter through the LED port so that I can control the sensitivity of our photogate (we don't need LED's since we're using video monitors).

I need to initialize the LED at startup in the firmware, it looks like the code will relate to the PWM, however there are two locations for this, one is pwmWrite (which looks like it may control the Bpod status LED) and the other relates to the SPI, which I recall from our previous communications relates to ethernet communication. 

My guess is that you initialize the emitter in the startup to always be on, and I'd like to do that for the LED port (then use the potentiometer to adjust sensativity.)

I saw in a previous thread that the emitter is on Ethernet jack 4, LED on jack 3.

Question 1: Is the emitter initialized at startup to always be on. If so then in the setup I could just swap the emitter line for the LED line and it would turn the LED port on at startup.

Question 2:, if (1) isn't true, then do you have any suggestions for coding this in the firmware?

If you have any concerns with doing this let me know.

Thanks!

I think I found it!!! In the main firmware code:

// Configure digital output channels
  for (int i = 0; i < nOutputs; i++) {
    switch (OutputHW[i]) {
      case 'D':
      case 'B':
      case 'W':
      case 'V':
        pinMode(OutputCh[i], OUTPUT);
        digitalWrite(OutputCh[i], LOW);
      break;
      case 'P':
        pinMode(OutputCh[i], OUTPUT);
        analogWrite(OutputCh[i], XXX);

Where XXX is the starting point for the LED lights!, I changed it to 255 and it turned them all on, and I can adjust them with the potentiometer, woo hoo!

T
Reply
#3
Hi Travis,

The IR emitter is tied to the port interface's 5V power line, so it's always on - not due to anything we initialize in software.
I haven't tried powering the IR emitter from the PWM line. Please keep in mind that it's a 3.3V line. A 10-ohm resistor in series with the port interface board's blue potentiometer limits the current through the white LED to a safe level - but the same current may not be safe for an IR emitter. I'd tune the visible light to low brightness (or even off), then swap in the IR emitter and use the low end of the potentiometer range.

You can probably avoid hacking the firmware by setting the line to be on at your desired PWM, in the output actions section of every state of your state matrix. When the trial starts, the emitter will turn on, and stay on until the inter-trial interval.

If you do mod the firmware and you're using state machine r0.5-1.0 (Arduino Due), please make sure to mod the text file controlling PWM frequency of your Arduino board, as indicated in comments at the top of the firmware file.

Please let us know if this works!
Cheers,
-Josh
Reply


Forum Jump: