Show Posts
Pages: 1 [2] 3 4 ... 6
16  Using Arduino / Installation & Troubleshooting / Re: Is there no internal Vref on Pro Mini Atmega 328p ? on: June 12, 2014, 08:00:55 am
My 328p chip is squared, it's not a 28pin DIP package.

http://www.wvshare.com/img/pinout/ATmega328P_l.jpg
 
and AREF seams to be located at pin 20.

By the way, how is it possible Atmel make a 32pin and a 28pin package when all the 32pin are used ?
The DIP package also has 2 GND, Vcc, AVcc.

And what difference do they make between Vcc and AVcc ?

Sorry for all these questions.
17  Using Arduino / Installation & Troubleshooting / Re: Is there no internal Vref on Pro Mini Atmega 328p ? on: June 12, 2014, 02:17:18 am
Ok.

I don't really need AREF access all the time but I want to calibrate the  1.1V reference to make an accurate voltmeter.

When I know exactly the value of this reference, I can then use it in my code.
That's it.

Thanks for your support.
18  Using Arduino / Installation & Troubleshooting / Re: Is there no internal Vref on Pro Mini Atmega 328p ? on: June 11, 2014, 05:12:22 pm
Quote
You probably mean the "AREF" (Analog Reference) pin.  The chip has one (pin 20)  but it is not connected to any of the edge pins.  It goes through a capacitor to ground.
Yes you're right I meant AREF ! Ok so it's not accessible from the board.

Quote
Using a higher voltage might cause the regulator to overheat.

Well, i have some 12V regulator, so I might use these. It won't be energy efficient but...... I'll see later to get a better solution.

Thanks for your help.
19  Using Arduino / Installation & Troubleshooting / Is there no internal Vref on Pro Mini Atmega 328p ? on: June 11, 2014, 03:48:42 pm
Hello.

I'm starting to work with a Pro Mini from Deek_Robot but I'm noticing some difference from my usual Arduino Board Mega 2560.

 On top of that, reading the Reference of the Pro Mini, it should be with a ATmega168. But instead, it's a ATmega328p ???

I can't find the Vref Pin ? Is there an internal Réfrence voltage on this ?  1.1V or 1.1V and 2.56V ? I guess, if there is, it's not accessible from a pin like on a Mega 2560.

Then I have a Vin and a RAW. Where can I give it 5V and where can I give it 12V ?  I guess the RAW is for 12 v
I want to work on car battery and I wonder if I can feed it up to 14.4V without damaging it ?




20  Using Arduino / Programming Questions / Why my INTERRUPT doesn't work on: June 10, 2014, 07:08:00 am
Hi.
I'm using an INTERRUPT for the 1st time and I can't get it working.
Any idea ?

Code:
//LCArduiDef.h LearnCbot  definitions Arduino
#include < avr/interrupt.h >
#include <Arduino.h>
#define  Led13  13 
#define   Led13On  digitalWrite (Led13,1)
#define   Led13Off digitalWrite (Led13,0)
#define   Led13Toggle
#define HP  1
#define   HPOn   digitalWrite (HP,1)
#define   HPOff  digitalWrite (HP,0)
#define   HPToggle  digitalWrite (HP,!digitalRead(HP))
#define L1  4 
#define L2  5
#define L3  6 
#define L4  7
#define   Led1On   digitalWrite (L1,1)
#define   Led1Off  digitalWrite (L1,0)
#define   Led1Toggle  digitalWrite (L1,!digitalRead(L1))
#define   Led2On   digitalWrite (L2,1)
#define   Led2Off  digitalWrite (L2,0)
#define   Led2Toggle  digitalWrite (L2,!digitalRead(L2))
#define   Led3On   digitalWrite (L3,1)
#define   Led3Off  digitalWrite (L3,0)
#define   Led3Toggle  digitalWrite (L3,!digitalRead(L3))
#define   Led4On   digitalWrite (L4,1)
#define   Led4Off  digitalWrite (L4,0)
#define   Led4Toggle  digitalWrite (L4,!digitalRead(L4))
#define P1  2 
#define P2  3
#define   Pous1On  (!digitalRead(P1))
#define   Pous2On  (!digitalRead(P2))

void LcSetup () {
  pinMode (1,1);
  pinMode (2,0);
  pinMode (3,0);
  digitalWrite (2, 1);
  digitalWrite (3, 1);
  pinMode (4,1);
  pinMode (5,1);
  pinMode (6,1);
  pinMode (7,1);
}
void avance () {
  Led2Off;
  Led4Off;
  Led1On;
  Led3On;
}
void ISR1 () {
  Led1Off;
  Led3Off;
  Led2On;
  Led4On;
  delay(500);
  Led2Off;
  Led1On;
  delay(1000);

}





void setup() {
  // put your setup code here, to run once:
  LcSetup ();
  attachInterrupt(P1, ISR1, FALLING);
  attachInterrupt(P2, ISR1, FALLING);
  //attachInterrupt(P2, ISR2, FALLING)
}

