Pages: 1 ... 6 7 [8] 9 10 ... 14   Go Down
Author Topic: SoftwareSerial with ATTiny84 using ATtiny library  (Read 47129 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 3
Posts: 188
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Is that the on between reset and ground?

Yes.

Quote
I did that and no change, still get the error:
Code:
--- 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.
Logged

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

Denmark
Offline Offline
Edison Member
*
Karma: 35
Posts: 1073
Happy Hobbyist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.



« Last Edit: January 19, 2013, 02:13:32 pm by Erni » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley-wink

Kind Regards
Logged

Offline Offline
Full Member
***
Karma: 3
Posts: 188
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


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.
Logged

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

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 208
Posts: 12932
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


Build options now go in the _TinyISP_BuildOptions.h 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.
Logged

Offline Offline
Full Member
***
Karma: 3
Posts: 188
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

sketch:
Code:
#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:
ÿ //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:
#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:
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 ---

Logged

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

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 208
Posts: 12932
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
ÿ //this shows up without me typing "!"

I often get a bit of garbage as well.  I haven't bothered to track down why.
« Last Edit: February 25, 2013, 10:48:10 pm by Coding Badly » Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 208
Posts: 12932
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Full Member
***
Karma: 3
Posts: 188
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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.
Logged

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

Denmark
Offline Offline
Edison Member
*
Karma: 35
Posts: 1073
Happy Hobbyist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

« Last Edit: February 26, 2013, 06:35:54 am by Erni » Logged

Offline Offline
Full Member
***
Karma: 3
Posts: 188
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley-sad

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 smiley I am trying to document it for the UNO as I go here: http://hellowoo.com/hardware/serial-monitor-with-attiny85-and-arduino/
« Last Edit: February 26, 2013, 09:24:25 am by hilukasz » Logged

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

Denmark
Offline Offline
Edison Member
*
Karma: 35
Posts: 1073
Happy Hobbyist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Code:
CapacitiveSensor cs_4_2 = CapacitiveSensor(1,0);   

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

Code:
CapacitiveSensor cs_4_2 = CapacitiveSensor(1,0);   


Logged

Offline Offline
Full Member
***
Karma: 3
Posts: 188
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Code:
CapacitiveSensor cs_4_2 = CapacitiveSensor(1,0);   

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

Code:
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.
« Last Edit: February 26, 2013, 09:36:33 pm by hilukasz » Logged

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

Denmark
Offline Offline
Edison Member
*
Karma: 35
Posts: 1073
Happy Hobbyist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Ohh, my copy/paste technique was bad.

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

Code:
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.
Logged

Offline Offline
Full Member
***
Karma: 3
Posts: 188
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Ohh, my copy/paste technique was bad.

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

Code:
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
« Last Edit: February 27, 2013, 07:39:28 pm by hilukasz » Logged

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

Pages: 1 ... 6 7 [8] 9 10 ... 14   Go Up
Jump to: