Show Posts
Pages: [1] 2 3
1  Using Arduino / Programming Questions / Re: Arduino Timer Question on: November 02, 2012, 04:27:57 am
I presume it is the same protocol. The send library uses Timer 2, you may have to rework it slightly for the Attiny.
so as far as I know from assembler the attiny85 dont have timer2 and I have to use Timer1 , and in order tgo sync it with the atmega328p receive programm I have to use attiny internal 8MHz.
I changed the code this way :
Code:
//
//  ManchesterSend.cpp
//  
//
//  Created by Nick Gammon on 22/01/12.
//  Copyright 2012 __MyCompanyName__. All rights reserved.
//

#include <ManchesterSend.h>

namespace ManchesterSend {
  
  // which pin to send on
  byte sendPin;

  // current bits yet to be sent
  volatile unsigned long outData;
  
  // how many bits
  volatile byte bitsToGo;
  
  // the current bit
  byte currentBit;
  
  // have we sent the first of the two pulses?
  boolean sentFirst;


// initialize by setting send pin to output
//   also configure Timer 2 to interrupt us every 500 uS
void begin (const byte pin)
{
  
  sendPin = pin;
  
  digitalWrite (sendPin, HIGH);
  pinMode (sendPin, OUTPUT);
  
  bitsToGo = 0;
  
  // reset Timer 2
  TCCR1A = 0;
  TCCR1B = 0;
  
  // Timer 2 - gives us our 500 uS counting interval
  // 16 MHz clock (62.5 nS per tick) - prescaled by 64
  //  counter increments every 4 uS.
  
  // So we count 125 of them, giving exactly 500 uS (1 mS)
  TCCR1A = _BV (WGM21) ;   // CTC mode
  OCR1A  = 124;            // count up to 125  (zero relative!!!!)
  
  // Timer 2 - interrupt on match
  TIMSK1 = _BV (OCIE1A);   // enable Timer2 Interrupt
  TCNT1 = 0;    
  
  // Reset prescalers
  GTCCR = _BV (PSRASY);        // reset prescaler now
  // start Timer 2
  TCCR1B =   _BV (CS22) ;  // prescaler of 64

} // end of ManchesterSend::begin

// write one byte (blocking)
void write (const byte data)
  {
  
  outData = (((unsigned long) data) << SYNC_BITS) | (1UL << (SYNC_BITS - 1));  
  bitsToGo = SYNC_BITS + 8;
  
  // wait for data to go                            
  while (bitsToGo)
    {}  // block until ISR pulls bits out

  delay (1);  // give last pulse time to go in case it was a LOW
  } // end of ManchesterSend::write

// Timer 2 interrupt here:
  
// a 1 is 01
// a 0 is 10

void isr ()
  {
  
  // if out of bits, set line to high and exit  
  if (bitsToGo == 0)
    {
    digitalWrite (sendPin, HIGH);
    return;
    }  // end of nothing to do
  
  // second pulse is the right way around
  if (sentFirst)
    {
    if (currentBit == 0)
      digitalWrite (sendPin, LOW);        
    else    
      digitalWrite (sendPin, HIGH);      
    
    // read for next one
    sentFirst = false;
    // one less bit
    bitsToGo--;  // that bit has been sent
    return;
    }  // end of done second bit
  
  // get low-order bit
  currentBit = outData & 1;
  // ready for next time
  outData = outData >> 1;
  // send inverse of bit
  if (currentBit == 0)
    digitalWrite (sendPin, HIGH);        
  else    
    digitalWrite (sendPin, LOW);  
  // next time we sent other way around
  sentFirst = true;    
  
  } // end of ManchesterSend::isr

  
} // end namespace ManchesterSend


// Timer 2 compare: call our ISR
ISR (TIMER1_COMPA_vect)
{
  ManchesterSend::isr ();
}  // end of TIMER2_COMPA_vect

Please tell me if I changed correct the code to work with Timer1, the code compile for atmega328 smiley
but when I try for attiny85 I get:
Code:
C:\Users\XaKeRa\Desktop\arduino-0023\libraries\ManchesterSend\ManchesterSend.cpp: In function 'void ManchesterSend::begin(byte)':
C:\Users\XaKeRa\Desktop\arduino-0023\libraries\ManchesterSend\ManchesterSend.cpp:42: error: 'TCCR1A' was not declared in this scope
C:\Users\XaKeRa\Desktop\arduino-0023\libraries\ManchesterSend\ManchesterSend.cpp:43: error: 'TCCR1B' was not declared in this scope
C:\Users\XaKeRa\Desktop\arduino-0023\libraries\ManchesterSend\ManchesterSend.cpp:50: error: 'WGM21' was not declared in this scope
C:\Users\XaKeRa\Desktop\arduino-0023\libraries\ManchesterSend\ManchesterSend.cpp:54: error: 'TIMSK1' was not declared in this scope
C:\Users\XaKeRa\Desktop\arduino-0023\libraries\ManchesterSend\ManchesterSend.cpp:58: error: 'PSRASY' was not declared in this scope
C:\Users\XaKeRa\Desktop\arduino-0023\libraries\ManchesterSend\ManchesterSend.cpp:60: error: 'CS22' was not declared in this scope
2  Using Arduino / Programming Questions / Re: Arduino Timer Question on: November 01, 2012, 03:58:44 pm
I wrote a Manchester library (not the one you posted) which uses pin change interrupts and thus keeps going while you do other things.

It is described here:

http://www.gammon.com.au/forum/?id=11506

The library is on that page, a fairly small download, plus example code in the car receiver.

