Go Down

Topic: SoftwareSerial with ATTiny84 using ATtiny library (Read 53603 times) previous topic - next topic

hilukasz


Is that the on between reset and ground?


Yes.

Quote
I did that and no change, still get the error:
Code: [Select]

--- 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?



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.
for(i = 0, i < 820480075, i++){ Design(); Code(); delay(1000); } // hellowoo.com

Erni

#106
Jan 19, 2013, 08:05 pm Last Edit: Jan 19, 2013, 08:13 pm by Erni Reason: 1
Quote
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.




laughlinez

For those using TinyISP with ATTinyx4 etc (specifically i use 84A_PU) and TinyDebugSerial at <=8Mhz

I found that on a new vanilla install (for windows 7 64) of Arduino IDE 1.0.3 (downloaded today 8/feb/2013) you should change the
define for the debug register and bit (see 2 lines below 'Use MISO as TX').

#elif defined( __AVR_ATtinyX4__ )

  #if F_CPU <= 8000000L
    // port B bit 0 (PB0)
    //#define TINY_DEBUG_SERIAL_REGISTER    0x18  <<<<original settings
    //#define TINY_DEBUG_SERIAL_BIT         0           <<<original settings
//use MISO as TX back to host, i.e Port A 5 (PA5)
    #define TINY_DEBUG_SERIAL_REGISTER    0x1B
    #define TINY_DEBUG_SERIAL_BIT         5
  #else
    // port A bit 0 (PA0)
    #define TINY_DEBUG_SERIAL_REGISTER    0x1B
    #define TINY_DEBUG_SERIAL_BIT         0
  #endif

I am very new to all this (1 week in) so I hope the above is helpful, please reply if this info is erroneous and I'll correct.

PS: Thx very much for TinyISP, makes using 84/85's almost pleasurable ;)

Kind Regards

hilukasz



Sorry about that.  Try it now.


did that file get revered maybe? I formatted and had to download it again and that file seems to be missing again.
for(i = 0, i < 820480075, i++){ Design(); Code(); delay(1000); } // hellowoo.com

Coding Badly


Build options now go in the[font=Courier New] _TinyISP_BuildOptions.h [/font]file.  It should be the last tab if you have the sketch loaded in the Arduino IDE.

Other than the copyright notice, I will never put anything in that file.  It's sole purpose is for you to specify build-time settings.

hilukasz

ah, must have ended up messing with that one instead last time. wrote it down this time :)

Ok the basic examples seem to work fine, for most part..

sketch:
Code: [Select]
#define KNOCK_BANG 1
#include <TinyDebugKnockBang.h>

#ifdef KNOCK_BANG
#define Serial Debug
#endif
int a;
void setup() {
   Serial.begin( 9600 );
       a = 1;
}

void loop() {
   delay(1000);
   Serial.println("hello world"); // debug output
   Serial.println(a); // debug output
   a++;
}



this is the output, though for some reason I always have to send "!" twice for it to work:
Code: [Select]
ÿ //this shows up without me typing "!"
--- Monitor starting ---

--- Knock-Bang fault: 11 ---
hello world
6
hello world
7
hello world
8
hello world
9


ok great, now I try a more complex one and everything falls apart. for some reason it is storing program from last upload...? I do stop the serial monitor before uploading, not sure if that matters.

the sketch:
Code: [Select]
#include <CapacitiveSensor.h>
#include <RunningMedian.h>
#define KNOCK_BANG 1
#include <TinyDebugKnockBang.h>
#ifdef KNOCK_BANG
#define Serial Debug
#endif

CapacitiveSensor cs_4_2 = CapacitiveSensor(1,0);        // 10 megohm resistor between pins 1 & 0, pin 0 is sensor pin, add wire, foil
const int sampleAmount = 5;
long runningAverage[sampleAmount];
boolean toggleLED;
int var;
   
