Show Posts
Pages: [1] 2 3 ... 6
1  Using Arduino / Project Guidance / Re: Counting 180Hz at less then 200mV on: September 18, 2013, 10:26:58 am
Thank you so much.
2  Using Arduino / Project Guidance / Re: Counting 180Hz at less then 200mV on: September 18, 2013, 07:39:29 am
Hi dc42
Quote
From your code, it looks like you just want the frequency, in which case suggestion (1) is the obvious solution.
Straight to the point, yes.. The pules count can be worked out with this method as well?
I'll be using an OMLED or LCD screen to show Hz and counts, with a button to reset the count back to zero and and hold button.
Quote
The end result is the finished code counting the pulses using "unsigned long" so say over 1 minuet at 180Hz, so that will be 180X60 = 10,800 counts
Thank you for the link!
 
3  Using Arduino / Project Guidance / Re: Counting 180Hz at less then 200mV on: September 17, 2013, 11:24:13 am
Thank you very much!
4  Using Arduino / Project Guidance / Counting 180Hz at less then 200mV on: September 17, 2013, 09:24:15 am
Hi, I need some guidance,

 
I would like to know if any of the ATmega328 pins can read 180Hz at less than 200mV with the appropriate code written.

I'm testing the Nano with code shown below, using a signal generator with sin wave at 180Hz. With the serial monitor open the Nano will only start giving a reading over an output of 2.80V on PD5.
Space is going to be tight so I need to keep the PCB small. I would like to use as little components as I can and this is the first time I'm going to give it a go at making a PCB with an ATmega328. I've done one with a Tiny85's and it was really fun.

Code:
#include <FreqCounter.h>
int cnt;
unsigned long frq; //Declares an extended size variable for the measured frequency

void setup() {
  Serial.begin(9600);
}

