Category Archives: Atmel AVR

Repairing a damaged surface mount resistor

Well, somehow I managed to damage a resistor that is connected to the ISP header (J5) on the expression’s motherboard.  This led to a confusing error message in AVR Studio when I tried to program the flash on the Atmel chip.

The error message said “Failed to connect to target.  Does the target have power?”

Referring to my previous image on the JTAG interface, I recognized this pin, VTRef, which is pin 2 on the connector:

CricutExpressionJtag

Just to the right of the connector, off screen in the above image, is a tiny surface mount resistor.

I had carelessly plugged the ISP cable (which goes in the black connector in the bottom right above) into my AVR Dragon programmer’s JTAQ port!!!!  Argh, so this sent voltage back down to pin 2, which fried the resistor.  During inspection of the board when I could no longer program the code, I saw some brown residue next to that resistor.

Using the voltmeter when the machine powered on, I confirmed that I had 5 volts going into the resistor, and zero volts coming out.

chicken_fried_resistor

Now I had to find a spare board with a similar sized resistor… and use my shaky hands to dismount it and re-solder it onto my machine’s motherboard.

So, once I removed the resistor and replaced with a similarly sized one, I tested the voltage going in and out, seeing that it was both 5v, I reconnected the AVR Dragon’s ISP cable (to the correct port this time!) I successfully read the chip and received no errors…. yayyyy!

FreeExpression Firmware Roadmap

Now that I have the base code working, and all the moving parts moving, I am planning the full firmware roadmap.  The original expression machine is a very capable machine but it is designed to be used with the manufacturer’s cartridges.  My ambition with this project is of course to break that cord and use the machine with open source software (Inkscape) in a user friendly manner.  Previous attempts by other people to use these machines with third party software have either been incredibly tedious, or resulted in litigation (yuck).

My approach is quite different.  I have decided to completely write new software that is installed onto the machine itself, erasing the manufacturer’s software (to avoiding copyright infringement) and implement my own grand design for the machine.

cricutkeypad4

Let’s talk about the user controls on the machine:

Dials

There are three dials marked Speed, Size, Pressure.  These are convenient because while the software (Inkscape) can manage these as well through the Export/Plot interface, it seems logical to support this functionality through the dials.

Size

The size dial is an interesting one.  In the original machine’s design,  you load a shape from a cartridge and then you use the size dial to resize it.  In this new paradigm, where you are using Inkscape, you simply would set your design size in Inkscape.  So the Size dial is kind of useless unless I implement some other feature (see below) that could make use of it.

Pressure

The pressure dial is very useful, as it allows us to set the pressure in one of four (five??) increments.  This would tell the firmware to adjust the voltage going to the solenoid that pushes the knife head down.  This in turn controls how hard the solenoid “presses” on the knife.

Speed

Adjusting the speed of a cut can help with thicker materials that require more delicate handling, or with thinner materials that can handle faster cutting.  It makes sense to allow the user to adjust the speed before the cut begins. I’m not sure if it should adjust the speed during the cut….

Keypad

The keypad has numerous keys that perform a wide range of functions.  Many of these keys are used to select a shape from the cartridge library.  Without the need for cartridges, there is a lot of keypad real estate that is going to be unused.

The main keys, A-B, 0-9, and some basic shapes (from Wingdings library) will allow the user to cut using a standard font (Comic Sans).

Direction keys

These keys allow you to position the cutting head over a specific area of your material

Stop key

This key will stop the cutting process completely and basically aborts your project, returning the machine to its home position and ejecting the mat.  There is no way to stop the incoming stream, so the machine will just have to ignore the remaining data and allow the internal buffers to clear out until it receives the final “end of job” HPGL command.

Cut key

There really is no current plan for this key.  Cutting is started at the computer.

Option keys

These keys are just to the right of the display and control things like multi-cut, portrait, mix n match, quantity, auto fill, fit to page and fit to length.  I’m not sure what possible use these can have in the future, but I’ll try to implement some of the options if they make sense.

Display

The display works fine in my current firmware, so I will continue to use it for user input/output.  On the original expression, when a user selects a shape, the machine shows a small image of what they selected.  This will not be possible since the main goal of this project is to allow you to cut whatever you want, the code could not possibly interpret your image completely and display it.  So, the display will just be for menu prompts and confirmations.