void loop() {
  // put your main code here, to run repeatedly:
  while (!Pous1On && !Pous2On){
    avance();
  }


}

21  Using Arduino / Programming Questions / Re: I can't find what is wrong in my code (newbie) on: June 03, 2014, 03:26:33 am
Yes you're right, I am.

But I have been used to that the english forum is way more active.
22  Using Arduino / Programming Questions / Re: I can't find what is wrong in my code (newbie) on: June 02, 2014, 05:16:10 pm
OK, Thanks you.

I made my code working now.

Thanks for the help, indeed.
23  Using Arduino / Programming Questions / Re: I can't find what is wrong in my code (newbie) on: June 02, 2014, 09:52:33 am
I'm really sorry but I don't catch you yet.

I'm lost with all these terms (English is not my mother tongue)

Could you tell me please what I should write in the function declaration and after what to write at the parameter place in  this function to use it.
24  Using Arduino / Programming Questions / Re: I can't find what is wrong in my code (newbie) on: June 02, 2014, 08:15:42 am
 Sorry but I don't understand the "myEnum"
Code:
void Caractere (Lettre myEnum)

I have never  mentioned this before.
Sorry for being so stupid but I'm very new at using array and enum !
It's a prototype error courtesy of the behind the scenes work the IDE does for you.


When I've done this without changing anything else, it worked ! :
This change in your Caractere function definition will make it compile at least:
Code:
  void Caractere (char Lettre)
But I removed the "char Letter" because I think I don't need it and now I got the same error as before.

The serial data protocole I'm using is very personal. It is sending on the pin N°4 the letter as ASCII code in binary S = 01010011, LSB and before the letter 1 Starbit, after the letter 2 Stopbit.

Code:
#define L1 4
#define L1On digitalWrite (L1, 1)
#define L1Off digitalWrite (L1, 0)

enum Lettre {
  s, o};
char tabLettre [] = {
  'S', 'O'};

long dureeBit = 3330;


void Zero () {
  L1On;
  delayMicroseconds (dureeBit);
  //delay(dureeBit);
}

void Un () {
  L1Off;
  delayMicroseconds (dureeBit);
  //delay(dureeBit);
}

void Start () {
  L1Off;
  delayMicroseconds (dureeBit);
  //delay(dureeBit);
}

void Stop () {
  L1Off;
  for (int i=0; i<2; i++) {
    delayMicroseconds (dureeBit);
    //delay(dureeBit);
  }
}

void Caractere ( Lettre){
  Zero();
  for (int i=0; i<8; i++) {
    //if (tabLettre [Lettre] & 1 << i) {
    if (Lettre & 1 << i) {
      Zero ();
    }
    else {
      Un ();
    }
  }
  Stop();
}

void sequence () {
  Caractere (s);
  Caractere (o);
  Caractere (s);
  Zero();
}



void setup() {
  // put your setup code here, to run once:
  pinMode (L1,1);
  Zero();

  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  /*if (Serial.available () > 0) {
   Lettre = Serial.read ();
   Serial.print ("Lettre est = "); Serial.print (Lettre);
   Serial.print ("    BINaire est ") ; Serial.println (Lettre, BIN );
   }
   */

  sequence();

  delay(1000);
}

25  Using Arduino / Programming Questions / Re: I can't find what is wrong in my code (newbie) on: June 02, 2014, 07:43:26 am
Many thanks for helping.

I'll try to work with these information and come back later if needed.

Thanks to you all.
26  Using Arduino / Programming Questions / I can't find what is wrong in my code (newbie) on: June 02, 2014, 07:01:46 am
Hello.

I'm trying to send an SOS on a LED wired on  N°4 PIn.
It has to send the different letter as serial binary data, LSB fisrt.
Before each letter is a start bit (0)
After each letter is 2 stop bit (0.0)
For S,(01010011) it has to send :
0 (startbit), 1, 1, 0 , 0, 1, 0, 1, 0, (then 2 stopbit), 0, 0.

I made this code that gives me error, but I can't finf the reason.
Code:
enum Lettre {s, o};
char tabLettre [] = {'S', 'O'};
char Lettre;
long dureeBit = 333;
#define L1 4
#define L1On digitalWrite (L1, 1);
#define L1Off digitalWrite (L1, 0);

 void Zero () {
  L1On;
  //delayMicroseconds (dureeBit);
  delay(dureeBit);
    }
 
  void Un () {
  L1Off;
  //delayMicroseconds (dureeBit);
  delay(dureeBit);
    }
   
  void Start () {
    L1Off;
    //delayMicroseconds (dureeBit);
    delay(dureeBit);
  }
     
  void Stop () {
    L1Off;
      for (int i=0; i<2; i++) {
      //delayMicroseconds (dureeBit);
      delay(dureeBit);
      }
  }
 
  void Caractere (Lettre){
      Zero();
      for (int i=0; i<8; i++) {
          //if (tabLettre [Lettre] & 1 << i) {
            if (Lettre & 1 << i) {
            Zero ();
            }
            else {
            Un ();
            }
        }
        Stop();
  }
   
  void sequence () {
 
    Caractere (s);
   
    Caractere (o);
   
    Caractere (s);
 
    Zero();
 
  }
 

   