void loop() {

  FreqCounter::f_comp=10;
  FreqCounter::start(1000);

  while (FreqCounter::f_ready == 0)

  frq=FreqCounter::f_freq; //Sets the 'frq' variable as the measured frequency

Serial.println(frq);

The end result is the finished code counting the pulses
Quote
unsigned long
so say over 1 minuet at 180Hz, so that will be 180X60 = 10,800 counts?
5  Using Arduino / Programming Questions / Re: Help with, ATtiny13A Water Sensor on: January 30, 2013, 04:58:48 am
Rite, all working now.. Thanks E.

If I changed,
Code:
const int Probe = 0;


to,
Code:
const int Probe = A3;
I got this, why? I thought this is declaring?
Code:
Tiny13:3: error: 'A3' was not declared in this scope


I removed the "A"

And now it's all working fine now, with a few adjustments to "threshold".

Code:
const int outPin1 = 1;
const int outPin2 = 2;
const int Probe = 3;
const int threshold = 220;
int sensorReading = 0;
void setup() {
  pinMode(outPin1, OUTPUT);
  pinMode(outPin2, OUTPUT);
}
void loop() {
  sensorReading = analogRead(Probe);   
  if (sensorReading >= threshold)
  {     
    digitalWrite(outPin1, HIGH); 
    digitalWrite(outPin2, LOW);
  }
  else {
    digitalWrite(outPin1, LOW);
    digitalWrite(outPin2, HIGH);
  }
  delay(1000);
}
6  Using Arduino / Programming Questions / Re: Help with, ATtiny13A Water Sensor on: January 30, 2013, 04:25:30 am
Thank you Erni, will update the code and see how it goes!
7  Using Arduino / Programming Questions / Help with, ATtiny13A Water Sensor on: January 29, 2013, 12:11:34 pm
Hi all,

I've been toying with my Leonardo and Mega2560 and have my simple code working fine and how I want on both ("code adapted from the Knock Sketch"). Trouble is, when I upload my code to my ATtiny13A with the pin's updated in the code, PB1 (Pin6) is "HIGH" and PB2 (pin7) is "LOW" which is all fine and well but, when I put the probe in water PB1 (Pin6) stays "HIGH" and PB2 (Pin7) is still "LOW" What I was expecting to see what PB1:LOW, PB2:HIGH as this is how it works on the Leonardo and Mega2560

Just to be clear,
The outPin's are LED's for now.

Probe out of water.
PB1:HIGH, PB2:LOW,

Probe in water.
PB1:LOW, PB2:HIGH



Leonardo code:
Code:
const int outPin1 = 7;
const int outPin2 = 8;
const int Probe = A0;
const int threshold = 75;
int sensorReading = 0;
void setup() {
  pinMode(outPin1, OUTPUT);
  pinMode(outPin2, OUTPUT);
  Serial.begin(9600);
}
void loop() {
  sensorReading = analogRead(Probe); 
  Serial.print("\t sensor = " ); 
  Serial.print(sensorReading);   
  if (sensorReading >= threshold) {     
    digitalWrite(outPin1, HIGH); 
    digitalWrite(outPin2, LOW); 
  }
  else {
    digitalWrite(outPin1, LOW);
    digitalWrite(outPin2, HIGH);

  }
  delay(100);
}

ATtiny13A:
Code:
const int outPin1 = 1;
const int outPin2 = 2;
const int Probe = 0;
const int threshold = 75;
int sensorReading = 0;
void setup() {
  pinMode(outPin1, OUTPUT);
  pinMode(outPin2, OUTPUT);
}
void loop() {
  sensorReading = analogRead(Probe);   
  if (sensorReading >= threshold)
  {     
    digitalWrite(outPin1, HIGH); 
    digitalWrite(outPin2, LOW);
  }
  else {
    digitalWrite(outPin1, LOW);
    digitalWrite(outPin2, HIGH);
  }
  delay(100);
}

I can only assume some things up with my code, in fact... My assumption is, PB0 to PB5 can be ether used as Analogue or Digital I/O's? Is this correct?

I'll put up an Fritzing pic in a sec.

If there's anything thing have missed out, shout.

Cheers,
8  Using Arduino / Microcontrollers / Re: Programming ATtiny13, Problems... on: January 22, 2013, 08:32:01 am
Very nice Erni, pictures help so much.
For the Tiny13A wiring.c just needs the string added in below.
Code:
|| (__AVR_ATtiny13__)

From this,
Code:
#if defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
SIGNAL(TIM0_OVF_vect)
#else
SIGNAL(TIMER0_OVF_vect)
#endif

To this,
Code:
#if defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || (__AVR_ATtiny13__)
SIGNAL(TIM0_OVF_vect)
#else
SIGNAL(TIMER0_OVF_vect)
#endif
When I opened the file up in notepad, it was very tricky to find, all the text run horizontally. It was a nightmare, but if you know what to look out for it's still tricky. In the end I just to used word.
Pasted as (Keep text Only). Oh yes! Be sure to make a copy off the original, if you FUBAR it you can role back with the original!!
My file was located here,
Quote
C:\Arduino\arduino-1.0.3\hardware\arduino\cores\arduino

This tut is good, newb's like me will struggle, some parts are vague.. I still don't know what "fuse bytes" are or what they are used for. I had disregard it all but plugged away...
http://tekstop.wordpress.com/2011/12/30/programming-attiny13-using-arduino-isp-and-all-the-hacking-involved/
9  Using Arduino / Microcontrollers / Re: Programming ATtiny13, Problems... on: January 22, 2013, 05:25:14 am
I uploaded "Blink", it works a treat.
Some one needs to write up a good tut for noobs like me, with this one. Lots of pic's... I might give it ago.
10  Using Arduino / Microcontrollers / Re: Programming ATtiny13, Problems... on: January 21, 2013, 11:21:19 am
I had the wires wrong, oops.

I now get this..

Code:
avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny13
avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny13

What does this mean?
11  Using Arduino / Microcontrollers / Re: Programming ATtiny13, Problems... on: January 21, 2013, 11:19:34 am
I have just try'd this,

Choose Tools->Board->Arduino Mega 2560         //The Programming board
Uploaded Sketch Examples->ArduinoISP          //The programming software
Choose Tools->Board->Arduino ATtiny13                //The target chip type to be programmed
Choose Tools->Programmer->Arduino as ISP   //Tells the IDE to use software programmer
Choose Tools->Burn Bootloader                      //Uploads the bootloader to the Diecimila (programmer) than burns it to the target

But I get this,

Code:
avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny13
avrdude: stk500_program_enable(): protocol error, expect=0x14, resp=0x50
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51

Just going to check my wires again. 
12  Using Arduino / Microcontrollers / Programming ATtiny13, Problems... on: January 21, 2013, 09:57:39 am
Hi all, I'm trying to program a ATtiny13A just have a play.
I'm using my good old Mega2560 for programming, 

I have given this tut ago, but I'm struggling
http://tekstop.wordpress.com/2011/12/30/programming-attiny13-using-arduino-isp-and-all-the-hacking-involved/
With https://github.com/tekstop/attiny/tree/Arduino1

Quote
*** modified boards.txt [ATtiny13 can be programmed using Arduino as ISP]
*** NOTE: A change has to be made to the wiring.c file in the arduino core for this to work correctly. The wiring.c file has an error where it does not set the correct TIMER for ATTiny13 only. This change will not impact any other boards.

in arduino1/hardware/arduino/cores/arduino/wiring.c

Line 44 should be supplemented with an additional condition for ATtiny13

#if defined(__AVR_ATtiny24__) || defined(..) ... [Add this] || defined(__AVR_ATtiny13__)
SIGNAL(TIM0_0VF_vect)
....

Do I need to add this or has it been done? I'm confused.

Code:
#if defined(__AVR_ATtiny24__) || defined(..) ... [Add this] || defined(__AVR_ATtiny13__)
SIGNAL(TIM0_0VF_vect)

Pin 9 LED is fading, indicating the program is working.
When I open serial monitor I input
Quote
Burn Bootloader > Arduino as ISP
Pin 9 LED stays on, and Pin 8 LED light's up, Pin 7 has remained off.

My wires check out, what can I do to figure out what I have missed or done wrong.
Quote
// pin name:    not-mega:         mega(1280 and 2560)
// slave reset: 10:               53
// MOSI:        11:               51
// MISO:        12:               50
// SCK:         13:               52

Is there anything more I can add to help you guys out to help me?



Cheers.
13  Using Arduino / Programming Questions / Re: Using Floating-Point number on: December 27, 2012, 04:32:09 am
14  Using Arduino / Programming Questions / Re: Using Floating-Point number on: December 27, 2012, 04:07:59 am
Hey Paul, hope you had a good Christmas.

I need to pop up a vid of it working, for you  smiley
15  Using Arduino / Programming Questions / Re: Using Floating-Point number on: December 14, 2012, 01:20:55 pm
Haaa haaaa!!! I got it..

Code:
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_DC 48
#define OLED_CS 52
#define OLED_CLK 46
#define OLED_MOSI 44
#define OLED_RESET 50
Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);
#if (SSD1306_LCDHEIGHT != 32)
#endif
enum PinAssignments {
  encoderPinA = 20,
  encoderPinB = 21,
  zeroButton = 42
};
volatile int encoderPos = 0;
int lastReportedPos = 0;
volatile boolean A_set = false;
volatile boolean B_set = false;

