ATtiny45 pulseIn

Hi,
I am trying to to read the pulses from a receiver for a remote control car with a Attiny45 using the 8MHz internal oscillator I've successfully read the pulses with my UNO; however, when i try to read the pulses with the attiny it wont register any pulses lower than about 1500 (1.5ms). Is 8MHz to slow to catch the shorter pulses or could it be some other issue? Im using the high low tech core for the attiny45.

int rc = 5;
int sp = 0;
int g = 7;
int b = 6;

void setup(){

pinMode(rc,INPUT);
pinMode(b,OUTPUT);
pinMode(g,OUTPUT);
}

void loop(){

sp = pulseIn(rc,HIGH);

if( sp >1550){//forward
digitalWrite(g,LOW);

if (sp <1400){//reverse
digitalWrite(b,LOW);

}

else{
digitalWrite(g,HIGH);
digitalWrite(b,HIGH);
}
}
}

Are you certain the processor is running at 8 MHz?

Does this core work correctly...
http://code.google.com/p/arduino-tiny/

As far as I recall, I've yet to have any issues receiving iR remote signals using ATTiny85 (similar, just more RAM) at 8MHz using the arduino-tiny core linked in the previous post.

Below is the output from my Attiny85 @ 8MHZ, connected to a rc receiver
Pulses from 1101 - 1923 as expected.

This also shows how convenient it is to use Coding Badly's TinyISP. You can get debuginformation in serial monitor, just like you are used to from the Arduino

1104
1117
1101
1167
1306
1395
1453
1458
1511
1661
1808
1923
1920
1923
1779
1511
1511
1524
1511
1506
1524
1514
1511

I tried to install the cores that coding badly posted however I believe i'm missing something in the installation because i cant even get the attiny to blink an led now.

And the following folder should contain the Arduino-Tiny core...

C:\Projects\Arduino\hardware\tiny\cores\tiny\

  • Open the "boards.txt" file and change both of the "upload.using" entries to
    the appropriate value for your setup. Following from the examples above, the
    file would be here...

C:\Projects\Arduino\hardware\tiny\boards.txt

what dose it want me to put in place of the "upload.using" in the bord.txt file?

Thank you everyone for your help.

Below is my boards.txt for attiny45
As you can see I have uncommented this option
attiny45at1.upload.using=arduino:arduinoisp
Because I use ArduinoISP

attiny45at8.name=ATtiny45 @ 8 MHz

# The following do NOT work...
# attiny45at8.upload.using=avrispv2
# attiny45at8.upload.using=Pololu USB AVR Programmer

# The following DO work (pick one)...
attiny45at8.upload.using=arduino:arduinoisp
# attiny45at8.upload.protocol=avrispv2
# attiny45at8.upload.using=pololu

attiny45at8.upload.maximum_size=4096

# Default clock (slowly rising power; long delay to clock; 8 MHz internal)
# Int. RC Osc. 8 MHz; Start-up time PWRDWN/RESET: 6 CK/14 CK + 64 ms; [CKSEL=0010 SUT=10]; default value
# Brown-out detection disabled; [BODLEVEL=111]
# Preserve EEPROM memory through the Chip Erase cycle; [EESAVE=0]

attiny45at8.bootloader.low_fuses=0xE2
attiny45at8.bootloader.high_fuses=0xD7
attiny45at8.bootloader.extended_fuses=0xFF
attiny45at8.bootloader.path=empty
attiny45at8.bootloader.file=empty45at8.hex

attiny45at8.build.mcu=attiny45
attiny45at8.build.f_cpu=8000000L
attiny45at8.build.core=tiny
 
###########################################################################

attiny45at1.name=ATtiny45 @ 1 MHz

# The following do NOT work...
# attiny45at1.upload.using=avrispv2
# attiny45at1.upload.using=Pololu USB AVR Programmer

# The following DO work (pick one)...
attiny45at1.upload.using=arduino:arduinoisp
# attiny45at1.upload.protocol=avrispv2
# attiny45at1.upload.using=pololu

attiny45at1.upload.maximum_size=4096

# Default clock (slowly rising power; long delay to clock; 8 MHz internal; divide clock by 8)
# Int. RC Osc. 8 MHz; Start-up time PWRDWN/RESET: 6 CK/14 CK + 64 ms; [CKSEL=0010 SUT=10]; default value
# Divide clock by 8 internally; [CKDIV8=0]
# Brown-out detection disabled; [BODLEVEL=111]
# Preserve EEPROM memory through the Chip Erase cycle; [EESAVE=0]

attiny45at1.bootloader.low_fuses=0x62
attiny45at1.bootloader.high_fuses=0xD7
attiny45at1.bootloader.extended_fuses=0xFF
attiny45at1.bootloader.path=empty
attiny45at1.bootloader.file=empty45at1.hex

attiny45at1.build.mcu=attiny45
attiny45at1.build.f_cpu=1000000L
attiny45at1.build.core=tiny
 
###########################################################################

Those lines are un-commented in mine as well but it still dosen't work. :frowning:

but it still dosen't work

Which error do you get?

Try to follow these steps

http://www.ernstc.dk/arduino/attiny85.html

Iam not getting any errors it uploads to the chip without any errors but i cant even get a simple sketch like blinking an led to work on it. Im pretty sure i have the core instillation wrong. I put the tiny and tolls folder into the hardware folder an that's really it from the read me instructions i sounds like i have to do something else but i find the instructions vauge.

I have re-installed the high low tech cores and am back to where i started. i can get it to read pulses above about 1500 but not lower. Is there any way it could be something rather than the core? Im trying to get it to work on my attiny44 8Mhz but have the same result. could the pin im using to read the rc signal be the problem?

Ok not really sure why the other code didn't work but i got it to work with the below code all i did diffrent was set the other pin high (for testing i used a common anode RGB led). thanks everyone that tired to help.

int rc = 5;
int sp = 0;
int g = 7;
int b = 6;



void setup(){

  pinMode(rc,INPUT);
  pinMode(b,OUTPUT);
  pinMode(g,OUTPUT);
}

void loop(){

  sp = pulseIn(rc,HIGH);


  if (sp <1400&& sp >500){//reverse
      digitalWrite(b,LOW);
      digitalWrite(g,HIGH);
      delay(10);

    }
    
    
    if( sp >1500){//forward
      digitalWrite(g,LOW);
      digitalWrite(b,HIGH);
      delay(10);
    }
    
    else{//neutral and failsafe
    digitalWrite(b,HIGH);
    digitalWrite(g,HIGH);
    }
    
  }

bd611 - You did "burn" the 8mhz bootloader to your chip first? right?

yes i did.

Hi, I notice you're using D5 (leg 1) for the RC input. That is also the reset pin, with active low. Might be worth moving that to another leg.

Geoff