Onboard memory

Since the machine has 512k bytes of on board memory storage, I have considered the option to allow the user to save their favorite projects and shapes into the memory, and allow them to easily retrieve them through the keypad or use the speed wheel to browse through the their custom shape library.  If this is implemented, then several of the option keys have meaning again, as well as the size wheel.

SD Card add on

sdcard

Another interesting possibility is the addition of an SD card port at the cartridge port.  The cartridge port is ideally designed to allow expansion, and in fact the Atmel AVR control pins that are connected to the cartridge port are the very same pins that standard SD card readers use.  The feature would work like this:

User inserts an SD card, and the machine reads the list of files, giving them a menu to browse through them using the speed wheel.  Once a file is selected, they can have the option of storing it, or cutting it.  If they store it, it will be placed into the machine’s on-board permanent memory.  This is useful for those stars, squares, hearts, snowflakes that we use every day 🙂

 

Connecting the AVR Dragon to the craft cutter

Here I document the two methods that I use to connect to and program the onboard ATMega1281 microcontroller.

First, the easy way:  ISP 6 pin connection

After opening the bottom of the case of the machine, you can see a 10 pin grey cable connected to an external port at the front right of the machine.  Disconnect the cable from the port, and relocate it so that it sticks out of the center of the case.  You can now reassemble the case so that the machine is kept closed and safe from falling debris.

Here you can see the cartridge port on the lower right corner.

circut_expression

The below image details the ISP programmer pin connections to the 10 pin cable connector.  However, this is just informational, because all you really need to do is connect the grey cable to your AVR Dragon’s 6 pin ISP header, aligning pin 1 on the cable to pin 1 on the ISP header.

CricutExpressionISP

Connecting the AVR Dragon is simple!

AVRDragonConnection

Here is how the machine looks with the dragon attached to the front cable:

CricutISP

 

Now, I head into Atmel Studio 6.2 to see if I can read the AVR’s information:

AtmelStudio

 

Next, the hard way: JTAG

JTAG interface is very useful!  You can use it to program the ATMega1281 Atmel microcontroller, as well as debug your software on the chip!  You can set breakpoints, step through your code line by line, inspect variables and registers.  Very useful, but challenging to connect.

In order to connect to the JTAG pins on the chip, I had to determine where the connections on the motherboard were located.  I knew any good engineer would provide test points, I just need to find them.  So I used my multi-meter set to Ohms, and set the range to audio.  This way it beeps when you touch the probes together.  So I had to grab the datasheet and find the JTAG pins on the chip, then locate their connection points on the motherboard:

CricutExpressionJtag

My first approach to this involved soldering wires onto the motherboard.  However, after I spent a lot of time trying to get the OLED display working, I discovered that the JTAG pins were also connected to the display port.  Theoretically, I could tap into the display cable (located under the top keypad).  However, there is one pin that is not connected to the display cable:  TCLK (at the top of the image in orange).  I would still need to solder something here.  In the end, it made more sense to just permanently wire the JTAG interface in, and connect it to another 10 pin cable.  This gives me the capability to debug things when i need to, however I can use the ISP header just for simple programming.  One caveat:  the display won’t work while JTAG is enabled.

CricutJtagTestConnection CricutJtagTestConnection2

Also, to get JTAG working, you have to set the fuses in Atmel Studio to JTAGEN = Yes.  Don’t forget to turn it off when you’re done, otherwise the display won’t work.

AtmelStudioJtagEnFuse

An inside look at the Cricut Expression

 

Disclaimer:  The purpose of this series of posts is to examine a well-built piece of hardware and undertake a study of how to develop firmware for the onboard Atmel AVR microcontroller it incorporates to interface with and control motors, lights, buttons, dials, switches, etc.

You could certainly find “AVR development boards” where you have a scratchpad sort of area to design your own circuits, however, unless you’re an electronics designer, engineer, or really advanced hobbiest, you will likely introduce design flaws that would interfere with your software.  My focus for this project is purely on designing the software, not the hardware.  Therefore it made sense to me to start with something that has been professionally engineered and debugged.

