Loading...
  Show Posts
Pages: [1] 2 3 ... 11
1  Using Arduino / Microcontrollers / Re: Question for Nick Gammon on: March 05, 2013, 01:33:53 pm
The chip is running 8Mhz from the internal clock

Based on your comments, I changed board for the LilyPad Arduino w/ ATmega328 (8MHz)
and all is well  smiley 

Thanks for your help
2  Using Arduino / Microcontrollers / Question for Nick Gammon on: March 05, 2013, 12:02:34 pm
Hi Nick,

I made a 328P-PU Arduino compatible minimal board based on your super tutorial
http://www.gammon.com.au/forum/?id=11637

I uploaded:
 - "board detector" sketch
 - bootloader programming sketch (8 MHz without a crystal)
Everything went well and I finally loaded up the basic Blink example

...
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(2000);               // wait for 2 seconds
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(2000);               // wait for 2 seconds
...

The LED turn ON for 4 seconds and OFF for 4 seconds
What am I doing wrong ??
Is it related to the 8 MHz clock ??

Thanks for your assistance
3  Using Arduino / Sensors / Re: MPU6050 SparkFun Breakout to Arduino Uno - No Communication on: July 30, 2012, 01:25:06 pm
Thanks,

Rechecked voltage: 3.32V   
go figure  smiley-roll-blue   I should add some water in my Bordeaux...

I will put additional resistors on SDA and SCL, on the Arduino side
I guess the original 10K's are OK when more sensors are added to the I2C Bus
4  Using Arduino / Sensors / Re: MPU6050 SparkFun Breakout to Arduino Uno - No Communication on: July 29, 2012, 02:23:45 pm
Answering partially my own questions
Not familiar with SMD  smiley-roll
The black components with 3 digits are actually resistors (http://www.hobby-hour.com/electronics/3-digit-smd-resistors.php)
331: 330 ohms
103: 10K
472: 4.7K

So, two 10K pull up resistors
Google is definitly your best friend  smiley-wink  smiley-wink

btw, this board can be had for 15 bucks shipped (Google ...)
5  Using Arduino / Sensors / Re: MPU6050 SparkFun Breakout to Arduino Uno - No Communication on: July 27, 2012, 12:04:45 pm
Hi Krodal,

Thanks for your very informative playground article
I bought a GY-52 breakout board which seems rather similar to yours (same manufacturer):



I connected as follow:
VCC - 5V
GND - GND
SCL - A5
SDA - A4

and loaded your code http://arduino.cc/playground/Main/MPU-6050
Amazingly enough, it worked first time

Now, I try to understand why it works  smiley-razz  smiley-razz
No additional pull up resistors on SDA/SCL
ADO seem to be pulled down (0X68)

Would you mind checking your onboard regulator output, mine is 4.3V with 5V or 3.3V supply
according to datasheet, seems a bit high
Please check the above photo for possible pullup resistors

My final project is a new/better Balancing Robot http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1284738418

Thanks again for this great job
6  Forum 2005-2010 (read only) / Exhibition / Re: Balancing robot for dummies on: January 16, 2011, 07:10:19 am
I am better at photo than video  smiley-wink
7  Forum 2005-2010 (read only) / Exhibition / Re: Balancing robot for dummies on: January 16, 2011, 01:33:28 am
..........   continued


       [size=14] ** Balancing robot for dummies **[/size]


[size=14]Part seven: Xbee wireless control, KasBot V 3.0[/size]



[size=14]2) Robot side:[/size]

On the bot side, the Xbee module is set as per post #107

The datastream is decoded within getMotion()
Code:
void getMotion() {
  if(!Serial.available())      return;
  delay(5);                  
  int controlByte = Serial.read();              // get control byte
  if(!Serial.available())      return;
  int dataByte_1 = Serial.read();               // get data byte 1
  if(!Serial.available())      return;
  int dataByte_2 = Serial.read();               // get data byte 2
  Serial.flush();                                
 
  if(controlByte == 'd')   {                    // Nunchuk joystick data
    setPoint = -(dataByte_1 - 20)/2;          // get forward/backward motion byte
    if(abs(setPoint) > 2)  {
      count = 0;
      last_count = 0;
    }
    turn = (dataByte_2 - 20);                   // get right/left motion byte
  }  else    bip(bipPin, 10, 1);                  // wrong header
}

setPoint is used to bias updatePid() and slithly move the bot from vertical, thus initiating the move