boolean handIsPresent;    
void setup(){
  Serial.begin(9600);
  cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF);     // turn off autocalibrate on channel 1 - just as an example
  pinMode(2, OUTPUT);
  pinMode(1, OUTPUT);
  pinMode(0, INPUT);
  var = 0;
  handIsPresent = false;  
}
void loop(){
  //findCurrentHighestAverage
  checkIfHandIsPresent();
  if(handIsPresent){
    toggleTheLED();
  }
  delay(10);
  Serial.print("test");
}

void toggleTheLED(){
      if(toggleLED == 0){
        digitalWrite(2, LOW);
        toggleLED = 1;
        //delay(2000);
        return;
      } else if(toggleLED == 1) {
         digitalWrite(2, HIGH);
         toggleLED = 0;
         //delay(2000);
      }
}

////////////////
// Check if hand is present
//--------------

int lastReading;

void checkIfHandIsPresent(){
 const int threshold = 300;
 int currentReading = getAverage();

 Serial.print(currentReading-lastReading);
 Serial.print("\n");
 // this will always only read when
 if((currentReading-lastReading) > threshold){
   handIsPresent = true;
 } else { handIsPresent = false; }
 lastReading = currentReading;
}

////////////////
// get average reading out of X samples
//--------------
int getAverage() {
  int tempAverage = 0;
  int capacitiveAverage = 0;
  for(int i = 0; i < sampleAmount; i++){
   runningAverage[i] = cs_4_2.capacitiveSensor(30);
  }
  // add all the samples up
  for(int i = 0; i < sampleAmount; i++){
    tempAverage = runningAverage[i] + tempAverage;
  }
  // divide by number of samples to get average
  capacitiveAverage =  tempAverage/sampleAmount;
  //printSampleData(capacitiveAverage);
  return capacitiveAverage;
}


Code: [Select]
73
hello world
74
hello world
75
hello world
76
hello world
77
hello world
78
hello world
79

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

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

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

--- Knock-Bang fault: 4 ---

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

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

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

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

73
hello world
74
hello world
75
hello world
76
hello world
77
hello world
78
hello worl
--- Knock-Bang fault: 11 ---

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

--- Knock-Bang fault: 4 ---

for(i = 0, i < 820480075, i++){ Design(); Code(); delay(1000); } // hellowoo.com

Coding Badly

#111
Feb 26, 2013, 04:45 am Last Edit: Feb 26, 2013, 04:48 am by Coding Badly Reason: 1
Quote
this is the output, though for some reason I always have to send "!" twice for it to work:


I've had that happen a few times but typically the transition is smooth.  I can't explain why you always have to send bang twice.

Code: [Select]
ÿ //this shows up without me typing "!"

I often get a bit of garbage as well.  I haven't bothered to track down why.

Coding Badly

ok great, now I try a more complex one and everything falls apart. for some reason it is storing program from last upload...?


Any upload errors?

Quote
I do stop the serial monitor before uploading, not sure if that matters.


Shouldn't matter.  The TinyISP sketch is coded to jump to the ISP part automatically.

hilukasz


ok great, now I try a more complex one and everything falls apart. for some reason it is storing program from last upload...?


Any upload errors?

Quote
I do stop the serial monitor before uploading, not sure if that matters.


Shouldn't matter.  The TinyISP sketch is coded to jump to the ISP part automatically.



just the standard:

Code: [Select]
Binary sketch size: 3,044 bytes (of a 8,192 byte maximum)
avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85
avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85


get this with all attiny uploads though.
for(i = 0, i < 820480075, i++){ Design(); Code(); delay(1000); } // hellowoo.com

Erni

#114
Feb 26, 2013, 12:34 pm Last Edit: Feb 26, 2013, 12:35 pm by Erni Reason: 1
hilukasz
One thing to try:
Ensure that the MISO connection wire is as short (and fat) as possible:

http://arduino.cc/forum/index.php/topic,123388.msg1029246.html#msg1029246
(reply #74)

Quote
avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85
avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85


This is jusr a warning, just ignore it.


hilukasz

#115
Feb 26, 2013, 03:01 pm Last Edit: Feb 26, 2013, 03:24 pm by hilukasz Reason: 1

hilukasz
One thing to try:
Ensure that the MISO connection wire is as short (and fat) as possible:

http://arduino.cc/forum/index.php/topic,123388.msg1029246.html#msg1029246
(reply #74)

Quote
avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85
avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85


This is jusr a warning, just ignore it.




thanks for suggestion. However, one I have now is very short and as large gauge as will fit in the pins :(

I'm wondering if it is something in my code conflicting with this type of serial read? It's strange that a simple example would work, and not my more complex one.

also as I am learning to get all this right (hopefully eventually :) I am trying to document it for the UNO as I go here: http://hellowoo.com/hardware/serial-monitor-with-attiny85-and-arduino/
for(i = 0, i < 820480075, i++){ Design(); Code(); delay(1000); } // hellowoo.com

Erni

Hmm, you are using the MOSI and MISO lines (0 and 1) as you sense pins.

Code: [Select]
CapacitiveSensor cs_4_2 = CapacitiveSensor(1,0);   

Try this instead, works for me (I think, atleast I don't get knock bang errors)

Code: [Select]
CapacitiveSensor cs_4_2 = CapacitiveSensor(1,0);   



hilukasz

#117
Feb 27, 2013, 02:10 am Last Edit: Feb 27, 2013, 03:36 am by hilukasz Reason: 1

Hmm, you are using the MOSI and MISO lines (0 and 1) as you sense pins.

Code: [Select]
CapacitiveSensor cs_4_2 = CapacitiveSensor(1,0);   

Try this instead, works for me (I think, atleast I don't get knock bang errors)

Code: [Select]
CapacitiveSensor cs_4_2 = CapacitiveSensor(1,0);   





oh doh! is it this line: #define KNOCK_BANG 1 because that was new on this round of sketches. I thought default was pin 3 (PCB3)? What weirds me out is this works on the first sketch I show above...? I can read the serial fine via pin 3, but its second sketch that fails.

I did try some tests to change it to #define KNOCK_BANG 3 and it seems like the same problem.
for(i = 0, i < 820480075, i++){ Design(); Code(); delay(1000); } // hellowoo.com

Erni

Ohh, my copy/paste technique was bad.

What I really meant was; Try moving the sense pins to PB3 and PB4.

Code: [Select]
CapacitiveSensor cs_4_2 = CapacitiveSensor(PB3,PB4);   

If you are using 0 and 1 you are interferring with MISO, which is used by KnockBang, and gives the weird results and errors.

I tried your sketch wirth this change and the output is OK.

hilukasz

#119
Feb 28, 2013, 12:59 am Last Edit: Feb 28, 2013, 01:39 am by hilukasz Reason: 1

Ohh, my copy/paste technique was bad.

What I really meant was; Try moving the sense pins to PB3 and PB4.

Code: [Select]
CapacitiveSensor cs_4_2 = CapacitiveSensor(PB3,PB4);   

If you are using 0 and 1 you are interferring with MISO, which is used by KnockBang, and gives the weird results and errors.

I tried your sketch wirth this change and the output is OK.


I don't understand how it uses both. Eventually I will need those pins is possible to change it over to a different pin? (possibly just one...?)

and if I use your setup, I don't get what pin is the serial pin either. I always thought pin 2 was the send pin.

Also, this is REALLY confusing me now. When I unplug the serial read pin, it seems to be still reading serial... This is even with the basic example I posted above. it's usually plugged into pin 1 of the arduino board, but I break the connection all together and it still is printing to serial monitor.

I am keeping all the connections connected because its on a prototype board that sits on top of the arduino, not sure if that will matter. Its basically this board http://www.instructables.com/id/ATtiny-Programming-Shield-for-Arduino-1/ but with addition of a jumper going from Tx (pin1) on arduino to pin3 (PB2) on attiny
for(i = 0, i < 820480075, i++){ Design(); Code(); delay(1000); } // hellowoo.com

Go Up