My first run with the shapeoko

Posted in Arduino, CNC, GRBL, Milling on November 2nd, 2012 by x-firm – Comments Off

My first run with the shapeoko without any problem except that I have only one stepper controller. I hope I get the other two soon so i can start milling something.

My Shapeoak is finally here

Posted in CNC, Milling on July 28th, 2012 by x-firm – Comments Off

I bought an Shapeoko CNC kit from Inventables for a couple of month ago and it has finally arrived.

It was a real nice black sealed package from Inventables as you can see below.

The first thing you see inside the package is an personal not from Edward Ford the inventor of the Shapeoak.

All parts seamed to be inside the package.

I can’t wait to starting to build it together…

More images

First little project with the Beaglebone

Posted in Arduino, Beaglebone on July 23rd, 2012 by x-firm – Comments Off

I would like to connect an Arduino to the Beaglebone true its USB host port to let the Arduino do all low level stuff. I thought it could not be that hard :) and after some trying it turned out it wasn’t.

I loaded the example sketch ASCII table by Tom Igoe that prints out byte values in all possible formats true the serial port of the arduin. If i could get that to print out in the console or in some serial console for linux.

But first I did’nt know what the device file would be named for an usb to serial adapter on the Beagelbone. So I plugged in my Arduino and  used the command dmesg | tail to see what happened.


root@beaglebone:~# dmesg | tail
[  712.471055] usb 1-1: SerialNumber: 64932343738351312182
[  712.471901] cdc_acm 1-1:1.0: ttyACM0: USB ACM device
[  961.711404] usb 1-1: USB disconnect, device number 5
[  963.279604] usb 1-1: new full-speed USB device number 6 using musb-hdrc
[  963.420999] usb 1-1: New USB device found, idVendor=2341, idProduct=0001
[  963.421019] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=220
[  963.421032] usb 1-1: Product: Arduino Uno
[  963.421043] usb 1-1: Manufacturer: Arduino (www.arduino.cc)
[  963.421054] usb 1-1: SerialNumber: 64932343738351312182
[  963.421916] cdc_acm 1-1:1.0: ttyACM0: USB ACM device
root@beaglebone:~#


So now when I know that I need to communicate with it and I found out that there are an serial console program called minicom in the Ångström distribution that I use on my Beaglebone. It seamed easy to use so I started up minicom in setup mode by the following command

root@beaglebone:~# minicom -s

Than I change the settings in minicom to use ttyACM0 as port and also change the boud rate to 9600.

Then I exit the setup menu and as soon I press the Arduino reset button it prints out the ASCII table as it should.
I think for the next step I will try to get an node.js script talking to the arduino and print out the result to the console.

I googled some and found this sites about communication with an arduino true node.js

And also an serial library for node.js that most use

I have now gotten my hands on an Beaglebone

Posted in Beaglebone on July 22nd, 2012 by x-firm – Comments Off

I love this little thing, it was really easy to get it started and playing with it but you will soon find out that there are not so much information regarding the Beaglebone yet.

Here is some information:

The Beagle Bone is a great step up from microcontrollers (such as AVR, PIC, ARM Cortex M3, 8051, Propeller, etc) to microcomputers. Unlike a microcontroller, where the FLASH, EEPROM, RAM, etc is all in one chip, a microcomputer has them separated out, like a classic computer such as a desktop or laptop machine. The Beagle Bone has a main processor core running at 700MHz, a chunk of 256M DDR RAM, and permanent storage onto a microSD card. This makes for a powerful machine, that has no problems running Linux, a webserver, Python, FTP clients, SSH, etc.

The Bone also has great accessories built in, such as onboard Ethernet with 10/100M connectivity, mini USB port with TTL serial converter, JTAG debugger for advanced hacking, USB A host port for connecting a hub/WiFi/etc, power management IC that keeps the board safe from a misplugged adapter, and tons of 0.1″ spaced breakouts

