Pololu microstepping settings

Pololu stepper microstepping settings taken from pololu’s site.

 

MS1 MS2 MS3 Microstep Resolution
Low Low Low Full step
High Low Low Half step
Low High Low Quarter step
High High Low Eighth step
High High High Sixteenth step

Updating firmware on USBASP from eBay

I got a USBASP off of ebay over christmas, but when trying to use it, avrdude and arduino would complain about the sclock not being able to be set. After a while of looking it up online, I found out that the issue was with an old firmware, so after a little research, this is what I discovered and what I had to do to update it.

This guide is for linux, if you want a guide for windows, here’s one that is the equivalent of it:
http://www.rogerclark.net/?p=702

First, install the megaisp sketch on an arduino, then hook the arduino to usbasp by connecting the arduino’s pins, to the 10 pin header on the usbasp programmer, using this diagram to hook it up:

My connections were
 Arduino    USBASP
 5V ———– 2
 GND ——– 10
 13 ———— 7
 12 ———- 9 (MISO)
 11 ———- 1 (MOSI)
 10 ———  5 (RESET) 

Just make sure to have it unplugged from the usb port while doing all of this. Also, you’ll need to short the program pin, on mine, it was pin 2 but you may need to check yours to see what yours is. I used a piece of wire on mine shortly to short them together, just by putting the wire through the holes and wrapping the wire around the whole USBASP programmer.

Then try to use this command in the command prompt, if everything goes correctly, it’ll say something like “AVR: ready to accept commands” or something like that:

avrdude -c avrisp -P /dev/ttyACM0 -b 19200 -p m8 -v

If it complains about “AVR: not found” or something like that, then check your wiring, or check your programmer’s chip to make sure it has the ATMEGA8, and if not, change the “m8” to whatever chip is used.

If everything works fine and it is ready to accept the commands, you can download the updated firmware from the site. Here’s the link: http://www.fischl.de/usbasp/

Just download, extract, and use this command to update the firmware:

avrdude -c avrisp -P /dev/ttyACM0 -b 19200 -p m8 -U flash:w:usbasp.atmega8.2011-05-28.hex

If everything went according to plan, you should be able to just unplug the USBASP from the arduno and plug it into the computer , all ready to go.

Here is the one that I purchased and that the pinout worked on:

usbasp programmer

Also, if you have one of these, and you notice that it doesnt work sometimes, just unplug it and wait a few mins, then try again, mine tends to misbehave if you unplug it and plug it in a few times, I think mine just spazzes out sometimes.

Update

Well, tomorrow we leave for world makerfaire in new york. I havnt really posted much lately due to the fact that Ive been working on my new printer because of the printrbot jr’s printrboard (controller board) died. Ive been trying to get ahold of someone at printrbot to see if I can get a replacement, but so far, I havnt been able to get ahold of anyone through support tickets, or through private messages on the forums. I also tried contacting the head of printrbot on twitter because most people have said they had better luck of getting a response back from them on there, but it seemed like he just ignored the question. Maybe Im not sending the messages right or something on there, but it’s always worked with everyone else Ive ever tried it with. It’s waay too much of an expensive part to have to just toss the old one and get a new one when it’s not very old at all. (around 130-140 dollars for the board)

So Im just trying to figure out how to get the printrbot jr up and running again, and hoping I can get ahold of them to see if I can just get a replacement. Ive heard that thier warantee stuff is really good if you need something replaced, but I guess just getting ahold of them is the hardest part.

Ive decided not to go with the printrboard, sanguino, or ramps for my new printer, and instead, go for a gen7 board because of multiple reasons. Mainly, I just wanted to build the whole printer from scratch excluding the motors and maybe hotend, and I wanted to be able to really really customize the firmware and hardware myself for everything.