Code:
void loop() {
// ********************* Get Xbee data *******************************
  getMotion();

// ********************* Sensor aquisition & filtering ***************
.....

// *********************** Angle Control and motor drive *************
  drive = updatePid(setPoint, actAngle);                                // PID algorithm

  if(abs(actAngle) < 100)    {
    Drive_Motor(drive);
  }  else {  
    Drive_Motor(0);                                                    // stop motors if situation is hopeless
    setZeroIntegal();                                                  // reset PID Integral accumulaor
  }
// ********************* print Debug info ****************************
.....

// *********************** loop timing control ***********************
.....

}


turn becomes a new parameter in Drive_Motor(), to allow right and left motor to run at their own speed
Code:
int Drive_Motor(int torque)  {
  if (torque + turn >= 0)  {                                          // drive motors forward
    digitalWrite(InA_R, LOW);                        
    digitalWrite(InB_R, HIGH);
    torque_R = torque + turn;
    if (torque - turn >= 0)  {                                        // drive motors forward
      digitalWrite(InA_L, LOW);                    
      digitalWrite(InB_L, HIGH);
      torque_L = torque - turn;
    }  else  {
      digitalWrite(InA_L, HIGH);                      
      digitalWrite(InB_L, LOW);
      torque_L = abs(torque - turn);
    }
  }  else {                                                           // drive motors backward
    digitalWrite(InA_R, HIGH);                      
    digitalWrite(InB_R, LOW);
    torque_R = abs(torque + turn);
     if (torque - turn >= 0)  {                                       // drive motors forward
      digitalWrite(InA_L, LOW);                    
      digitalWrite(InB_L, HIGH);
      torque_L = torque - turn;
    }  else  {
      digitalWrite(InA_L, HIGH);                      
      digitalWrite(InB_L, LOW);
      torque_L = abs(torque - turn);
    }
 }
  torque_R = map(torque_R,0,255,K_map,255);
  torque_L = map(torque_L,0,255,K_map,255);
  torque_R = constrain(torque_R, 0, 255);
  torque_L = constrain(torque_L * motor_Offset, 0, 255);
  analogWrite(PWM_R,torque_R);
  analogWrite(PWM_L,torque_L * motor_Offset);                      // motors are not built equal...
}


OK guys, this is probably my last significant contribution to this thread  :-/
I suddently realize that I have a real life and... some other projects to explore  :smiley :smiley

I am sure this thread will keep on, with new bright ideas coming on
What about non linear control ??
What about one wheeled bot as shown by Big Oil ??

"...Two wheeled balancing robots are an area of research that may well provide the future locomotion for everyday robots..."

I really enjoyed all these discussions we had on this common project
Thanks again to everybody for reading and contributing   smiley smiley smiley

8  Forum 2005-2010 (read only) / Exhibition / Re: Balancing robot for dummies on: January 15, 2011, 06:12:19 am
       [size=14] ** Balancing robot for dummies **[/size]


[size=14]Part seven: Xbee wireless control, KasBot V 3.0[/size]

The objective is to obtain basic motion control (Forward/Backward, Stop Right/Left)
Xbee modules act as a serial line replacement, a USB cable without the cable smiley
See post #82 for more info


[size=14]1) controller side:[/size]

Shopping list at post #77
Transmitter with Nunchuck joystick controller is shown on post #107
The additional micro joystick and the 3 LED's will be used for advanced features wich are beyong the scope of this basic KasControl V1.0

Nunchuk_kas.h does take care of the I2C communication with the joystick
Code:
// Nunchuck_kas.h        joystick functions ----------------------------------------------------------------

#include "Wprogram.h"
#include <Wire.h>

static uint8_t nunchuck_buf[6];                             // array to store nunchuck data,

void nunchuck_init()  {
  Wire.begin();                                                  // join i2c bus as master
  Wire.beginTransmission(0x52);                                  // transmit to device 0x52
  Wire.send(0x40);                                        // sends memory address
  Wire.send(0x00);                                        // sends a zero.  
  Wire.endTransmission();                                  // stop transmitting
}

void nunchuck_send_request()  {                             // Send a request for data to nunchuck
  Wire.beginTransmission(0x52);                                  // transmit to device 0x52
  Wire.send(0x00);                                        // sends one byte
  Wire.endTransmission();                                  // stop transmitting
}
 
char nunchuk_decode_byte (char x)  {                         // Encode data to format that most wiimote drivers
  x = (x ^ 0x17) + 0x17;                                     // except only needed if you use one of the regular
  return x;                                                  // wiimote drivers
}

