Show Posts
Pages: [1]
1  Using Arduino / General Electronics / Re: 5v project not working on 3.3v on: October 03, 2011, 12:08:34 pm
Sooooo,
First of all: Thanks for all your great advices, they help me understand the mcu-world a bit more!
I can't exactly determine the mistake i made, but after re-organizing the breadboard components and changing some cable it somehow worked suddenly, so probably a lack of electrical connection somewhere, which is weird, because I had already removed / moved some stuff in order to minimize testing configuration and localize the mistake.
Though not everything works perfectly now ("fake" gnd and vc on analog pins have only 2.7v), it works!
Since I am really very new to all this, it also could have been a decoupling mistake.
Thanks, solved!
2  Using Arduino / General Electronics / Re: 5v project not working on 3.3v on: October 03, 2011, 04:58:12 am
I don't think so, because it is one of the chips being delivered together with the arduino board, factory settings should work, or not?
But thanks for the advice, I learned something again smiley-grin
Anyway, I'll test that when I have time, meanwhile I use a step-up booster for the mcu circuit and the 3.3v to power the motor.
3  Using Arduino / General Electronics / Re: 5v project not working on 3.3v on: October 02, 2011, 09:01:08 am
Sorry if that wasn't clear enough.
Its not a source problem for sure. The current draw of the test installation is below the rated 50mA for the 3.3v pin of an UNO, but my iPod (used as source in my project, providing regulated 3.3v) provides even more.
4  Using Arduino / General Electronics / Re: 5v project not working on 3.3v on: October 02, 2011, 08:50:44 am
Edit: Timings will be off. Programming the chip in an Uno assumes a 16MHz clock. When the chip is then moved to the breadboard running at 8MHz, delay(1000) will actually result in a two second delay, etc. Not entirely sure about PWM, should probably work, although I'd think the PWM frequency would be halved as well. Still, it ought to run.

Your sketch is pretty simple, but when faced with a conundrum like this, I always back off to the simplest thing possible, i.e. the Blink sketch.
Yes, thought about that too, but doesn't explain this behavior. I believe having read somewhere that sketches will run equally on 16 and 8 mHz, because these frequencies are supported by the default bootloader, only things like 10 or 20 mHz require a reconfigured one.

Yes, I just made this simple sketch to figure out what is going wrong, the real code doesnt work either of course.
5  Using Arduino / General Electronics / Re: 5v project not working on 3.3v on: October 02, 2011, 08:44:46 am
@Jamed C4S

This i ment with the quoted line:
The 3.3v source provides enough power, actually more when using my iPod, otherwise i simply power it with the 5v or the 3.3v pin of another arduino.
6  Using Arduino / General Electronics / Re: 5v project not working on 3.3v on: October 02, 2011, 08:42:19 am
Of course, yea. And this is the really weird thing, why does it perfectly work on 5v and not at all at 3.3v?
So, i suppose, it doesn't matter.. shouldn't matter if the atmega is programmed using an 5v/16mHz Uno and then moved on a 3.3v/8mHz breadboard?
7  Using Arduino / General Electronics / 5v project not working on 3.3v on: October 02, 2011, 08:14:47 am
Hi,
I wonder if there must be made any softwaresided changes in order to make my atmega328p-pu work on 3.3v with 8mHz crystal, which is programmed being plugged into an arduino UNO (on 5v of course) and then clipped to a breadboard.

This chip works fine if I power the breadboard with 5v (still using 8mHz crystal with 22pF decoupling capacitors), i.e. the pwm signal on pin 6 tested with the code below varies between 0 and 5v, but if i power it with 3.3v (another arduino as source, or my iPod), my multimeter shows only 0,1v, all the time.

What am I doing wrong? I really don't want to use a step-up booster and - for sure - the used 3.3v source has enough power (logical considering that it works on 5v).

My breadboard installation doesn't matter in this case, because this behavior is apparently related to the atmega itself.

Any help is greatly appreciated, I am still new to Arduino!

Greets,
Flok3r

Code:

int out_A_pwm = 6;
int out_A_in_1 = 7;
int out_A_in_2 = 8;

int i = 1;
int pwm = 0;


//----------------------------------
void setup() {

  // Motor part ----------------
  pinMode(out_A_pwm,OUTPUT);
  pinMode(out_A_in_1,OUTPUT);
  pinMode(out_A_in_2,OUTPUT);
  digitalWrite(out_A_in_1, HIGH); //setting direction of the motor
  digitalWrite(out_A_in_2, LOW);

}
//------------------------------------
void loop(){
  if (pwm == 255) i = -1;
  else if (pwm == 0) i = 1;
 
  pwm = pwm + i;
  analogWrite(out_A_pwm, pwm);
  delay(5);
 
}