int printEncode;

void setup() {
  pinMode(encoderPinA, INPUT);
  pinMode(encoderPinB, INPUT);
  pinMode(zeroButton, INPUT);
  digitalWrite(encoderPinA, HIGH);
  digitalWrite(encoderPinB, HIGH);
  digitalWrite(zeroButton, HIGH);
  attachInterrupt(2, doEncoderA, CHANGE);
  attachInterrupt(3, doEncoderB, CHANGE);
  display.begin(SSD1306_SWITCHCAPVCC);
  display.display();
  delay(1000);
  Serial.begin(9600);
}
void loop(){

  if (lastReportedPos != encoderPos) {
    noInterrupts();
    lastReportedPos = encoderPos;
    interrupts();
  }
  if (digitalRead(zeroButton) == LOW)  {
    encoderPos = 0;
  }
  float printEncode = (encoderPos / 1000.0);
  display.display();
  display.clearDisplay();
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.setCursor(0,0);
  display.print("Linear");
  display.setCursor(0,16);
  display.print("Position");
  display.setCursor(0,40);
  display.setTextSize(3);
  display.print(printEncode, 3);
  display.setTextSize(2);
  display.setCursor(0,24);
  display.print("__________");
  display.setTextSize(2);
  display.setCursor(96,47);
  display.print("mm");
  display.setTextSize(2);
  display.setCursor(0,50);
  display.print("__________");
 
}
void doEncoderA(){
  A_set = digitalRead(encoderPinA) == HIGH;
  encoderPos += (A_set != B_set) ? +1 : -1;
}
void doEncoderB(){
  B_set = digitalRead(encoderPinB) == HIGH;
  encoderPos += (A_set == B_set) ? +1 : -1;
}
Pages: [1] 2 3 ... 6