int nunchuck_get_data()  {                                   // Receive data back from the nunchuck
  int cnt=0;
  Wire.requestFrom (0x52, 6);                                  // request data from nunchuck
  while (Wire.available ()) {                               // receive byte as an integer
    nunchuck_buf[cnt] = nunchuk_decode_byte(Wire.receive());
    cnt++;
  }
  nunchuck_send_request();                                  // send request for next data payload
  if (cnt >= 5)     return 1;                               // If we recieved the 6 bytes, then go print them
  return 0;                                                 // failure
}                                                           // returns 1 on success read, returns 0 on failure

int nunchuck_joyx()  {                                     // returns value of x-axis joystick
  return nunchuck_buf[0];
}

int nunchuck_joyy()  {                                     // returns value of y-axis joystick
  return nunchuck_buf[1];
}
This is a strip down version of the code that can be found in the Arduino Playground section.
We only use the joystick data, (we have enough accelerometers in this project  smiley-wink)
More info on wiring and code here

The main code uses a communication protocol based on 3 Bytes:
   controlByte = 'd'      (just says "hey, I am coming with new joystick data !!")
   dataByte_1 = value of y-axis joystick
   dataByte_2 = value of x-axis joystick

To reduce traffic, data is only sent when joystick is moved
Code:
// ** Kas Control V10     Balancing bot RC with nunchuk **  

// Yellow: Clock SCL (AI5)  Red: 3.3V  Green: Data SDA(AI4)  Write: Ground
// serial data format:   <controlByte> <dataByte_1> <dataByte_2> <CR>
// V1.0 basic control

#include <Wire.h>
#include "Nunchuck_kas.h"

int refreshTime = 100;                                    // time in millisecs between Nunchuck poolings
long lastPulse = 0;
char controlByte = 0;
char dataByte_1 = 0;                                      // joystick data
char dataByte_2 = 0;

void setup()  {
  Serial.begin(19200);
  nunchuck_init();                                         // send the initilization handshake
  delay(100);
  nunchuck_joyx();
  nunchuck_joyy();
}

void loop()  {
  if (millis() - lastPulse >= refreshTime) {                // x ms have passed
    checkNunchuck();
    lastPulse = millis();                                   // save the time of last pulse
  }
}

void checkNunchuck()  {
  static int Byte1_ant, Byte2_ant;
  nunchuck_get_data();
  controlByte = 'd';
  dataByte_1 = map(nunchuck_joyy(), 27, 218, 0, 40);        // nunchuck joystick North/South                    
  dataByte_2 = map(nunchuck_joyx(), 27, 218, 0, 40);        // nunchuck joystick East/West
  dataByte_1 = constrain(dataByte_1, 0, 40);                                
  dataByte_2 = constrain(dataByte_2, 0, 40);
  if((dataByte_1!=Byte1_ant)||(dataByte_2!=Byte2_ant))  {
    updateBot();
    Byte1_ant = dataByte_1;
    Byte2_ant = dataByte_2;
  }
}

void updateBot()    {                                       // send data stream
    Serial.print(controlByte);        
    Serial.print(dataByte_1);    
    Serial.print(dataByte_2);
    Serial.print("\n");
}

...........

9  Forum 2005-2010 (read only) / Exhibition / Re: Balancing robot for dummies on: January 15, 2011, 05:47:26 am
Hi prof_jazz, welcome  smiley
please let us have a photo of your new pet

Quote
I used 6V HITEC HS-325HB hacked to run continuosly, but this motors are not enough for he job they have to do
I also waste one year following this track  smiley-wink

Quote
(1) in the setup, with the function calibrateSensors(); you have to put the robot (each time you switch it on) exactly in the static equilibrium position in order to evaluate zero values (exept for z).
is this a little bit boring and could produce errors (if it is not perfectly perpendicular)?
If during the calibrateSensors() i'll give a tilt, the Robot will work to keep the tilt!
No No...
If you tilt the bot forward before calibrateSensors(), it will move forward and find a vertical equilibrium
This will happen only with encoder(s) implementation, look here

Quote
(2) what do You use to recharge the 12V batteries?
I ordered the battery charger shown here



10  Forum 2005-2010 (read only) / Exhibition / Re: Balancing robot for dummies on: January 14, 2011, 10:29:07 am
08:16 14/01/2011
@Osmaneram
Nice bot  smiley
I played with a MPC3208 ADC which is the 8 input version
As far as I remember, those are 12 bit ADC's with 4096 units (not 8096)  :o
Please clarify

