Trying to create a simple O'scope with UNO

HI! I was following this tutorial
I did that successfully. Now I want to use it on a attiny85.
When I compiled the code for attiny85, It gave me this error
Clock=8MHz
CODE:

// Firmware to capture 2-channels of data and send it out over BlueTooth.
// This implementation is designed to provide data to the Windows Phone 8
// Application
//
// Software is distributed under the MIT License, see ArduinoFirmware_License.txt
// for more details.

// This library provides a frame structure
// for the data.
#include <minsegbus.h>
MinSegBus mbus; 

// The SoftwareSerial library is used to provide
// data to the Bluetooth module.
#include <SoftwareSerial.h>
SoftwareSerial BTSerial(10, 11); // RX | TX


#define maxbuffer     0x0400
#define ADCChannels   0x0002

//storage variables
boolean toggle0 = 0;

// Define the ADC
int analogPinCh1 = 0;
int analogPinCh2 = 1;
bool bOutput;

// Buffers
unsigned short iUnsignedShortArray[ADCChannels*2];
unsigned char cBuff[maxbuffer];

// MinSegBus vaiiables
unsigned char iAddress;
unsigned short iUnsignedShort;
unsigned int iBytesReturned;
unsigned int iErrorCount;
unsigned int iIdx;



void setup()
{
  // Serial port setup
  //Serial.begin(115200);
  BTSerial.begin(115200);

  // Definitions for the MinSegBus
  iAddress = 0x000;
  
  // Tattle tale pins, used to confirm timing
  pinMode(9, OUTPUT);
  
  // Get two samples before sending the frame
  bOutput = false;
  
  // Timer setup.  Begin by disabling the interrupts
  // Reference:  http://www.instructables.com/id/Arduino-Timer-Interrupts/?ALLSTEPS
  
  cli();
  
  // Timer control registers
  TCCR0A = 0;   // Set entire TCCR0A register to 0
  TCCR0B = 0;   // Same for TCCR0B
  // Set compare match register for 625Hz increment
  OCR0A = 99;  // = (16*10^6) / (500*256) - 1 (must be < 256)
  // Turn on the CTC mode
  TCCR0A |= (1 << WGM01);
  // Set CS01 and CS00 bits for 256 prescaler
  TCCR0B |= (1 << CS02 );
  // Enable the timer compare interrupt
  TIMSK0 |= ( 1 << OCIE0A );
  
  // enable interrupts
  sei();
}

//  All the work is done in the timer interrupt service routine (ISR)
void loop()
{
    return;
}

// Timer0 interrupt 1kHz.  This also toggles pin 31
// to provide a method to veriy the sampling frequency.
ISR(TIMER0_COMPA_vect){
  
  if (toggle0)
  {
    digitalWrite(9,HIGH);
    toggle0 = 0;
  }
  else
  {
    digitalWrite(9,LOW);
    toggle0 = 1;
  }

  if( bOutput)
  {
    iUnsignedShortArray[2] = analogRead(analogPinCh1);
    iUnsignedShortArray[3] = analogRead(analogPinCh2);
    iBytesReturned = 0;
    iAddress++;
    mbus.ToByteArray(iAddress, iUnsignedShortArray, ADCChannels*2, maxbuffer, &cBuff[0], &iBytesReturned);
    bOutput = false;
  }
  else
  {
    iUnsignedShortArray[0] = analogRead(analogPinCh1);
    iUnsignedShortArray[1] = analogRead(analogPinCh2);
    bOutput = true;
    for (iIdx = 0; iIdx<iBytesReturned; iIdx++)
    {
      // Uncomment this line to write to the serial port. Useful
      // only for debugging
      //Serial.write(cBuff[iIdx]);
      BTSerial.write(cBuff[iIdx]);
    }
  }

}

Error

Arduino: 1.6.5 (Windows XP), Board: "ATtiny, ATtiny85, 8 MHz (internal)"

Using library MinSegBus in folder: C:\Documents and Settings\Administrator\My Documents\Arduino\libraries\MinSegBus (legacy)

Using library SoftwareSerial in folder: C:\Documents and Settings\Administrator\My Documents\Arduino\libraries\SoftwareSerial (legacy)