void setup() {
  // put your setup code here, to run once:
  pinMode (L1,1);
  Zero();
 
Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  /*if (Serial.available () > 0) {
  Lettre = Serial.read ();
  Serial.print ("Lettre est = "); Serial.print (Lettre);
  Serial.print ("    BINaire est ") ; Serial.println (Lettre, BIN );
  }
  */
 
sequence();

delay(1000);
}

Any help to solve this "error: variable or field 'Caractere' declared void"?

27  Using Arduino / Programming Questions / Re: Accurate voltmeter (or could be renamed : uC's ADC ... State of the art) on: April 27, 2014, 03:22:25 pm
I'm now wondering if using 1024 or 1023 in the calculation of VCC !

http://forum.allaboutcircuits.com/showthread.php?t=80018

What chance has the beginner (or indeed anyone) if you just wrote
Code:
ADCSRA |= 64
?
At least the BV form gives an idea what is going on.

(BTW, you realise ADCSRA is a macro too, don't you?   smiley-wink. )

ADCSRA ? A macro ? I don't see what you mean.

This topic  is really leading me to deep. Somebody to help stay tuned on the most important things ?
Properly using uC seems to be quite difficult indeed ! Interesting, but a little bet hard for a beginner !
28  Using Arduino / Programming Questions / Re: Accurate voltmeter on: April 27, 2014, 03:09:27 pm
Quote
As I said, I don't know how to "read" :
"ADCSRA |= _BV(ADSC);"
"BV" means "bit value", so given a bit position as a number (LSB is zero), it turns that into a bit mask.
BV(2) is the same as 1 << 2, which is same as 4.
"|=" says bit wise OR the variable on the left with the mask on the right, and assign the result to the variable on the left.

So can I say :
ADCSRA |= _BV(ADSC);
is equivalent to :
ADCSRA = ADCSRA | _BV(ADSC);
is equivalent to :
ADCSRA =ADCSRA | 0b01000000  (see Atmel datasheet, -BV(ADSC) = 0b01000000)
is equivalent to :
ADSRA = ADCSRA | 0x40
is equivalent to :
ADCSRA |= 1<<6
is equivalent to :
ADCSRA |= 64


Mmmm ! So many writting to say the same thing ! No wonder why a beginner can't understand !
29  Using Arduino / Programming Questions / Re: Accurate voltmeter on: April 27, 2014, 08:12:15 am
If you study the Atmel datasheet for whatever MCU you are using you will discover that all these things
Quote
ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
are register names and bit names within the registers of the microprocessor.

Personally I find this notation very opaque and I prefer to write my code in the style ADMUX &= B01001010 where the 1s and 0s directly correspond with the bits. (By the way B01001010 is just random stuff for example purposes).

...R

Yes I'm more or less clear with ADMUX register "configuration". Despite I don't know what the "_BV" means
Your notation is quite interesting because it remind the configuration of each bit each time you write it. But what I don't understand in this case is the "&="
But what about the rest  : "ADCSRA |= _BV(ADSC);"
for instance.

Quote
I wonder where the "1125300L" come from ?
The calculation is set out at the end of the line.
You're quite correct however, is should be 1024, not 1023.
I'm not sure I agree with you !I think despite there is 1024 value possible, in the calculation you must use 1023.
The comments don't help me understand.
As I said, I don't know how to "read" :
"ADCSRA |= _BV(ADSC);"
I think this kind of expression is closer to C that to Arduino programming !

Quote
That is the problem copying code without understanding it ! It can lead to serious mistake !
pure wisdom , seldom seen
Many thanks for securing and encouraging me in that direction. otherwise, I sometime feel like an alien, wanting understanding every bits !

Arduino is not a PC but an embedded processor, it has no operating system that shields of the low level thingies (HAL)
When you program an Arduino (or similar device)  youare have to programming much closer to the hardware level than you typically do in an PC environment where every device is e.g. a (more or less) nice .NET  Class.

If you take a few days to go through the tutorial section, and study, execute, adapt the sketches there you will see most register and bit-masking thingies is not very very difficult. But it takes several dozen projects to get used to it.



You got it I think. That register and bit-masking stuff that I need. But how to get a start with it. I've been turning around this for a while already. I feel, it's what I need, but can't get things on its way.
I think  this "Accurate voltmeter" is extremely important with this Arduino things where we need to deal with lots of analogRead() and analogWrite(). That's basis of sensors accuracy. And with Arduino, what to do with no sensor ?
You catch what I need to be able to read this code. Any advice for a start ?


30  Using Arduino / Programming Questions / Re: Arduino source code. What does the function analogRead() in C ? on: April 27, 2014, 07:03:58 am
Well.

Maybe my question wasn't correct.
What lead me to this question is that topic I've started :
http://forum.arduino.cc/index.php?topic=236066.0

I thought I was facing some C instead of Arduino code, but as I'm beginner, I might have been wrong !

Pages: 1 [2] 3 4 ... 6