One of the powerful abilities of the Bone is that it has I2C, SPI, and GPIO at a hobbyist-friendly 3.3V level (instead of the more difficult to interface 1.8V) while also running complex applications such as a webserver. This allows for more complex projects that would tax an Arduino.

I noticed some thing was wrong when I should try to use Cloud9 and the Bonescript to play around with some of the in and outputs. I got some nasty compiler errors when I tried to run an node.js script, I found some information about the factory flashed image you get with the Beaglebone cane some times be damaged.

So I wanted to load a new image on the flash card but all information an how to do that was for linux. But i found this site where there ware an step by step guide for windows and also the latest image released with the revision A6 of the Beagelbone.  After that everything worked good.

Some good links:

http://beagleboard.org/static/beaglebone/latest/README.htm

http://learn.adafruit.com/beaglebone

http://circuitco.com/support/index.php?title=BeagleBone

http://webcache.googleusercontent.com/search?q=cache:fgiHs41mhDcJ:www.gigamegablog.com/2012/01/05/beaglebone-coding-101-blinking-an-led/+&cd=1&hl=en&ct=clnk

https://plus.google.com/104712705716996155416/posts

http://borderhack.com/?p=1062

http://www.unixguide.net/linux/linuxshortcuts.shtml (General linux guide)

New code for the motor part of the X-bot

Posted in Arduino, Processing, Self balancing robot on April 22nd, 2011 by x-firm – Comments Off

I have recoded the motor part and added the encoder for the other motor and made a PID for each motor that takes the output from the current PID. This for trying to get the two motors to behave equal. The original PID is only looking on the right motor encoder as before. But I’m calculating the current speed in pulses/10ms for each motor and then using that and the output from the old PID to control the motors for a requested speed in pulses/10ms..

That feels better than just sending a value of 0-255 that has no connection to the speed of the motor that are depending on the surface and battery level.

I have made a new sketch for the bot and a GUI to make settings and testing the motor PIDs you can download it from this links:
Motor_PID_Enc_v2 (Bot code)
Motor_PID_Enc_v2 (GUI)

Nice balancing bot controlled by a WiiMote

Posted in Arduino, Self balancing robot on April 6th, 2011 by x-firm – Comments Off

Found a nice robot that was built and programed using parts of the Balancing Robot For Dummies guide. A nice looking bot..

The most interesting is that he has the WiiMote connected directly to the Arduino true a USB HID shield.. Instead of having both the bot and the WiiMote connected to a computer that acts as a gateway..

More information here..

My first attempt for Fuzzy Logics

Posted in Processing, Self balancing robot on February 2nd, 2011 by x-firm – Be the first to comment

I have now successfully created a fuzzy logic controller using Processing.

My test case was getting an object avoiding obstacles when given order to move to specific target..

You can try it here

The input variables was simple angle and distance.

Fuzzy sets for inputs:

Angel to obstacle:
smallAngle
mediumAngle
largeAngle

Distance to obstacle:
smallDist
mediumDist
largeDist

Instead of using linguistic rules I used something called FAMM(Fuzzy associative memory matrix) and that only work in a 2 input, 1 output scenario.

smallAngle mediumAngle largeAngle
smallDist 90° 55° 35°
mediumDist 55° 35° 25°
largeDist 35° 25° 5°

Then defuzzification is done true weighting the relationships in the FAMM..

I will improve some parameters of the controller and optimize it a little before I try It on my balancing robot..

Nice drawings of the Arduino UNO and Mega 2560

Posted in Arduino on January 10th, 2011 by x-firm – Be the first to comment

X-Bot v2

Posted in Self balancing robot on December 23rd, 2010 by x-firm – Be the first to comment

I have now started on a second version of my balancing bot do the first one was a little to heavy in my opinion. I will remove the breadbord from the robot and make everything more permanent installed on the bot.

I’m tired of being needed to unhook the batteries every time I just want to turn of the motor power..

So now there will be one switch for the logic and motor power and also a fuse on the motor power.

I have started with the body parts of the robot like you can see in the pictures below.

Middle plate

Bottom plate