Ive decided on the gen7 1.4.1 rather than the 1.5 due to the fact that 1.5 has the usb chip built in, and eventually I want to do away with the usb chip entirely and use a level translator to convert the 3v signals to 5v and vise versa for hooking it directly up to the serial port on the raspberry pi, and just build the raspberry pi into the printer itself so it would have an all in one printer that I can just take with me and not have to worry about plugging in a bunch of power cords to get it to run. Just run the 5v from a pc power supply, and that’s all you need.

Like I said before, makerfaire is in two days, and Im already packed and ready to go, and will upload alot of pics from there. I saw that this year, eben upton from raspberry pi foundation will be there also showing off some of thier new hardware, and Im hoping that I’ll be able to get a pic or two with him also. Who knows, maybe Ill be able to show off that little hacked netbook running as a raspberry pi also 😛

Im hoping that the printrbot guys will be up there and see if I can just talk directly to them to get all of this sorted out. It’s been around a week since I sent in the support tickets and still havnt gotten a reply or anything from anyone, so maybe Ill just be able to ask up there. There’s still a good amount of parts needed to be printed out for my prusa, and cant, also I have a few other people wanting stuff printed also, so need to get it up and running asap.

Also, if anyone reads this site and knows the answer to this question, I’ll ask it here:

Ive seen people saying that they get disconnects using the ft232 chips and 3d printers due to the latency, but I also see other people using attiny chips or other usb-ttl converter chips, and I was wondering if the other chips have that issue, or if it’s just ft232 related. I only ask because for testing everything and getting everything set up, I wanted to use a pl2303x based converter that Im planning on making from an old dialup modem that I tore apart ages ago. Always better to repurpose something than toss it if you know you can use it for something. 😛

Program an Arduino using your sound card

Hackaday

audioino_programming_arduino_with_sound

[Chris] wrote us to share a neat technique he has been using to program the Arduinos he uses in his projects. He likes to build bare bones Arduino clones rather than sacrifice full dev boards, and instead of programming them via traditional means, he is using his computer’s sound card.

He builds a simple dead bug Arduino (which he calls an Audioino) using a handful of resistors, a pair of caps, an LED, a reset switch, and most importantly – an audio jack. After burning a special audio bootloader to the chip, he can connect the Arduino directly into his computer’s speaker port for programming.

Once the microcontroller is connected to his computer, he runs the IDE-generated hex file through a Java app he created, which converts the data into a WAV file. With the Arduino put into programming mode, he simply plays the WAV file with an audio player…

View original post 39 more words

Newest Projects

Hi, I havnt really posted anything in a while due to being busy with some new projects and tearing things apart that we find in the trash.

So far, Ive been building a small cnc machine and a reprap prusa mendel 3d printer. The cnc machine hasnt gotten very far other than collecting the rods and such for it, and two motors for it. The reprap on the other hand, Im stuck due to the fact that I dont have the motors, electronics, or the hot end to finish it, but I do have the frame and all plastic pieces already printed out and assembled.

Here’s a pic of the progress on the reprap:

Image

the motor is just a weaker one that I found in an old inkjet printer ages ago, but looked good there for the time being, but Ill probably use it on my little cnc machine. Also, I ran out of filament, so just messing with fixing stuff atm. I keep researching into making a Lyman’s extruder, which turns plastic pieces of scrap or whatever and turns it into filament for the printers. I find tons of ABS plastic in the plastic covers and internals of most of the computer cases, and printers/scanners that we find in the trash nonstop, so it would be great to have one of those with some type of shredder.

The cnc machine, I plan on trying to make it out of an old flatbed scanner base since it had large 10mm smooth rods and brass bearings already there, so it was a good starting place. Ive been trying to research different electronics to put on it, but haven’t found something that suits my budget/needs yet.

