Need sugestion for Transistor and power regulator for attiny85

Hi.

I'm building a laptimer for RC Cars and I'm using attiny85 on transponder and raspberry pi 3 as receiter/main computer (with and IR receiver).

Now I'm using and 'standard' IR emitter on TX, but isn't enought, so I need to use a powerfull model. I'm looking for 3W and 5W on ebay to test......but how to power it?
I'm using MMBT2222A as transistor (SOT-23), but it supports 'only' 600mA and this new IR led need at least 700mA, so isn't enought.

For power, I'm using AMS1117 5v (powe input is from 5v to 14v) to attiny85 + LED, but I think isn't enought too.....so I need sugestion for both: power regulator and transistor to drive 1A LED (5W / 1A).

I'll drive this transistor directly using attiny85 IO and must be smallest one (transponder must be very small).

Tks!

jmaurin:
I'm building a laptimer for RC Cars and I'm using attiny85 on transponder and raspberry pi 3 as receiter/main computer (with and IR receiver).

Now I'm using and 'standard' IR emitter on TX, but isn't enought, so I need to use a powerfull model. I'm

Maybe you should try narrow beam (<10 degrees) 5mm IR LEDs.
Two in series (vertical array) with a >=68ohm current limiting resistor should be more powerful (light) than a 3watt wide-beam IR LED.
One narrow-beam, with a >=100ohm resistor might already be enough (>= 5meters).

Are you using receivers made for beam-break, e.g. the TSSP4038 (not the TSOPxxxx).
Leo..

I'm using these for TX: TSUS 5202 Vishay IR LED 5mm 950nm, 150ma 30°

For current limiting, I'm using 33R with 5v power suply, which gives me about 115mA (this led supports 150mA acordingh to datasheet).

For receiving, I'm using TSOP31238. As code-base, I'm using this: GitHub - polyvision/EasyRaceLapTimer

But I'm writting receiver code from scratch. The TX code is 'original' from here (not modified): EasyRaceLapTimer/Arduino/TransmitterAttiny85v0.3 at master · polyvision/EasyRaceLapTimer · GitHub

But i'm re-writting receiver code from scratch (using C). The TX/RX is working fine, I can receiver fone inside my house. The problem is in the sun.....nothing seens to work. I'm using receiver faced down (the same way of sun) and the sender (Tx) against the sun (face up).....but is not looking good :frowning:

A 7-degree IR LED theoretically throws about 18x more light on the sensor than a 30-degree LED.
Disadvantage is that you have to line up the LED a bit more accurate.

Did you experiment with the transmit frequency.
38kHz might not be 38kHz on an ATtiny.

I use the transmit code below on an Uno/Nano.
Leo..

const byte IR_LEDpin = 11; // IR transmitter LED with 100ohm (minimum) CL resistor

void setup() {
  pinMode (IR_LEDpin, OUTPUT);
  TCCR2A = _BV (COM2A0) | _BV(WGM21);
  TCCR2B = _BV (CS20);
  OCR2A =  209; // ~209 = ~38kHz | ~219 = ~36kHz
}

void loop() {
}

I just realised you're not making a beam-break sensor,
but a flying remote control that triggers a receiver that's hidden behind a vane.
If so, then you need a wide-angle transmit LED or several LEDs to cover a wider angle.
You might learn something from the TV-B-Gone kit from Adafruit (Google it).
Leo..

Wawa:
A 7-degree IR LED theoretically throws about 18x more light on the sensor than a 30-degree LED.
Disadvantage is that you have to line up the LED a bit more accurate.

Did you experiment with the transmit frequency.
38kHz might not be 38kHz on an ATtiny.

I use the transmit code below on an Uno/Nano.
Leo..

const byte IR_LEDpin = 11; // IR transmitter LED with 100ohm (minimum) CL resistor

void setup() {
 pinMode (IR_LEDpin, OUTPUT);
 TCCR2A = _BV (COM2A0) | _BV(WGM21);
 TCCR2B = _BV (CS20);
 OCR2A =  209; // ~209 = ~38kHz | ~219 = ~36kHz
}

void loop() {
}

I'm not sure about frequency, I'm just a 'basic developer' when we talk about arduino. Anyway, this is the code that I'm using (it's from easyracelaptimer project). I'm not sure if is right or not, but it works inside house and not at sun.