Calibrating/testing the motors and encoders..

Posted in Arduino, Processing, Self balancing robot on November 24th, 2010 by x-firm – Be the first to comment

I started to check the differences of the motors by using the encoders to try to see the distance the motors turned in a constant time and get a factor for the diff. I drive the motors in both directions in four different speeds 50, 100, 200, 250..

I made a sketch for the Arduino and a GUI sketch in processing based on the Balancing Bot GUI, and thought that this cant be so hard to do just see the diff. and calculate a factor for the faster motor but that was not the case..

The first run gave me the results like in the image below, where the motors behaved very different in forward to backward motion. When going forward for a time constant(2000ms) and then sending the drive_motor(0) the motor continued running in free spin for a short while. But when running backward the motor brakes for a short while.

Click for larger image

Speed   L           R

255    7662   :  7413

-255   -5516  :  -5541

150    6582   :  6386

-150   -4901  :  -4872

50     3342     :  3291

-50    -2747   :  -2705

As you can see the behavior is very different in the two directions..

I changed the drive_motor function like below and tried again and the result was better but is I going about this in the right way?

int Drive_Motor(int torque)  {
  if (torque > 0)  {
    // drive motors forward
    digitalWrite(InA_R, LOW);
    digitalWrite(InB_R, HIGH);
    digitalWrite(InA_L, LOW);
    digitalWrite(InB_L, HIGH);
    forward = true;
  }else if(torque < 0) {     // drive motors backward
    digitalWrite(InB_R, LOW);
    digitalWrite(InA_R, HIGH);
    digitalWrite(InB_L, LOW);
    digitalWrite(InA_L, HIGH);
    torque = abs(torque);
    forward = false;
  }else{
    if(forward){
      digitalWrite(InA_R, HIGH);
      digitalWrite(InB_R, LOW);
      digitalWrite(InA_L, HIGH);
      digitalWrite(InB_L, LOW);
    }else{
      digitalWrite(InA_R, LOW);
      digitalWrite(InB_R, HIGH);
      digitalWrite(InA_L, LOW);
      digitalWrite(InB_L, HIGH);
    }
  }
  //if(torque>5) map(torque,0,255,30,255);
    analogWrite(PWM_R,torque * motorOffsetR);
    analogWrite(PWM_L,torque * motorOffsetL);
    Serial.println(torque,DEC);
}

Now it looks like the Arduino and the motor controller is behaving in the same way in both directions. I need to take some more readings to see if the differences that are left are linear in some way.. It feels like there are a difference between the motors in both directions but also that both motors are going faster forward, and that I think is created by the motor control??..

See image below..

Click for larger image

Heres the Arduino sketch I used..

Heres the Processing sketch I used..

The main part of the Arduino sketch:

// KasBot Encoder test V1  -  Main module       basic version, angles in Quids, 10 bit ADC
/*
  Description:
  The KasBot Encoder test Vx is made for checking that the encoder signal workes and
  to tune the diffrenses from your motors..

  This code is aimed for the Encoder test GUI v1.0

  Version log:

  v1.0  -

*/

#define   InA_R          6                      // INA right motor pin
#define   InB_R          7                      // INB right motor pin
#define   PWM_R          10                     // PWM right motor pin
#define   InA_L          8                      // INA left motor pin
#define   InB_L          9                      // INB left motor pin
#define   PWM_L          11                     // PWM left motor pin
#define encodPinA_R      3                      // encoder A pin left motor
#define encodPinB_R      5                      // encoder B pin right motor
#define encodPinA_L      2                      // encoder A pin left motor
#define encodPinB_L      12                     // encoder B pin right motor

#define LOOPTIME         100                    // PID loop time
#define FORWARD          1                      // direction of rotation
#define BACKWARD         2                      // direction of rotation

#define DELAY_TIME       5000                   //Time to delay after motion
#define RUN_TIME         2000                   //Time to run motor

int speeds[] = {50, 100, 200, 255};
int speedIndex = 0;

int STD_LOOP_TIME  =  9;             