C:\Program Files\arduino-1.6.5-r5\hardware\tools\avr/bin/avr-g++ -c -g -Os -Wall -Wextra -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=attiny85 -DF_CPU=8000000L -DARDUINO=10605 -DARDUINO_attiny -DARDUINO_ARCH_AVR -IC:\Program Files\arduino-1.6.5-r5\hardware\arduino\avr\cores\arduino -IC:\Documents and Settings\Administrator\My Documents\Arduino\hardware\attiny\avr\variants\tiny8 -IC:\Documents and Settings\Administrator\My Documents\Arduino\libraries\MinSegBus -IC:\Documents and Settings\Administrator\My Documents\Arduino\libraries\SoftwareSerial C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\build61903387065297718.tmp\ArduinoFirmware.cpp -o C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\build61903387065297718.tmp\ArduinoFirmware.cpp.o 

In file included from C:\Program Files\arduino-1.6.5-r5\hardware\arduino\avr\cores\arduino/Stream.h:26:0,
                 from C:\Program Files\arduino-1.6.5-r5\hardware\arduino\avr\cores\arduino/HardwareSerial.h:29,
                 from C:\Program Files\arduino-1.6.5-r5\hardware\arduino\avr\cores\arduino/Arduino.h:224,
                 from ArduinoFirmware.ino:11:
C:\Program Files\arduino-1.6.5-r5\hardware\arduino\avr\cores\arduino/Print.h:32:0: warning: "BIN" redefined [enabled by default]
 #define BIN 2
 ^
In file included from c:\program files\arduino-1.6.5-r5\hardware\tools\avr\avr\include\avr\iotn85.h:38:0,
                 from c:\program files\arduino-1.6.5-r5\hardware\tools\avr\avr\include\avr\io.h:428,
                 from c:\program files\arduino-1.6.5-r5\hardware\tools\avr\avr\include\avr\pgmspace.h:88,
                 from C:\Program Files\arduino-1.6.5-r5\hardware\arduino\avr\cores\arduino/Arduino.h:28,
                 from ArduinoFirmware.ino:11:
c:\program files\arduino-1.6.5-r5\hardware\tools\avr\avr\include\avr\iotnx5.h:55:0: note: this is the location of the previous definition
 #define BIN     7
 ^
ArduinoFirmware.ino: In function 'void setup()':
ArduinoFirmware.ino:73:3: error: 'TIMSK0' was not declared in this scope
Multiple libraries were found for "SoftwareSerial.h"

 Used: C:\Documents and Settings\Administrator\My Documents\Arduino\libraries\SoftwareSerial

 Not used: C:\Program Files\arduino-1.6.5-r5\hardware\arduino\avr\libraries\SoftwareSerial

'TIMSK0' was not declared in this scope

Let me know whats wrong.
P.S. I checked the attiny 85 datasheet, It has the TIMSK register.
The required library is attached

MinSegBus.zip (5.9 KB)

Bit 0 (TIMSK0) is not available on ATtiny. What do you want to achieve with it in setup()?

I don't know. I am not the author of this code. I just copied it from instructables. Can you shed some light?

As the layout of the TIMSK register depends on the processor, the use of TIMSK0-TIMSK7 is not a good idea, with 0-7 meaning bit numbers. Instead the bit names should be used. Which Arduino is normally used with the library?

E.g. the Uno board has an ATmega328 controller, where bit 0 of TIMSK is named TOIE0. Try that name instead of TIMSK0 and report.

Here is the new error after replacing the TIMSK0 with TOIE0

Arduino: 1.6.5 (Windows XP), Board: "ATtiny, ATtiny85, 8 MHz (internal)"

Build options changed, rebuilding all

In file included from C:\Program Files\arduino-1.6.5-r5\hardware\arduino\avr\cores\arduino/Stream.h:26:0,
                 from C:\Program Files\arduino-1.6.5-r5\hardware\arduino\avr\cores\arduino/HardwareSerial.h:29,
                 from C:\Program Files\arduino-1.6.5-r5\hardware\arduino\avr\cores\arduino/Arduino.h:224,
                 from ArduinoFirmwareFort85.ino:11:
C:\Program Files\arduino-1.6.5-r5\hardware\arduino\avr\cores\arduino/Print.h:32:0: warning: "BIN" redefined [enabled by default]
 #define BIN 2
 ^
In file included from c:\program files\arduino-1.6.5-r5\hardware\tools\avr\avr\include\avr\iotn85.h:38:0,
                 from c:\program files\arduino-1.6.5-r5\hardware\tools\avr\avr\include\avr\io.h:428,
                 from c:\program files\arduino-1.6.5-r5\hardware\tools\avr\avr\include\avr\pgmspace.h:88,
                 from C:\Program Files\arduino-1.6.5-r5\hardware\arduino\avr\cores\arduino/Arduino.h:28,
                 from ArduinoFirmwareFort85.ino:11:
c:\program files\arduino-1.6.5-r5\hardware\tools\avr\avr\include\avr\iotnx5.h:55:0: note: this is the location of the previous definition
 #define BIN     7
 ^
ArduinoFirmwareFort85.ino: In function 'void setup()':
ArduinoFirmwareFort85:73: error: lvalue required as left operand of assignment
Multiple libraries were found for "SoftwareSerial.h"

 Used: C:\Documents and Settings\Administrator\My Documents\Arduino\libraries\SoftwareSerial

 Not used: C:\Program Files\arduino-1.6.5-r5\hardware\arduino\avr\libraries\SoftwareSerial

lvalue required as left operand of assignment

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.

Sorry for the wrong language :frowning:

The BIN thing seems to be a bug in the libraries. With print() it's used for the output formatting, in io...h it should have a different name.

What's the purpose of the SoftwareSerial library in your Documents folder? If it should not be used then remove it, else rename it.

When you care of "Show verbose output", the error messages would be more informative.

Hi,
As you will see in the tutorial the sketch is for a UNO, not an attiny.
There are significant differences between the two in internal registers.

You are asking to much of a smaller controller to do.

If you want to make a stand alone scope, then UNO is the way to go, it has the TLL/RS232/USB interface and the speed to do a good job with bluetooth and an phone.

Tom..... :slight_smile:

DrDiettrich:
Sorry for the wrong language :frowning:

The BIN thing seems to be a bug in the libraries. With print() it's used for the output formatting, in io...h it should have a different name.

What's the purpose of the SoftwareSerial library in your Documents folder? If it should not be used then remove it, else rename it.

When you care of "Show verbose output", the error messages would be more informative.

Here is the verbose output.

Arduino: 1.6.5 (Windows XP), Board: "ATtiny, ATtiny85, 8 MHz (internal)"

Using library MinSegBus in folder: C:\Documents and Settings\Administrator\My Documents\Arduino\libraries\MinSegBus (legacy)

Using library SoftwareSerial in folder: C:\Documents and Settings\Administrator\My Documents\Arduino\libraries\SoftwareSerial (legacy)



C:\Program Files\arduino-1.6.5-r5\hardware\tools\avr/bin/avr-g++ -c -g -Os -Wall -Wextra -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=attiny85 -DF_CPU=8000000L -DARDUINO=10605 -DARDUINO_attiny -DARDUINO_ARCH_AVR -IC:\Program Files\arduino-1.6.5-r5\hardware\arduino\avr\cores\arduino -IC:\Documents and Settings\Administrator\My Documents\Arduino\hardware\attiny\avr\variants\tiny8 -IC:\Documents and Settings\Administrator\My Documents\Arduino\libraries\MinSegBus -IC:\Documents and Settings\Administrator\My Documents\Arduino\libraries\SoftwareSerial C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\build3497198973938971977.tmp\ArduinoFirmwareFort85.cpp -o C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\build3497198973938971977.tmp\ArduinoFirmwareFort85.cpp.o 

In file included from C:\Program Files\arduino-1.6.5-r5\hardware\arduino\avr\cores\arduino/Stream.h:26:0,
                 from C:\Program Files\arduino-1.6.5-r5\hardware\arduino\avr\cores\arduino/HardwareSerial.h:29,
                 from C:\Program Files\arduino-1.6.5-r5\hardware\arduino\avr\cores\arduino/Arduino.h:224,
                 from ArduinoFirmwareFort85.ino:11:
C:\Program Files\arduino-1.6.5-r5\hardware\arduino\avr\cores\arduino/Print.h:32:0: warning: "BIN" redefined [enabled by default]
 #define BIN 2
 ^
In file included from c:\program files\arduino-1.6.5-r5\hardware\tools\avr\avr\include\avr\iotn85.h:38:0,
                 from c:\program files\arduino-1.6.5-r5\hardware\tools\avr\avr\include\avr\io.h:428,
                 from c:\program files\arduino-1.6.5-r5\hardware\tools\avr\avr\include\avr\pgmspace.h:88,
                 from C:\Program Files\arduino-1.6.5-r5\hardware\arduino\avr\cores\arduino/Arduino.h:28,
                 from ArduinoFirmwareFort85.ino:11:
c:\program files\arduino-1.6.5-r5\hardware\tools\avr\avr\include\avr\iotnx5.h:55:0: note: this is the location of the previous definition
 #define BIN     7
 ^
ArduinoFirmwareFort85.ino: In function 'void setup()':
ArduinoFirmwareFort85.ino:73:9: error: lvalue required as left operand of assignment
Multiple libraries were found for "SoftwareSerial.h"

 Used: C:\Documents and Settings\Administrator\My Documents\Arduino\libraries\SoftwareSerial

 Not used: C:\Program Files\arduino-1.6.5-r5\hardware\arduino\avr\libraries\SoftwareSerial

lvalue required as left operand of assignment

The purpose of SoftwreSerial in my documents folder is that I use 3-4 versions of IDE at same time due to different reasons,So in all of them, a same version should be shared which helps me in finding out other errors.

Thank you.

TomGeorge:
Hi,
As you will see in the tutorial the sketch is for a UNO, not an attiny.
There are significant differences between the two in internal registers.

You are asking to much of a smaller controller to do.

If you want to make a stand alone scope, then UNO is the way to go, it has the TLL/RS232/USB interface and the speed to do a good job with bluetooth and an phone.

Tom..... :slight_smile:

Yeah. I don't want to give space on a breadboard to another 328P just for scope. I need only 4 I/O, 2 for sofrwareserial and 2 ADC as for 2 scope channels. So, atiny x5 chip is chosen. If my code was small, I'd put a tiny10 on a SOT23-6 to DIP adapter.
I have only one arduino board and no chance for buying another until mid march.
Anothe ascept is that, if I can put the sketch on a tiny, I'll put all of this on a PrefBoard and solder together as a permenant scope for my projects. I really want a DS1054Z *ish something,but I can't find a reliable distributor here and I wont be getting it until mid march even if I find a distributor.
Sadly(maybe for you,If you don't have a Windows Phone) the application is only for Windows Phone.
BTW,Everything works on smoke, really,I put supply backwards on Uno at Vin, let the smoke out from
1117-5,replaced 1117-5 for $0.1
Thank you.

Suggestion: compile for an Uno board, to find out specific ATtiny problems.

Did you check the sampling rate, achievable with the ADC and two channels? At 10 bit resolution you'll get max. 7kHz sampling rate only. By interleave with data transmission to your phone you'll get an unpredictable (unstable) rate, and the small RAM won't allow to store lengthy samples before transmission.

DrDiettrich:
Suggestion: compile for an Uno board, to find out specific ATtiny problems.

Did you check the sampling rate, achievable with the ADC and two channels? At 10 bit resolution you'll get max. 7kHz sampling rate only. By interleave with data transmission to your phone you'll get an unpredictable (unstable) rate, and the small RAM won't allow to store lengthy samples before transmission.

As I know, it dosen't store a lot in RAM,just reads it>makes packet> sends to HC05>to phone
wait,i'll compile for UNO and find out the RAM needed for uno
Okay,Result

Sketch uses 3,964 bytes (12%) of program storage space. Maximum is 32,256 bytes.
Global variables use 1,238 bytes (60%) of dynamic memory, leaving 810 bytes for local variables. Maximum is 2,048 bytes.

so, the sketch uses 1,238 bytes of dynamic memory,which is nearly 3 times the available for attiny 85.
I may need to strip down the sketch.

I'll consider the sampling rate when the sketch compiles.