8  Using Arduino / Programming Questions / Re: Code wont compile - Noob question! on: September 18, 2011, 07:46:00 am
Thanks for your quick answer and advices smiley
Ye, a beginner mistake..
I was sure to have the mistake in my sketch, relying on the nunchuck lib which i had used successfully before, that i completely ignored overlooking it, though it was indeed a somehow modified version.

Using a new downloaded one everything works just perfect.

PS: I AM at 0022, that comment probably was in the lib?
I ment, i am unable to test it now, because my arduino stuff is located elsewhere.

But thanks anyway, didn't expect the mistake in the lib
9  Using Arduino / Programming Questions / Code wont compile - Noob question! on: September 18, 2011, 05:54:30 am
Hi, this is probably very simple, so i hope someone will take a minute and correct my code ;D

Unfortunately i am currently unable to test it with hardware, but need to have the code finished before.
Its intended to simply control a RC car driving with only 2 wheels (third one moves in all directions) based on the input of an nunchuck joystick, whose values are read with the standard nunchuck_funcs.h

Since this is one of my first sketches, its probably a structure error, but if there is an error in the logic, too, i appreciate any improvements/corrections  smiley

Some parts are unnecessary, i know, and i've checked if its caused by a missing bracket, but didn't find any.
The idea is, that the robot turns on the spot when x = max or min and y = 0
Code:
#include <math.h>
#include <Wire.h>
#include "nunchuck_funcs.h"

// Motor part ---------------------
int out_A_pwm = 3; //pwm of motor A, when low, motor stops (or on both inputs low)
int out_A_in_1 = 9; // If high and Input2 low, then CCW
int out_A_in_2 = 8; // If high and Input1 low, then CW

int out_B_pwm = 3; //pwm of motor B
int out_B_in_1 = 9;
int out_B_in_2 = 8;

int out_stby = 12;

// Steering Part -------------------
int tolerance = 2;
float angle = 0;
float angle_temp = 0;
float speed_factor = 0;
float angle_speed_factor = 0;

int default_joyx = 130;
int default_joyy = 130;
int x = 0;
int y = 0;

//----------------------------------
void setup() {
  Serial.begin(9600);
  // nunchuck_setpowerpins();
  nunchuck_init(); // send the initilization handshake

  // Motor part ----------------
  pinMode(out_A_pwm,OUTPUT);
  pinMode(out_A_in_1,OUTPUT);
  pinMode(out_A_in_2,OUTPUT);

  pinMode(out_B_pwm,OUTPUT);
  pinMode(out_B_in_1,OUTPUT);
  pinMode(out_B_in_2,OUTPUT);

  pinMode(out_stby,OUTPUT);
  digitalWrite(out_stby,HIGH);
}
//------------------------------------
void loop(){
  delay(20);
  nunchuck_get_data();

  Serial.print(nunchuck_joyx());
  Serial.print(" | ");  
  Serial.print(nunchuck_joyy());
  Serial.print(" || ");  

  Serial.print((int)nunchuck_accelx());
  Serial.print(" | ");  
  Serial.print((int)nunchuck_accely());
  Serial.print(" | ");  
  Serial.println((int)nunchuck_accelz());

  // Motor Part

  // Set x and y as total values referring to middle
  if (nunchuck_joyx() < default_joyx){
    x = default_joyx - nunchuck_joyx();
  }else{
    x = nunchuck_joyx() - default_joyx;
  }
  if (nunchuck_joyy() < default_joyy){
    y = default_joyy - nunchuck_joyy();
  }else{
    y = nunchuck_joyy() - default_joyy;
  }
  
  // stop both motors if y/x is in default pos +/- 2
  if ((nunchuck_joyy() > (default_joyy - tolerance)) && (nunchuck_joyy() < (default_joyy + tolerance)) && (nunchuck_joyx() > (default_joyx - tolerance)) && (nunchuck_joyx() < (default_joyx + tolerance))){
    digitalWrite(out_A_in_1,LOW);
    digitalWrite(out_A_in_2,LOW);
    analogWrite(out_A_pwm, 0);

    digitalWrite(out_B_in_1,LOW);
    digitalWrite(out_B_in_2,LOW);
    analogWrite(out_B_pwm, 0);
  }else{
    //gets angle seen from forward direction in gon
    angle = atan(x/y)/360*400;
    if ((nunchuck_joyx() > default_joyx) && (nunchuck_joyy() < default_joyy)) angle += 100;  //if point is in quarter 2
    if ((nunchuck_joyx() < default_joyx) && (nunchuck_joyy() < default_joyy)) angle += 200; //if point is in quarter 3
    if ((nunchuck_joyx() < default_joyx) && (nunchuck_joyy() > default_joyy)) angle += 300; //if point is in quarter 4
    // value to be multiplied with the final pwm values
    speed_factor = pow(sq(x) + sq(y), 0.5) / (default_joyx + default_joyy) / 2;
    
    // Direction:
    // Speed of A
    if ((angle > 150) && (angle < 350)){ //drive forward
      digitalWrite(out_A_in_1,LOW);
      digitalWrite(out_A_in_2,HIGH);
    }else{
      digitalWrite(out_A_in_1,HIGH); //drive backward
      digitalWrite(out_A_in_2,LOW);      
    }  
    // Speed of B
    if ((angle > 50) && (angle < 250)){ //drive forward
      digitalWrite(out_B_in_1,LOW);
      digitalWrite(out_B_in_2,HIGH);
    }else{
      digitalWrite(out_B_in_1,HIGH); //drive backward
      digitalWrite(out_B_in_2,LOW);      
    }    
    calc_speed(0); // Set Speed of A
    calc_speed(100); // Set Speed of B
  }
}