int lastLoopTime = STD_LOOP_TIME;
int lastLoopUsefulTime = STD_LOOP_TIME;
unsigned long loopStartTime = 0;

unsigned long delayStart = 0;

long count_R = 0;                                 // rotation counter right motor
long count_L = 0;                                 // rotation counter left motor

boolean frwMotion = true;                         // motor moves

void setup() {
  pinMode(InA_R, OUTPUT);
  pinMode(InB_R, OUTPUT);
  pinMode(PWM_R, OUTPUT);
  pinMode(InA_L, OUTPUT);
  pinMode(InB_L, OUTPUT);
  pinMode(PWM_L, OUTPUT);

  pinMode(encodPinA_R, INPUT);
  pinMode(encodPinB_R, INPUT);
  digitalWrite(encodPinA_R, HIGH);                      // turn on pullup resistor
  digitalWrite(encodPinB_R, HIGH);
  attachInterrupt(1, rencoder_R, FALLING);

  pinMode(encodPinA_L, INPUT);
  pinMode(encodPinB_L, INPUT);
  digitalWrite(encodPinA_L, HIGH);                      // turn on pullup resistor
  digitalWrite(encodPinB_L, HIGH);
  attachInterrupt(0, rencoder_L, FALLING);

  Serial.begin(19200);
}

void loop() {
// ********* Simple motor test for serial monitor ***********************

  //motorDebugForSerialMonitor();

// *********************** Motor drive **********************************
  //Turns motors on for RUN_TIME and then off for DELAY_TIME
  if((millis() - delayStart) <= RUN_TIME){
    if(frwMotion){
      Drive_Motor(speeds[speedIndex]);
    }else{
      Drive_Motor((speeds[speedIndex] * (-1)));
    }
  }else if((millis() - delayStart) > RUN_TIME){
    Drive_Motor(0);
  }

  if((millis() - delayStart) >= (RUN_TIME + DELAY_TIME)){
    delayStart = millis();
    if(frwMotion){
      frwMotion = false;
    }else{
      speedIndex++;
      frwMotion = true;
    }
    clearCounts();
    if(speedIndex >= 3) speedIndex=0;
  }

 // *********************** print Debug info *****************************
  serialIn_GUI();       //Processing information from a pc
  serialOut_GUI();	//Sending information to pc for debug

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

}

void clearCounts(){
  count_L = 0;
  count_R = 0;
}

void motorDebugForSerialMonitor()
{
  Drive_Motor(255);
  delay(2000);
  Drive_Motor(0);
  delay(500);
  Serial.print(count_L,DEC);
  Serial.print(" : ");
  Serial.println(count_R,DEC);
  clearCounts();
  delay(4500);

  Drive_Motor(-255);
  delay(2000);
  Drive_Motor(0);
  delay(500);
  Serial.print(count_L,DEC);
  Serial.print(" : ");
  Serial.println(count_R,DEC);
  clearCounts();
  delay(4500);

  Drive_Motor(150);
  delay(2000);
  Drive_Motor(0);
  delay(500);
  Serial.print(count_L,DEC);
  Serial.print(" : ");
  Serial.println(count_R,DEC);
  clearCounts();
  delay(4500);

  Drive_Motor(-150);
  delay(2000);
  Drive_Motor(0);
  delay(500);
  Serial.print(count_L,DEC);
  Serial.print(" : ");
  Serial.println(count_R,DEC);
  clearCounts();
  delay(4500);

  Drive_Motor(50);
  delay(2000);
  Drive_Motor(0);
  delay(500);
  Serial.print(count_L,DEC);
  Serial.print(" : ");
  Serial.println(count_R,DEC);
  clearCounts();
  delay(4500);

  Drive_Motor(-50);
  delay(2000);
  Drive_Motor(0);
  delay(2000);
  Serial.print(count_L,DEC);
  Serial.print(" : ");
  Serial.println(count_R,DEC);
  clearCounts();
  delay(4500);

  while(true){delay(100);}
}