SoftwareSerial with ATTiny84 using ATtiny library

Erni:
One thing I've noticed about this core is the timing of the delay function is unaccurate, and especially at the frequencies where KnockBang gives error messages ... I do not know how or if this affects KnockBang

Excellent observation. If delay is wrong because the F_CPU value is wrong than Knock-Bang would most definitely not function correctly. Please post your boards.txt file with the other entries (or ensure the F_CPU entries are correct).

I would like to help with your KnockBang...

Including 128 KHz, which clock speed is your highest priority?

Other than 128 KHz, which clock speed is your highest priority?

If delay is wrong because the F_CPU value is wrong than Knock-Bang would most definitely not function correctly

Oh yes of course, I had only made corrections to the fuses and forgot the f_cpu value. Sigh now i feel stupid

So now KnockBang works on Attiny13, whit clockspeeds 9.6 4.8 1.2 and 0.6 mHz.

Below is the correct boards.txt.

To summarize using smeezekitty's core13 with Coding Badly's KnockBang:

Core13:

  1. Delete line (#55) from TinyDebugKnockBang.h

  2. In the Wprogram.h add these lines (in the coe13 libary):

class __FlashStringHelper;
#define F(string_literal) (reinterpret_cast<const __FlashStringHelper *>(PSTR(string_literal)))
#include <avr/pgmspace.h>
#include "print.h"
  1. When changing fuses (burn bootloader):
    Use this changed TinyISP
    GitHub - Coding-Badly/TinyISP: ArduinoISP replacement with: Tiny Debug Knock Bang, Monitor, Tiny Tuner 2, and other amenities

  2. Use a short and thick wire as MISO, and maybe use pullup resistor

attiny13int.name=Attiny13 @ 128 KHz (internal watchdog oscillator - no KnockBang)
attiny13int.upload.using=arduino:arduinoisp
attiny13int.bootloader.low_fuses=0x33
attiny13int.bootloader.high_fuses=0xFF
attiny13int.upload.maximum_size=1024
attiny13int.build.mcu=attiny13
attiny13int.build.f_cpu=128000
attiny13int.build.core=core13

###########################################################################

attiny13at4d.name=ATtiny13 @ 4.8MHz (internal 4.8 MHz clock/8)
attiny13at4d.upload.using=arduino:arduinoisp
attiny13at4d.bootloader.low_fuses=0x69
attiny13at4d.bootloader.high_fuses=0xff
attiny13at4d.upload.maximum_size=1024
attiny13at4d.build.mcu=attiny13
attiny13at4d.build.f_cpu=600000
attiny13at4d.build.core=core13
###########################################################################

attiny13at4.name=ATtiny13 @ 4.8MHz (internal 4.8 MHz clock)
attiny13at4.upload.using=arduino:arduinoisp
attiny13at4.bootloader.low_fuses=0x79
attiny13at4.bootloader.high_fuses=0xff
attiny13at4.upload.maximum_size=1024
attiny13at4.build.mcu=attiny13
attiny13at4.build.f_cpu=4800000
attiny13at4.build.core=core13
###########################################################################


attiny13at9dm.name=ATtiny13 @ 9.6 Mhz/div8
attiny13at9dm.bootloader.low_fuses=0x66
attiny13at9dm.bootloader.high_fuses=0xff
attiny13at9dm.upload.maximum_size=1024
attiny13at9dm.build.mcu=attiny13
attiny13at9dm.build.f_cpu=1200000
attiny13at9dm.build.core=core13

###########################################################################

attiny13at9m.name=ATtiny13 @ 9.6 Mhz
attiny13at9m.bootloader.low_fuses=0x7A
attiny13at9m.bootloader.high_fuses=0xff
attiny13at9m.upload.maximum_size=1024
attiny13at9m.build.mcu=attiny13
attiny13at9m.build.f_cpu=9600000
attiny13at9m.build.core=core13

########################################################################

Erni:
Sigh now i feel stupid

Why? Were you born knowing how to modify boards.txt? If not (and we both know you were not) you are not even close to "stupid".

You made a mistake. We all do. To be "stupid" you would have to refuse to acknowledge your mistake then correct it. Clearly that is not the case.

So now KnockBang works on Attiny13, whit clockspeeds 9.6 4.8 1.2 and 0.6 MHz.

Excellent!

(Except for 0.6 MHz. I'm surprised that works. As the clock speed is reduced below 1 MHz, the protocol becomes less reliable. At 0.5 MHz it should fail.)

(Except for 0.6 MHz. I'm surprised that works. As the clock speed is reduced below 1 MHz, the protocol becomes less reliable. At 0.5 MHz it should fail.)

Now I have done some more testing at 600 kHz and it is indeed unreliable.

I had a sketch running for more than 40 minutes whitout any errors,
other tests only 4-5 lines before I got a KnockBang error, and most tests between those.

Erni:
Now I have done some more testing at 600 kHz and it is indeed unreliable.

Do you have a need for Knock-Bang to work at clock speeds below 1 MHz?

I had a sketch running for more than 40 minutes whitout any errors,

Excellent!

Do you have a need for Knock-Bang to work at clock speeds below 1 MHz?

No, I was just curious to see if it worked.

this seems like a really awesome project and exactly what I am looking for. however the sketch doesn't seem to want to compile. I get this error:

In file included from KnockBangReceiver.cpp:36:
TinyISP_SelectBuildOptions.h:175:2: error: #error

I'm on an Uno and IDE v1.0.1. I think it might have to do with TinyISP_BuildOptions.h, that doesn't seem to be in the files included.i did find TinyISP_SelectBuildOptions.h and that seemed right, however settings in there already matched what you said to change.

any suggestions?

Sorry about that. Try it now.

daywalkerdha:

[quote author=Coding Badly link=topic=123388.msg929989#msg929989 date=1348162209]

daywalkerdha:
Not sure how this is supposed to work without power...

It won't.

That's what they taught me in EE :wink:
[/quote]

It might ... if one of the I/O pins is connected to a voltage source.

OTOH this is a good way to destroy chips, don't try it at home.

ahh, there we go! perfect. thank you.

I seem to be missing something. Maybe I don't fully understand what knock-bang is. Was assuming this was a simple "hello world" type message that you can test this one, could be wrong.

I have selected attiny85 at 8mhz as board and it upload fine and I can even add "!" into debugger and I get "--- Monitor starting ---" but it seems nothing is coming out. Also have 19200 baud set, no line ending. I uploaded the sketch you showed earlier:

#include <TinyDebugKnockBang.h>

void setup( void )
{
  Debug.begin( 250000 );
}

void loop( void )
{
  Debug.println( F( "Caitlin! " ) );
  delay( 1000 );
}

But I am not getting anything in the monitor aside from initiated message. On arduino its connected to Tx (though it seems like it would be Rx but all other monitors I have set up use Rx for some reason) and PB3 on the attiny (with 220ohm resistor between). Might be missing something though?

hilukasz:
I seem to be missing something.

You are. Documentation. Work keeps getting in the way.

Try this...

• With the TinyISP sketch loaded in the Arduino IDE, switch to the _TinyISP_BuildOptions.h tab # (sadly, it ended up the last tab)

• Add this line below the Put build options here comment...

#define RELAY_KNOCK_BANG_ENABLED 1

• Upload the modified sketch (don't forget to remove the auto-reset disable capacitor)

# Or, with the Arduino IDE not running use an external editor to modify the file.

• Upload the modified sketch (don't forget to remove the auto-reset disable capacitor)

Is that the on between reset and ground? I did that and no change, still get the error:

--- Knock-Bang fault: 11 ---

--- Knock-Bang fault: 11 ---

hilukasz:
Is that the on between reset and ground?

Yes.

I did that and no change, still get the error:

--- Knock-Bang fault: 11 ---

--- Knock-Bang fault: 11 ---

No change? Earlier you reported that nothing was being output to the Serial Monitor. Were error messages being output?

definitely a change, it now says --- Knock-Bang fault: 11 --- instead of nothing. Of course I should clarify, it did indicate the monitor was starting and stopping.

Edit: trimmed the unnecessary quote.

The receive errors are listed here...

The one of interest is...
fault_timeout_knock = 0x11

The receiver (your Uno) is expecting a low pulse of a certain duration (a "knock"). The pulse is too short to be a knock.

The problem could be caused by the target running at 1 MHz with code built for a processor running at 8 MHz. Which "board" do you have selected? Have you used "burn bootloader" to change the fuses?

The problem could be caused by the target running at 1 MHz with code built for a processor running at 8 MHz.

If it is of any help, I just tried a Attiny85 running at 1MHZ and selected board Attiny85 @ 8MHZ and got:

--- Knock-Bang fault: 11 ---

With the same target and selcting board Attiny85 @ 1MHZ it works as expected (Output to the serial monitor looks as it should)

Erni:

The problem could be caused by the target running at 1 MHz with code built for a processor running at 8 MHz.

If it is of any help, I just tried a Attiny85 running at 1MHZ and selected board Attiny85 @ 8MHZ and got:

--- Knock-Bang fault: 11 ---

With the same target and selcting board Attiny85 @ 1MHZ it works as expected (Output to the serial monitor looks as it should)

yeah, I just did this too. It makes sense since the frequency is 8 times faster, would make the signal shorter. I was under impression serial monitor needed to be 8Mhz like normal, but this seems to run differently.

It works perfect now! thanks guys.

I have it in still and it seems to be working fine. should I leave it? I honestly don't know what it does. I was under impression it just resets arduino so that it can program the attiny, but what that really means I have no idea.

I have it in still and it seems to be working fine. should I leave it?

As long as you use your Arduino as programmer, the capacitor between reset and ground should be connected.
It is there tp prevent your Arduino to reset and then starting the bootloader, instead of talking to the ArduinoISP.