void calc_speed(int other_motor){
  if (((angle > (0 + other_motor)) && (angle < (100 + other_motor))) || ((angle > (200 + other_motor)) && (angle < (300 + other_motor)))){
    // Fixed Speed
    if (other_motor = 0){
      analogWrite(out_A_pwm, (255 * speed_factor));
    }else{
      analogWrite(out_A_pwm, (255 * speed_factor));
    }
  }else{
    // var Speed
    
    // to get it between 0 and 100 instead of 100 and 200
    angle_temp = angle - (100 - other_motor);
    // in order to calc var speed in one step (if angle is in 4th quarter, it will move it to 1st)
    if ((angle > (300 - other_motor)) && (angle < (400 - other_motor))) angle_temp -= 300;
    // 50 is the point, when the direction inverts. like this it takes me only one calc step
    if (angle_temp > 50) angle_temp = 100 - angle_temp;
    // "1 -" inverts percentage, so that the speed will slow along with an increasing angle_temp
    angle_speed_factor = 1 - (angle_temp / 50);
    if (other_motor = 0){
      analogWrite(out_A_pwm, (255 * speed_factor * angle_speed_factor));  
    }else{
      analogWrite(out_B_pwm, (255 * speed_factor * angle_speed_factor));
    }
  }
}

Nunchuck functions
http://todbot.com/blog/2008/02/18/wiichuck-wii-nunchuck-adapter-available/

I use the normal motor driver from Sparkfun
http://www.sparkfun.com/products/9457

These are the errors:

Quote
In file included from SpyPhone.cpp:6:
nunchuck_funcs.h:29: error: variable or field 'nunchuck_init_with_power_pins' declared void
nunchuck_funcs.h:29: error: 'byte' was not declared in this scope
nunchuck_funcs.h:29: error: 'byte' was not declared in this scope
/nunchuck_funcs.h: In function 'void nunchuck_init_with_power()':
nunchuck_funcs.h:42: error: 'PC3' was not declared in this scope
nunchuck_funcs.h:42: error: 'PC2' was not declared in this scope
nunchuck_funcs.h:42: error: 'nunchuck_init_with_power_pins' was not declared in this scope
/nunchuck_funcs.h: In function 'int nunchuck_get_data()':
nunchuck_funcs.h:68: error: 'delay' was not declared in this scope
/nunchuck_funcs.h: In function 'void nunchuck_print_data()':
nunchuck_funcs.h:122: error: 'Serial' was not declared in this scope
nunchuck_funcs.h:122: error: 'DEC' was not declared in this scope
The errors in the nunchuck library have to be caused somehow by my sketch

Any help is greatly appreciated!
Flok3r
10  Using Arduino / Programming Questions / RFID Tag Reader on: July 23, 2011, 05:15:45 am
Hi,
My first project and my first post here  smiley-wink

I bought a TWT2021 at Conrad:

http://shop.conrad-uk.com/1/2-a1-uk0191553__191553-universal-rfid-antenna-c-control-twt2021-.html

Datasheet:

http://www.produktinfo.conrad.com/datenblaetter/175000-199999/191553-an-01-en-TOWITEK_UNIVERSAL_RFID_ANTENNE_C_CONTROL.pdf

And somehow i dont manage to get it working. The tag is fine, Arduino (UNO) works and i ve tried this code for example, but simple rx to tx, too:

Code:
void setup() {
  Serial.begin(9600);                                 // connect to the serial port
}

void loop () {
  byte i = 0;
  byte val = 0;
  byte code[6];
  byte checksum = 0;
  byte bytesread = 0;
  byte tempbyte = 0;

  if(Serial.available() > 0) {
    if((val = Serial.read()) == 2) {                  // check for header
      bytesread = 0;
      while (bytesread < 12) {                        // read 10 digit code + 2 digit checksum
        if( Serial.available() > 0) {
          val = Serial.read();
          if((val == 0x0D)||(val == 0x0A)||(val == 0x03)||(val == 0x02)) { // if header or stop bytes before the 10 digit reading
            break;                                    // stop reading
          }

          // Do Ascii/Hex conversion:
          if ((val >= '0') && (val <= '9')) {
            val = val - '0';
          } else if ((val >= 'A') && (val <= 'F')) {
            val = 10 + val - 'A';
          }

          // Every two hex-digits, add byte to code:
          if (bytesread & 1 == 1) {
            // make some space for this hex-digit by
            // shifting the previous hex-digit with 4 bits to the left:
            code[bytesread >> 1] = (val | (tempbyte << 4));

            if (bytesread >> 1 != 5) {                // If we're at the checksum byte,
              checksum ^= code[bytesread >> 1];       // Calculate the checksum... (XOR)
            };
          } else {
            tempbyte = val;                           // Store the first hex digit first...
          };

          bytesread++;                                // ready to read next digit
        }
      }

      // Output to Serial:

      if (bytesread == 12) {                          // if 12 digit read is complete
        Serial.print("5-byte code: ");
        for (i=0; i<5; i++) {
          if (code[i] < 16) Serial.print("0");
          Serial.print(code[i], HEX);
          Serial.print(" ");
        }
        Serial.println();

        Serial.print("Checksum: ");
        Serial.print(code[5], HEX);
        Serial.println(code[5] == checksum ? " -- passed." : " -- error.");
        Serial.println();
      }

      bytesread = 0;
    }
  }
}

Its from here:
http://www.arduino.cc/playground/Code/ID12

And what do i receive? Nothing  smiley-confuse
Neither at 3.3 v, nor at 5, though i measure an output voltage at the serial cable of the RFID reader, so it has to be something softwaresided.

As usual considering posts of newbees it probably will be a simple thing, but i cant figure out, what is missing and would appreciate any help  smiley-grin

Now i wish, i would have bought an ID12 or 20..

PS: Somewhere in the datasheet i read something about the need of a max232 inverter in order to connect the module to rs232, which is not necessary for the id-series.
Could that be the mistake?

Thanks, Greets, Flok3r
11  Using Arduino / General Electronics / Re: Guidance: Diy Electronical muscle stimulator on: June 05, 2011, 01:13:56 am
Wow, thanks, didnt know that these things are sold at this name too.. seems like i didnt search that good, sorry smiley-roll-sweat
But i think ill buy one of these for such a low price to see, whats going on inside.
Thank you for taking the time picking up these links  smiley
12  Using Arduino / General Electronics / Re: Guidance: Diy Electronical muscle stimulator on: June 04, 2011, 04:06:26 am
Hm, i expected that it is probably too dangerous, its a pity, because good ems's are very expensive.
But - for other purposes - im still interested, what capacitor to use and how.
Anyone knows these electrical fly paddles/rackets?
Electro shockers in general, how much current and voltage?
13  Using Arduino / General Electronics / Guidance: Diy Electronical muscle stimulator on: June 04, 2011, 01:28:22 am
Hi, my first post here in this great community! smiley-grin
Id like to build such a device on my own and actually it seems quite simple: a few capacitor and electrodes connected to them..
But which capacitors for 5v source (like arduino) and what current?
And how to adjust the output? by changing frequency or current/voltage?

In general this should work like a real EMS but i havent found much information on how they work in the www.
Perhaps you could help me out?  smiley

Thanks in advance,
Flok3r
Pages: [1]