The other thing Ive been working on is my little lemon trees and fixing xbox 360 consoles and kindle fire tablets. (they evidently couldnt solder the usb connector in very well, so it likes to just fall off and the tablets refuse to charge anymore.

Here’s an older pic of my baby trees and messy table: 😛

Image

That’s what’s been going on so far, too many projects, not enough parts 😛

New Addition to the Robot Circus

Well, there’s a new robot in town, it’s name is Mouse. I named it mouse because of the fact that when I was first putting it together, the big wheels and the base reminded me of a weird mouse with the wires sticking straight out the back of the base. I made it over the last few days using my 3d printer and some extra servos/arduino/printboard. It tends to go in large circles because of the fact that I dont know what the centers are on the servos for the arduino programming. Ive always used them with PIC chips, which I figured for this little bot, I’d change it up a little to learn something new. Other than the large circles issue, it runs around the camper here and if something gets in its way, the ultrasonic sensor on top picks it up and tells the robot to turn around and run away.

Here’s some pics of it sitting on my resistor cabnet waiting for me to press the go button:

Image

Image

Its based off of the miniskybot 2.0, which is a basic printbot. The robot is an educational robot designed by a guy over in spain, but uploaded the robot as open source for anyone to use and modify as they wanted.

http://www.thingiverse.com/thing:63165

With a 9v backpack holder hot glued to the back of the robot, here’s the 9v backpack

http://www.thingiverse.com/thing:26599

I also used a custom printshield which seperates the 9v from running into the 6v servos, and used the 6 AAA batteries that are designed into the base of the robot to power the servos with, then 9v battery for the arduino and sensors. I did it like this so motors didnt get too much power, and it helps prevent power dips when its running which would normally cause the robot to reset itself.

If anyone wants the pcb layout for the printshield, I can upload the files, and/or the mirrored pdf file to use for toner transfer method.

Will be bringing him to a certain gyro shack and letting him loose as soon as I can get over there 😛

Robosapian v2 PC control/New Toy

I know I havnt posted any posts in a while, but been busy working with a new project. I recently came across a robosapian v2 that someone tossed in the trash, that I rescued and got working again. The only thing is, he had no remote, so this is what I did to get control of him using the computer.

I rewired him and replaced all of the original and crumbling wires, and cleaned out the battery compartments since the batteries had exploded inside of him, then I found the wire running from his IR sensor to the motherboard inside of his back. I cut the wire and added a normally closed mono headphone jack, the type that when nothing’s plugged in, it shorts the two contacts together. The contact that gets disconnected, I ran to the IR sensor, then the other, I ran to the motherboard so the tip of the headphone jack will connect into the motherboard when it’s plugged in, and will disconnect the IR sensor so there is no false signals coming from the IR sensor in the head while it’s plugged in, then it will connect back up the IR sensor in the head when the headphone jack isnt plugged in. I put the headphone jack into his back, he usually has something that looks like a button on his back and front, but I just popped the one out on his back, and drilled it out slightly to put the jack in it, and now it looks like it was just designed into it by default.

Then I took an arduino and on a protoboard I found for dirt cheap on ebay, I soldered another headphone jack to it with 3 pin header so you can use it as you wish. I then used a 1.8k ohm resistor and a 3.3k ohm resistor to hook up a voltage divider between pin 13 and gnd, and the divided voltage went to the tip of the headphone jack on the protoshield.

Using this code below, I am able to send commands to the robosapian v2 by a python program called robomoco.py that I found online, Ill post a link to it below also. I had to modify the code slightly because newer arduino software deprecated a few things that was in the old code.

// rs_commander.c - Arduino-based serial port controller for Robosapiens
// Modified: 9/15/10
// Author: Ben Bongalon (ben@borglabs.com)
// Adapted from Karl Castlet's code
// I refactored it a bit and added support for the Robosapien V2 and
// other models (untested).
// Robosapien's model types. Credit to AiboPet's BoneYard
#define RS_MODEL_ROBOSAPIEN_V1   0x00
#define RS_MODEL_ROBORAPTOR      0x01
#define RS_MODEL_ROBOPET         0x02
#define RS_MODEL_ROBOSAPIEN_V2   0x03
#define RS_MODEL_ROBOREPTILE     0x04
#define RS_MODEL_RSMEDIA         0x05
#define RS_MODEL_ROBOQUAD        0x06
#define RS_MODEL_ROBOBOA         0x07
#define RS_BIT_HIGH    1
#define RS_BIT_LOW     0
// User-configurable parameters
int RSModel = RS_MODEL_ROBOSAPIEN_V2;  // your Robosapien model
boolean RSEcho = true;          // echo commands to host PC?
int irSignalPin = 2;             // Infrared wire connects to this Pin
int ctrlPin = 13;                // Generate the pulses on this Pin
volatile int RSIRCommand;        // Single byte command from IR
volatile int RSBit=9;            // Total bits of data
boolean RSIRCommandReady=false// IR command was received?
int bitTime = 833;               // bit width in microseconds (1/1200 second clock)
#define INTER_CMD_TIME    10     // msecs before sending next command
// Encode a binary '1' or '0' on the wire
void WriteBit(int bit)
{
  digitalWrite(ctrlPin, HIGH);
  delay_ticks((bit == RS_BIT_HIGH) ? 4 : 1);
  digitalWrite(ctrlPin, LOW);
  delay_ticks(1);
}
// Send a byte down the wire (MSB first)
void WriteByte(byte b)
{
    WriteBit( (b & 0x80) == 0x80 );
    WriteBit( (b & 0x40) == 0x40 );
    WriteBit( (b & 0x20) == 0x20 );
    WriteBit( (b & 0x10) == 0x10 );
    WriteBit( (b & 0x08) == 0x08 );
    WriteBit( (b & 0x04) == 0x04 );
    WriteBit( (b & 0x02) == 0x02 );
    WriteBit( (b & 0x01) == 0x01 );
}
// Start each Robosapien commands with a preamble
void WritePreamble()
{
   // Pull down the I/O line for 8 ticks
   digitalWrite(ctrlPin, LOW);
   delay_ticks(8);
   // Send the Robosapien model type (not needed for the orginal Robosapien)
   if (RSModel != RS_MODEL_ROBOSAPIEN_V1) {
     WriteBit( (RSModel & 0x08) == 0x08 );
     WriteBit( (RSModel & 0x04) == 0x04 );
     WriteBit( (RSModel & 0x02) == 0x02 );
     WriteBit( (RSModel & 0x01) == 0x01 );
   }
}
// Add N clock ticks of delay
void delay_ticks(int ticks)
{
  delayMicroseconds(ticks*bitTime);
}
// Receive a bit at a time.
void RSReadCommand()
{
  delayMicroseconds(bitTime + bitTime/4);      // about 1 1/4 bit times
  int bit = digitalRead(irSignalPin);
  if (RSBit==9) { // Must be start of new command
    RSIRCommand=0;
    RSBit=0;
    RSIRCommandReady = false;
  }
  if (RSBit<8) {
    RSIRCommand <<= 1;
    RSIRCommand |= bit;
  }
  RSBit++;
  if (RSBit==9) {
    RSIRCommandReady=true;
  }
}
void RSSendCommand(int opcode)
{
  WritePreamble();
  WriteByte(opcode & 0xFF);
  digitalWrite(ctrlPin, HIGH);
  if (RSEcho) {
    Serial.print(opcode);
  }
  delay(INTER_CMD_TIME);    // buffer time before processing next command
}
// Initialize the serial port, GPIO pins and interrupts
void setup()
{
  Serial.begin(9600);
  pinMode(irSignalPin, INPUT);
  pinMode(ctrlPin, OUTPUT);
  digitalWrite(ctrlPin, HIGH);
  attachInterrupt(0,RSReadCommand,RISING);
}
// Main program loop
void loop()
{
  // If a command was received from the IR remote, relay it to the robot
  if (RSIRCommandReady) {
    RSSendCommand(RSIRCommand);
  // otherwise, check the serial port for new commands sent by computer
  else if (Serial.available() > 0) {
    int opcode = Serial.read();
    RSSendCommand(opcode);
  }
}

And here is the link for robomoco.py

http://borglabs.com/projects/robosapien-v2/using_robomoco

Ill try to post pictures later, but dont feel like tearing him all back apart again atm. 😛

ps, if your having trouble with the code I posted, just grab the code from the site with robomoco, under the part 1 link,  and look for “serial.print(opcode, BYTE” and change it to “serial.print(opcode)”, then it should compile fine.

Short tutorial on Raspberry Pi’s GPIO pins in Python

Here is a short tutorial on how to use the GPIO pins in python and the labeling on them. Alot of people seem confused about this and I figured I’d explain how the labeling works. There’s a third labeling part too, but from what Ive discovered, it’s only used with shell commands and C/C++, not with python.

In python with the RPi.GPIO package, there’s two common numbering systems to describe the pins on the GPIO header, there’s the BCM layout and Board layout.

BCM labeling: The pin labeling from the BCM2835 IC itself (The main Processor), Here’s an example in python:

import time
import RPi.GPIO as GPIO
LED = 4               #Physical pin 7, BCM pin GPIO.4 on the BCM2835
GPIO.setmode(GPIO.BCM)
GPIO.setup(LED, GPIO.OUT)

while 1:
GPIO.output(LED, True)
time.sleep(0.5)
GPIO.output(LED, False)
time.sleep(0.5)

Board Labeling: the physical pinout on the GPIO header, and here’s the same example using the same pin but using board layout:

import time
import RPi.GPIO as GPIO
LED = 7               #Physical pin 7, BCM pin GPIO.4 on the BCM2835
GPIO.setmode(GPIO.BOARD)
GPIO.setup(LED, GPIO.OUT)

while 1:
GPIO.output(LED, True)
time.sleep(0.5)
GPIO.output(LED, False)
time.sleep(0.5)

This tabel below is the labeling of both the physical board pinout (inside numbers) to the BCM layout (outside labels):

Image

I hope this helps those that are starting out with programming the GPIO pins in python on your Raspberry Pi.

Update: on version 2 raspberry pi boards, GPIO 21 is renamed GPIO 27, so dont think the pin was broken like I did. 😛

Basic logic analyzer on raspberry pi using PICKit2

I discovered this little trick for all of you out there that uses the rpi for the electronics projects like I do.

First, go to this link and download the pk2-la zip file, and extract it somewhere like a Downloads folder on the rpi.

http://sourceforge.net/projects/pk2-la/

Then go “sudo apt-get install python-usb”, which will install the USB stuff for python, and just run the pk2-la executable through root command line, or “sudo pk2-la”. Make sure your pickit2 is plugged in before you run it tho otherwise it will not run.

I copied the pk2-la file, LA-Format file, and IO-Format file to /usr/bin so I could just call it from anywhere in the command line by using “sudo pk2-la”.

You should see a window pop up after a few seconds looking like this:

Image

You need to hook 5v from your circuit to pin 2 and gnd to pin 3/middle pin, then the other three inputs are shown in this diagram:

Image

And there you go, a 3 channel logic analyzer for your Raspberry Pi 😛

All credit for pictures go to Josejx at http://sourceforge.net/projects/pk2-la/ and Microchip.

Reading CPU temps using python for Raspberry Pi

earlier, I found this, and thought it was cool so I modified it a bit to work how I needed it to.

http://www.raspberrypi.org/phpBB3/viewtopic.php?f=32&t=22180

and here is my modification:

#!/usr/bin/env python
import os

# Return CPU temperature as a character string
def getCPUtemperature():
res = os.popen(‘vcgencmd measure_temp’).readline()
return(res.replace(“temp=”,””).replace(“‘C\n”,””))

temp1=int(float(getCPUtemperature()))
temp2= 9.0/5.0*temp1+32
print temp1,”C”, “\n”,  temp2,”F”

Now I can have an IF statement watch the temperature and if it goes above a certain temp, I can turn on a GPIO pin using RPI.GPIO package, or anything I wanted to do with it. I figured I’d share this little trick with everyone. 😛

ps. if the guy that wrote the original function part ever reads this, thank you so much for that 😛