About IR Led, do you have any sugestions that I can buy from AliExpress or Ebay? I found one (that I don't know if works): TSTS7100. But I can't find in Ali and the only sellers that I found in Ebay doesn't send to Brazil :frowning: Here I don't even need to say......we can't find anything! :confused:

Tks for your tips/help Wawa.

/**
   EasyRaceLapTimer - Copyright 2015-2016 by airbirds.de, a project of polyvision UG (haftungsbeschränkt)

   Author: Alexander B. Bierbrauer

   This file is part of EasyRaceLapTimer.

   Vresion: 0.3.1

   EasyRaceLapTimer is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
   EasyRaceLapTimer is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
   You should have received a copy of the GNU General Public License along with Foobar. If not, see http://www.gnu.org/licenses/.
 **/
// use 8MHZ internal clock of the Attiny
// Timer code from http://forum.arduino.cc/index.php?topic=139729.0
#include <EEPROM.h>

#define BIT_SET(a,b) ((a) |= (1<<(b)))
#define BIT_CLEAR(a,b) ((a) &= ~(1<<(b)))
#define BIT_FLIP(a,b) ((a) ^= (1<<(b)))
#define BIT_CHECK(a,b) ((a) & (1<<(b)))

// CHANGE HERE THE ID OF TRANSPONDER
// possible values are 1 to 63
#define TRANSPONDER_ID 1

// DEFINITIONS FOR TRANSPONDERS WITH PUSH BUTTON CONFIGURATION
#define CLEAR_EEPROM
#define ENABLE_BUTTON_CONFIGURATION
#define BUTTON_PIN PB2
#define STATUS_LED_PIN PB0
#define BUTTON_INC_ID_PUSH_TIME 750
#define LED_BLINK_CONFIRM_TIME 750
#define ENABLE_PROGRAMMING_MODE_TIME 8000 // 8 seconds

// DO NOT CHANGE ANYTHING BELOW
#define NUM_BITS  9
#define ZERO  300
#define ONE   700
#define STARTB 150

unsigned int buffer[NUM_BITS];
unsigned int num_one_pulses = 0;
unsigned int transponder_id = TRANSPONDER_ID;
unsigned long buttonPushTime = 0;
int buttonState = 0;
unsigned long ledBlinkStartTime = 0;

void EEPROMWriteInt(int p_address, int p_value);
unsigned int EEPROMReadInt(int p_address);

void encodeIdToBuffer() {
  num_one_pulses = 0;
  buffer[0] = STARTB;
  buffer[1] = STARTB;
  buffer[2] = get_pulse_width_for_buffer(5);
  buffer[3] = get_pulse_width_for_buffer(4);
  buffer[4] = get_pulse_width_for_buffer(3);
  buffer[5] = get_pulse_width_for_buffer(2);
  buffer[6] = get_pulse_width_for_buffer(1);
  buffer[7] = get_pulse_width_for_buffer(0);
  buffer[8] = control_bit();
}

void readConfigButtonState() {
  if (ledBlinkStartTime != 0) {
    return;
  }

  int state = digitalRead(BUTTON_PIN);
  if (state == LOW) {
    if (state != buttonState) {
      buttonState = state;
      buttonPushTime = millis();
    }
  } else {
    buttonPushTime = millis();
  }

  buttonState = state;

  if (buttonPushTime + BUTTON_INC_ID_PUSH_TIME <= millis()) {
    transponder_id++;
    if (transponder_id >= 63) {
      transponder_id = TRANSPONDER_ID;
    }
    EEPROMWriteInt(0, transponder_id);
    ir_pulse_off();
    cli();
    buttonState = HIGH; // RESET
    buttonPushTime = millis(); // RESET
    ledBlinkStartTime = millis(); // Enable confirmation LED
    digitalWrite(STATUS_LED_PIN, HIGH);
    encodeIdToBuffer();
    sei();

    delay(200);
    flashTransponderId();

  }
}


void updateConfirmationLed() {
  if (ledBlinkStartTime != 0 && ledBlinkStartTime + LED_BLINK_CONFIRM_TIME <= millis()) {
    digitalWrite(STATUS_LED_PIN, LOW);
    ledBlinkStartTime = 0;
  }

}

unsigned int get_pulse_width_for_buffer(int bit) {
  if (BIT_CHECK(transponder_id, bit)) {
    num_one_pulses++;
    return ONE;
  }

  return ZERO;
}

unsigned int control_bit() {
  if (num_one_pulses % 2 >= 1) {
    return ONE;
  } else {
    return ZERO;
  }
}

void setup()
{
  PORTB = 0;
#ifdef CLEAR_EEPROM
  for (int i = 0 ; i < EEPROM.length() ; i++) {
    EEPROM.write(i, 0);
  }
#endif

#ifdef ENABLE_BUTTON_CONFIGURATION
  transponder_id = EEPROMReadInt(0);
  if (transponder_id == 0) {
    transponder_id = 1;
    EEPROMWriteInt(0, transponder_id);
  }

  // put your setup code here, to run once:
  pinMode(STATUS_LED_PIN, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(BUTTON_PIN, INPUT_PULLUP);
  PORTB |= (1 << BUTTON_PIN);    // enable pull-up resistor

  flashTransponderId();

#endif


  pinMode(PB1, OUTPUT);
  //DDRB =  0b00000010;    // set PB1 (= OCR1A) to be an output

  setFrequency(38000); // 38 kHz

  encodeIdToBuffer();
}

// Set the frequency that we will get on pin OCR1A but don't turn it on
void setFrequency(uint16_t freq)
{
  uint32_t requiredDivisor = (F_CPU / 2) / (uint32_t)freq;

  uint16_t prescalerVal = 1;
  uint8_t prescalerBits = 1;
  while ((requiredDivisor + prescalerVal / 2) / prescalerVal > 256)
  {
    ++prescalerBits;
    prescalerVal <<= 1;
  }

  uint8_t top = ((requiredDivisor + (prescalerVal / 2)) / prescalerVal) - 1;
  TCCR1 = (1 << CTC1) | prescalerBits;
  GTCCR = 0;
  OCR1C = top;
}

// Turn the frequency on
void ir_pulse_on()
{
  TCNT1 = 0;
  TCCR1 |= (1 << COM1A0);
}

// Turn the frequency off and turn off the IR LED.
// We let the counter continue running, we just turn off the OCR1A pin.
void ir_pulse_off()
{
  TCCR1 &= ~(1 << COM1A0);
}

void loop() {
  for (int i = 0; i < 3; i++) {
    for (int b = 0; b < NUM_BITS; b++) {
      switch (b) {
        case 0:
          ir_pulse_on();
          delayMicroseconds(buffer[b]);
          break;
        case 1:
          ir_pulse_off();
          delayMicroseconds(buffer[b]);
          break;
        case 2:
          ir_pulse_on();
          delayMicroseconds(buffer[b]);
          break;
        case 3:
          ir_pulse_off();
          delayMicroseconds(buffer[b]);
          break;
        case 4:
          ir_pulse_on();
          delayMicroseconds(buffer[b]);
          break;
        case 5:
          ir_pulse_off();
          delayMicroseconds(buffer[b]);
          break;
        case 6:
          ir_pulse_on();
          delayMicroseconds(buffer[b]);
          break;
        case 7:
          ir_pulse_off();
          delayMicroseconds(buffer[b]);
          break;
        case 8:
          ir_pulse_on();
          delayMicroseconds(buffer[b]);
          break;
      }
      ir_pulse_off();
    } // going through the buffer

    delay(20 + random(0, 5));
  } // 3 times

  // Temporary
  //flashTransponderId();

#ifdef ENABLE_BUTTON_CONFIGURATION
  readConfigButtonState();
  updateConfirmationLed();
#endif
} // end of main loop


void flashTransponderId() {
  int fn = abs(transponder_id); //better way to find first digit of trasnponder_id
  while (fn >= 10)
    fn /= 10;

  //Display Transponder ID in two sets of LED Flashes
  for (int i = 0; i < fn; i++) { //Display MSB
    digitalWrite(STATUS_LED_PIN, HIGH);
    delay(400);
    digitalWrite(STATUS_LED_PIN, LOW);
    delay(400);
  }

  if (transponder_id > 9) {
    //Display a single LED Flash to seperate the bits (helps distinguish ID 1 and ID 10)
    delay(1000);
    //digitalWrite(STATUS_LED_PIN, HIGH);
    //delay(50);
    //digitalWrite(STATUS_LED_PIN, LOW);
    delay(1000);

    for (int i = 0; i < transponder_id % 10; i++) { //Display LSB
      digitalWrite(STATUS_LED_PIN, HIGH);
      delay(400);
      digitalWrite(STATUS_LED_PIN, LOW);
      delay(400);
    }
  }
}

My idea is to replicate this: LapMonitor Personal and Multi-User RC Lap counter / RC Lap timing System

But insted of putting onde receiver led on the side of road, I'm planing to put 3 at top of road (in a pole or something like that).