Showing posts with label microprocessor. Show all posts
Showing posts with label microprocessor. Show all posts

Sunday, November 30, 2014

AVR ISP Extender

I have played with microprocessors such as PIC and AVR. They both have advantages and disadvantages, and are fun to play with.

One thing about AVR that I have problem with is the ISP interface. The AVR ISP programmers use a 10-pin (or 6-pin) interface arranged in 5x2 (or 3x2). This is rather bread-board unfriendly. In comparison, the PIC ISP programmers use a 5-pin inline interface, which is much easier to connect. With some time in the weekend, I have decided to build a little board that brings AVR ISP into a more breadboard friendly form.

There are a few such attempts by other people on the internet. Here is one that is just expanding the space between the two rows. This is a little circuit board of the same idea from Sparkfun. This guide makes the circuit board yourself, and I like the way how the pin head is connected to the board.

This is quite simple, and I have all the connectors I needed. So I decided to get my soldering iron and make one myself just for the fun. Since I will be using a lot of 8-pin ATtiny processors, I decided to add a DIP8 socket so I can easily program those without needing to connect the wires every time. By the way, I found a nice compact bootloader that works on ATtiny's, so all I need to do is to burn the bootloader on.


 
So here is my AVR ISP extender. I tested it by programming a ATtiny chip, and it works well.
 
By the way, my pin out is as following:
  1. GND
  2. VDD
  3. MOSI
  4. MISO
  5. SCK
  6. RST
This is different from most others on the Internet. I also has two rows of inline connectors, one male and one female so it works with both arrangements when I need it.
 
 


Tuesday, July 22, 2014

Homemade CNC2 (Electronics - Part 1)

I needed the electronics to run the CNC. When I started out (and with my last CNC build) I have been running it with Arduino Mega 2560 with a RAMPS shield. You can immediately recognize that this is a 3D printer electronics setup. Indeed, I have converted my last CNC into a 3D printer to learn the in and out of it. So with this CNC2 build, I have also started with the same setup, which I happened to have laying around.

For the firmware, I have been using Marlin. In order for it to run CNC, I have to modify the configuration file to disable temperature sensing otherwise it would not move (this is a safety feature for 3D printer to prevent extruding before the hot end is hot enough). For the host software, I have been using Printrun.

This setup works out fine for a while, but then I felt that I will need more. First of all, the Marlin firmware does not work with inch as unit. In this part of world where I am living, the English system is still commonly in use. It is a lot easier to go down to my local hardware store to buy stuff in English then mail order then on Internet and wait for them to arrive. The second thought is that I know there are CNC specific firmware out there, such as GRBL. If I can have a firmware that not wasting the processing power on checking the temperature, why not go for it? GRBL has been proven working by years of experience in the community and it has a few neat features from what I read (such as command to change steps per distance). The third things is that while using Marlin, I for a few times have the firmware paused in the middle of a long run. I somehow suspect there might be un-found bugs in the Marlin firmware, at the same time GRBL is simpler (thus less chance of bugs), better tested (it is there longer than any 3D printer firmware), and I especially like its soft reset that retains machine coordinate while resets the processor state. So I have set to move to GRBL.

GRBL is very simple and easy to use. It is small enough (I have always loved simpler solution) that fits into the 32K memory of ATmega328P. I happened to have a few Arduino Pro Mini 328 (which I bought for a few bucks on eBay thanks to China). So I pulled out my AVR compiler and build the GRBL. After some struggle with the Arduino bootloader, I am able to load GRBL onto my Arduino (which I essentially used as a ATmega328P breakout board).

Onto my breadboard in a spare box, I have built a test CNC controller running GRBL. And I have added the GRBL soft reset switch to the front panel, as I really needed that "Panic Switch". I will find out why soon.

Sunday, July 6, 2014

Using AVRDUDE with Arduino bootloader

I am working on a home built CNC project that uses Atmel processors as controller. In the process, I had gone through much trouble to load the firmware using the AVRDUDE through the Arduino bootloader on the chip. Here is to share my finding since I have a little trouble finding this information on the internet.

Basically the Arduino bootloader is default to 57600 baud 8-N-1 (circa 2014). Everywhere I searched on Internet (including the official Arduino bootloader page) has dated information, and specified as 17600.

The other information is that the programmer protocol must be set to "arduino" for AVRDUDE. So here is the correct commandline options for it:

avrdude -v -v -c arduino -b 57600 -P com9 -p atmega328p ....

Note that the baud rate (57600) has to be explicitly specified for this to work. I also found this information mentioned in this Sparkfun forum post, which is where I got the idea originally.

One more small caution with loading with AVRDUDE instead of Arduino IDE is that one will need to make sure that the chips is in bootload mode when AVRDUDE attempts to write to it. One way to do it is to perform a board reset (through a switch or short the right pin). But the modern Arduino bootloaders stays in the bootload mode in a very short time (mine is half a second), so you will have to reset it in a relatively short time window. But if the code is load through Arduino IDE (and proper Arduino hardware setup) there is no such reset needed. The way that Arduino IDE does it without using the reset is to use the DTR line (of the serial communication) to trigger the reset. On my setup I just connect the DTR of my FT232R module to a line marked GRN on my Arduino Mini Pro, and it works well without needing me to press the reset button any more for loading.

A few more words, I am using these Arduino boards essentially as a AVR processor board. The Arduinoo boards are cheap and readily available (thanks to industry scale and China), and it helps me to avoid soldering the tiny surface mount chips.