Your IMU board may have a different noise pattern that may require specific Kalman filter tuning.
The ADC should not inpact Kalman tuning (it didn't on my setup)



@Ro-Bot-X
I am also tempted to go digital for several reasons
 - analogic is noisy by nature
 - additional features
 - this is the future...

I2C frequency is in the 100KHz range, don't be affraid
Please try it and let us know the outcome, we all need guinea pigs  smiley-wink smiley-wink
 

11  Forum 2005-2010 (read only) / Exhibition / Re: Balancing robot for dummies on: January 14, 2011, 06:33:01 am
Quote
I got my hands on a free L298N H-Bridge: http://www.st.com/stonline/books/pdf/docs/1773.pdf
Unfortunately it only can handle spikes of 3 A (repetitive 2.5 A). Did you ever get an idea of what currents are used? I plan on making the bot relatively small...
I would take the motor stall current as the H-bridge amp requirement

Quote
Also, have you ever run into speed problems from the microcontroller? Is 16 MHz fast enough?
16 MHz is fast enough

Quote
My understanding was that the sensors act as the feedback to tell the motors direction and speed, so a motor encoder is not necessary. I see you made the same statement in your initial post.
You will get "basic" balance w/o encoders, but the bot will drift forward/backward




Quote
I have now gotten my BlueSmirf and the other parts I was missing to be able to complete my bot.
...
I will post some images and a video on the interface and robot in the end of the week hopefully..
Congratulation Patrik
I will also post my XBee version this week end smiley-wink smiley-wink



12  Forum 2005-2010 (read only) / Exhibition / Re: Balancing robot for dummies on: January 11, 2011, 05:01:20 am
Hi BrianBot,
Welcome and good luck for your project  smiley

Looking at your shopping list, I have the following comments:
motor controller shield:
This device will definitly not cope with the amperes needed to feed your motors  :-?
Look here (initial post)

motors & wheels:
The wheels are wide and soft, which is good for balancing
Wheel diameter could be higher
You need encoders (at least one). How will you afix them ??

Quote
My instructor seems to think there will be problems with different torques of each motor.
How much validity is in that?
This is addressed with the second encoder

Feel free to document you project here
This thread is now very visible from Google, this is convenient for discussion with non Arduino jerks
13  Forum 2005-2010 (read only) / Exhibition / Re: Balancing robot for dummies on: January 10, 2011, 05:05:01 am
Quote
hello.
I'm looking for the kasBot v2.0 code, involving quadrature encoders. Couldn't find it on the "official" site.
Can you help me?

Andreas
Norway
Hi Andreas,
Sorry for that, I will send it today to Patrik for posting in his blog
http://www.x-firm.com/?page_id=145
14  Forum 2005-2010 (read only) / Exhibition / Re: Balancing robot for dummies on: January 09, 2011, 03:55:41 am
Quote
What do you think about it so far?
Possible options for speeding the transmital process:
 - reduce number of parameters to be tansmitted
 - transmit parameter only when value have changed
 - if you have 50 data to transmit, split the information and try sending 10 values per cycle.
    all info will be passed within 5 cycles = 500ms, which is acceptable
 - Combine these options
15  Forum 2005-2010 (read only) / Exhibition / Re: Balancing robot for dummies on: January 08, 2011, 03:23:51 pm
Hi bryanpearson
Welcome to this thread,
no doubt Patrik will soon jump in to answer your question


@Patrik
Quote
Quote
What do you think about that? And in your opinion what baud rate should we use if possible?
I will experiment and be back by the end of the week
I ran this (really  smiley-wink) striped down version of KasBot

Code:
int   STD_LOOP_TIME  = 9;            
int lastLoopTime = STD_LOOP_TIME;
int lastLoopUsefulTime = STD_LOOP_TIME;
unsigned long loopStartTime = 0;

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

void loop() {
// ********************* print Debug info ********************************
  Serial.println("The quick brown fox jumps over the lazy dog");
  Serial.println("The lazy dog doesn't care and keep sleeping");
  Serial.print("Loop:");        Serial.print(lastLoopUsefulTime);
  Serial.print(",");            Serial.println(lastLoopTime);
  Serial.println();

// *********************** loop timing control **************************
  lastLoopUsefulTime = millis()-loopStartTime;
  if(lastLoopUsefulTime<STD_LOOP_TIME)         delay(STD_LOOP_TIME-lastLoopUsefulTime);
  lastLoopTime = millis() - loopStartTime;
  loopStartTime = millis();
}

The results (lastLoopUsefulTime) are, as expected, inversely proportional to the Serial data speed

9600             110 ms
19200             54 ms
38400             27 ms
57600             18 ms
115200             9 ms

Interestingly enough, 28800 bps doesn't work on my system
I used a Diecimila board powered by an ATmega168,
So try using 115200 bps, but YMMV.

Is it related with the lag observed by bryanpearson ??


@ GuzZzt
Quote
... It looks complicated...
It does  :o :o
Pages: [1] 2 3 ... 11