The Cricut Expression is trademarked by Provo Craft, Inc.  It is a very nice little machine that cuts designs out of all sorts of materials, and thousands of happy crafters use it to make all sorts of interesting things.  When I received my machine (a gift from my sister), it was not working and I was very curious about how this thing works, and how to repair it.  It turned into a project…of interesting proportions!

This is an educational project used solely by me to learn Atmel AVR development and hardware interfacing techniques.  I am a software engineer by trade, and an electronics enthusiast at heart.

Ok, so with that out of the way, one more thing to add… This information is for my own use, and may not be of use to anyone for any particular purpose.  Indeed, if you follow these posts and decide to apply anything you learn to your own machine, you accept full responsibility and accept all warnings and disclaimers posted.  The bottom line is, it’s my machine, and I can break it if I want to.

20150206_160128

Motherboard

Once the machine is opened from the bottom, the motherboard can be accessed for inspection.  The following image displays the major functional elements.

motherboard layout

(You can click the images to view the full size version)

I diagrammed this during my exploration and annotated which subsystem I had working.  The green highlighting was used to keep track of what I had working at each stage of the process.  I would use yellow for partially functional and red for non-functional.

CricutFunctionalDiagram

Future articles will describe each of these in depth, so I will summarize the functional areas below:

Keypad

The keypad connector interfaces with the large matrix keypad and LEDs on the top panel.

Display

The display is an OLED display using the Univision Technology UG-2864ASYDT01 module based on the SSD1325 driver IC.  The u8lib AVR library is used to interface with the display.

JTAG

This interface allows you to program the AVR as well as use the Atmel Studio debugging interface to step through the running code on the chip. This is immensely useful when things don’t seem to be working right.  However, when the JTAGEN fuse is enabled the OLED display will be disabled since it uses the same pins.

FTDI

The FTDI chip is used to convert the serial interface on the AVR to the USB interface for the computer.  It is connected to the USB port on the far right.

ISP/Port

The typical 6 pin ISP programming header is exposed in this 10 pin cable.  Interestingly, this cable is actually connected to the cartridge port on the front of the machine.  Eventually I will build a small cartridge board to connect my AVR Dragon programmer to the port instead of hanging a cable out the front of the machine.

Motor Control

This machine (actually,all of these cutters) uses two stepper motors for the two axis (x/y).  This motherboard uses eight MOSFETs for the high-power side, and eight smaller transistors for low power.  This allows us a great deal of capabilities for accurate micro-stepping movement.  Each of the transistors are connected to the output connector.  The stepper motors are 6-wire unipolar models.  Each of the 4 coils (per motor) are connected to the white connectors at the bottom edge of the motherboard.

Dials

Driver for 3 analog dials, connected as follows:

dial  | AVR pin
——-+———–
size  | PF0 (ADC0)
speed | PF1 (ADC1)
press | PF2 (ADC2)

Each input is a simple voltage divider between 0 and 5V, with  a few discrete settings where the pot clicks.

USB

The USB connection is set in my software to 9600 baud, XON/XOFF flow control.  This has proven to be the most reliable, and certain software like Sure Cuts A Lot required 9600 baud when using the US Cutter “SC” plugin.

Pen Control

These transistors manage the pen holder’s up/down movement and the “pressure” which equates to a Pulse Width Modulation signal driving the voltage up or down.  The mechanism that moves the pen up or down is essentially an electromagnet or solenoid.

Home Switch

The home switch signals the Atmel AVR micro-controller that the cutting head has reached its right-most position.  This internally translates to a 0 on the X axis.

Flash Memory

The flash memory on the machine is an Atmel AT45DB041D 4 megabit serial flash memory device.  For native mode operation, this flash memory contains the George and Basic Shapes cartridge data.  For my purposes, I have erased the flash memory and may use it to store projects that I print, so that I can easily reprint them in the future without having to load Inkscape or use the computer.  One idea I have for this is to create a menu option to store rather than cut the incoming data.  The user would enter a name for the project and the machine would store the incoming HPGL data in flash memory.

With the addition of an SD card connected to the front cartridge port, this might be very useful in the future 🙂