Scroll down to: "Manchester receiving library".
Ok I found receiver and send library and I downloaded them both but I have one question is it possibble to upload the transmiter sketch to attiny85 with arduino UNO AS ISP and then upload the receiver to my arduino uno ?
I presume that ManchesterSend is the same as ManchesterTransmiter
3  Using Arduino / Programming Questions / Re: Arduino Timer Question on: November 01, 2012, 03:47:35 pm
Not familiar with the manchester library, can you post a link?
Manchester.cpp - http://dox.bg/files/dw?a=14b160bdf3
4  Using Arduino / Programming Questions / Arduino Timer Question on: November 01, 2012, 03:35:59 pm
Hi guys I am using two rf devices to transmit data, the transmitter is attiny85 and receiver is atmega328p, but now I am trying to execute another code while the receiver is reading data when I  do it I get request time out in my c# application.
I am using MANCHESTER library to transmit the number data smiley
Is there a way to use delegate or something to interupt the manchester 1 minute delay and execute the code for turning on my TV ?

Code
Code:
#include <MANCHESTER.h>

#define RxPin 4

void setup()
{
 MANCHESTER.SetRxPin(RxPin); //user sets rx pin default 4
 MANCHESTER.SetTimeOut(1000); //user sets timeout default blocks
 Serial.begin(9600); // Debugging only
}//end of setup

void loop()
{
 unsigned int data = MANCHESTER.Receive();
 Serial.println(data);
}//end of loop


After Serial.println(data);
Code:
char c = Serial.read();
if(c == 'p')
{
//this method just send a special IR impulse in order to control the mp3 player at home
PlayMedia();
}
5  Using Arduino / Sensors / Re: RF link with attiny device on: October 16, 2012, 02:13:48 am
No suit me,because virtualWire need faster timer0 which attiny85 don't have  smiley-grin
But this guy somehow managed to do it :
6  Using Arduino / Sensors / RF link with attiny device on: October 15, 2012, 03:14:25 pm
Hi,guys I have these rf transmitter and receiver :
http://www.robotev.com/product_info.php?cPath=1_30&products_id=235
http://www.robotev.com/product_info.php?cPath=1_30&products_id=236

I wan't to use two separated attiny microcontrolers to send and receive numeric data.
My first question is how can I achieve this,and what attiny microcontroller to use ?
Note: I have arduino UNO and I can program any microcontroller with the ISP MODE.
What I actually want to do is to recognize when the user is around a table and do something.
7  Using Arduino / General Electronics / Re: How to connect this camera to arduino ? on: September 30, 2012, 11:42:36 am
If I can connect this camera directly to my computer and get video feed that will be great, but I am not sure what connector this camera use, and how to connect it at all.

I want to use this camera,because its small and perfect for my needs.
If I go to market and buy a webcam it will be way big, and the fps will suck so bad.
I need a  camera for computer vision project, so I need something that will not slow the fps frame even in full dark room.
8  Using Arduino / General Electronics / Re: How to connect this camera to arduino ? on: September 30, 2012, 09:48:58 am
like ?
9  Using Arduino / General Electronics / How to connect this camera to arduino ? on: September 30, 2012, 09:02:49 am
Hello,guys I have Iphone 3GS camera which is disassembled from the original Iphone, and I want somehow to connect it to arduino and pass the video feed from the camera threw microcontroller and visualizate it in my computer, so then I can apply computer vision algorithms. smiley-wink

Any idea what can I use in order to power up the camera and start making some video ?
10  Using Arduino / Sensors / Wii remote IR Camera on: May 22, 2012, 11:39:54 am
Hello, guys is there a way to buy from anywhere a Wii remote ir camera ?
I don't want to rip off the whole wii controller in order to get the camera.
11  Using Arduino / Project Guidance / Re: Attiny 85 RF on: May 04, 2012, 01:35:10 am
Nobody ... ?
12  Using Arduino / Project Guidance / Re: Attiny 85 RF on: May 03, 2012, 02:16:50 pm
Ok,thank a lot , and sorry for my mistake
13  Using Arduino / Project Guidance / Re: Attiny 85 RF on: May 03, 2012, 08:38:54 am
Someone ?
14  Using Arduino / Project Guidance / Re: Attiny 85 RF on: May 02, 2012, 04:32:02 am
Ok so then how to upload succesufully the code on attiny85 then ?
15  Using Arduino / Project Guidance / Re: Attiny 85 RF on: May 02, 2012, 02:43:13 am
Well I tried this manchested library, but I always get this error when I try to upload the code in attiny85 :
Code:
#include "MANCHESTER.h"

#define TxPin 1  //the digital pin to use to transmit data

unsigned int Tdata = 32;  //the 16 bits to send

void setup()
{               
MANCHESTER.SetTxPin(TxPin);      // sets the digital pin as output default 4
}//end of setup

void loop()
{
 //Tdata +=1;
 MANCHESTER.Transmit(Tdata);
 delay(100);
}//end of loop

Code:
D:\arduino-0022\libraries\MANCHESTER\MANCHESTER.cpp: In constructor 'MANCHESTERClass::MANCHESTERClass()':
D:\arduino-0022\libraries\MANCHESTER\MANCHESTER.cpp:42: error: 'TCCR2A' was not declared in this scope
D:\arduino-0022\libraries\MANCHESTER\MANCHESTER.cpp:43: error: 'TCCR2B' was not declared in this scope
D:\arduino-0022\libraries\MANCHESTER\MANCHESTER.cpp:44: error: 'TIMSK2' was not declared in this scope
D:\arduino-0022\libraries\MANCHESTER\MANCHESTER.cpp: In member function 'unsigned int MANCHESTERClass::Receive()':
D:\arduino-0022\libraries\MANCHESTER\MANCHESTER.cpp:85: error: 'TCNT2' was not declared in this scope
D:\arduino-0022\libraries\MANCHESTER\MANCHESTER.cpp:126: error: 'TCNT2' was not declared in this scope


Pages: [1] 2 3