Wednesday, 22 February 2012

Wireless communication success

Well after loads of trial and error and lots of searching on the web, I am finally able to talk to the ATmega644p chip on my breadboard via a bluetooth connection.

There were 2 issues:

First, I have no RST pin on my bluetooth module, so I had to find a way of generating one.

This involved attaching a wire to the place where the "status" pin would be connected (basically looped through from the status LED, that actually connects to pin 32 of the HC-05 board that is soldered onto the module) then connecting this via a 1uF capacitor to the reset pin of the ATmega644p.

Now when I power up the board, initially both the ATmega644p and the BT module flash until a connection is established.

Once a connection (like from Printrun) is made, the capacitor delays this connection to the reset pin allowing the chip to reset one last time and then keep that pin held high and allowing programming to happen.

Second, I had the RX and TX pins connected backwards, once this was sorted, Printrun was able to see the "printer" as online. It would seem that these pins are connected differently to my CP2102 programmer, despite being labelled the same.

Still I have never known any harm come from connecting these the wrong way round, and often found this to be a suck it and see exercise to locate the correct orientation of the 2 pins - TX-TX and RX-RX never actually achieves anything - 2 sides attempting to talk on one pin but both listening on the other.
Further tests have shown that I don't actually need the status pin connected for Printrun to talk to the chip, if I had sorted problem 2 first, I would have noticed this sooner, though it may still be required for wireless re-programming should I feel the need to do this from avrdude or Arduino.

I have been having a closer look at the Sanguinololu schematic:
I am wondering if one can get away without needing to install the FTDI chip at all, especially if you have access to an external serial programmer like the CP2102. all the pins for the USB2TTL connector loop through to the relevant pins on the ATmega644p chip, and all of the pins required for flashing the bootloader are available via the 6 pin ISP header (also used by the SD board).

This would mean a potential saving of 5 components:

IC100 - FTDI chip
PS1/PS2 - USB connector
C8, C11 & C15 - 0.1uF Capacitors
C16 - 4.7uF Capacitor

The FTDI chip and USB connector are the most expensive components on the board after the Stepper drivers and the ATmega644p chip, a programmer like the CP2102 can be had on eBay for as little as £1.83, the FTDI chip alone costs more than that, and without it, there is no SMD soldering required at all.

I have since seen this confirmed by some of the postings on the forums, though it is far from obvious on the Wiki, or the github home of this product.

I have ordered a couple of microSD card adapters:
These worked out at £5.84 each including postage, which is only slightly above the bare board price for SDRamps, just over half the price of a populated SDRamps and about a third of the price of an SDSL (Sanguinololu version).

It also has a built in voltage regulator, so works with 5V or 3.3V (same as SDRamps and SDSL) and will use the same pins on the ISP header (actually only 6 of the pins used by the other boards are required anyway), despite them using a 10 pin connector:


Saturday, 18 February 2012

Delta Robot

Just for giggles, I thought I would have a go at designing a delta robot, I have no idea how stable it would be, or if it would be anywhere near accurate enough to use as a 3D printer, or even a pick and place machine.

I was initially inspired by a couple of designs on Thingiverse, the Yazoo Polybot:

the Yazoo Polybot - Cranberry Edition:

So I came up with the following:
Which after some further tweaking and looking in detail at several commercial items it became the following:
Every time I see one of these, I can't help thinking about Jeff Wayne's "War of the Worlds" and the tripod like exo-skeletons used by the alien invaders from Mars:
Anyway, I have no idea if I will even build this, it does not look too expensive to build, EMC supports Kinematic coordinates, I intend to build a bunch of PMinMO TB6560AHQ based Stepper drivers:
I already have all of the parts, and recently placed an order with ITead Studio for some of these boards ($9.99 for 10 boards of less than 5cm x 5cm - Spring Festival discounted price), so the total cost of each board including all of the parts will be £4.35, the cheapest equivalent one I can find on eBay is £12.01.

These drivers with a different set of power resistors (I have 0R22 currently, which will allow 2.27A, I have some 0R15 resistors on order which will allow 3.3A) will be used on my PCB CNC Machine.

A recent addition on Thingiverse is the Rostock:

Bootloading and Arduino

My USBasp programmer arrived in 3 days (wow that was fast), seems it came from a supplier just down the road from me, rather than direct from HK.

I downloaded and installed the Arduino 1.0 software, downloaded and configured the Sanguino add-on software, connected up the programmer to the breadboard, select the relevant options in Arduino and attempt to upload the bootloader.

Well it barfed a lot but I think (after much googling) that it may have worked - no "successfully uploaded" messages, just a long pause, stops and then displays a load of messages about "pipe stalled".

I connected up the debug led to pin 1 and on power on or pressing the reset button, this flashes a couple of times - this apparently means that there is a bootloader present - yeah finally some progress.

I also located some newer information relating to using this version with an ATmega644p at maniacbug's blog, along with a link for a version of the bootloader that will actually compile, since none of the other ones I can locate will.

Next, I download sprinter from github and attempt to compile/upload this to the newly bootloaded chip.

First hurdle - Arduino has had a major rewrite for version 1.0, and it would seem that the Sanguino and reprap community are somewhat behind the curve here.

Downloaded Arduino 0.23 as this supposedly works with the most recent version of Sanguino, more tweaking, still no joy, bootload from this version fails outright as well.

Apparently I am not alone with having issues with this version.

Downloaded Arduino 0.18 and the appropriate version of Sanguino for this, well these actually compile the sprinter software, so that in itself is progress,

The only version that seems capable of uploading the bootloader is 1.0, and the only version that will compile the software is 0.18 - oh joy.

Also version 0.18 of Arduino does not support the upload of software via the programmer unlike version 1.0, so a serial programmer is required.

I have one, a PL2303 USB to RS232, however it does not have a pin for connecting to the reset pin of the ATmega644p chip, so another programmer is required, a CP2102, that is more compatible with AVR chips:
A massive £1.82 spend on eBay and a few more days wait later and I have the item and can hook it up to the board.

My Mac does not recognise it, so a quick search for a CP2102 driver, which I located at Silicon Labs website, install and restart - hey presto we have a new serial port called SLAB_USBtoUART that I can select within Arduino.

Some minor cabling updates to the breadboard and we try again - fails with stk500 errors cannot communicate.

A bit more googling, and find a work around that suggests pressing the reset button 4 seconds after selecting the "upload to board" option from the software - this seems to have the desired effect, the debug light flashes quite a lot at varying speeds and eventually stops.

Again, no nice "your upload was successful" message, but I believe it did actually upload something, so let's test if we can talk to it.

Locate my installation of Printrun and fire it up, then after I locate the correct syntax to connect to my specific serial port, it claims that the printer is set up - wahey looks like we made it.

Now you may ask - "why go to all this trouble and not just solder up the board already and then program it via the USB port like everyone else?"

Well, partly because I don't actually want to use the USB connection, I want to talk to the board via bluetooth, and if I solder the USB connector, it will prevent me from soldering on the pins for the TTL header, and partly, just to see if I can.

I bought a couple of Bluetooth modules from  eBay, £11.70 for two:
so much cheaper than the BlueSMiRF items from Sparkfun Electronics at $64.95 a piece!

I may yet find that the cheaper items cause issues, but we shall see, serial communication should only need transmit and receive - hell, I used to use a broken paperclip to cross connect RX and TX between the B serial port of one Sun Microsystems Sparc 5, 10, 20, etc machine to the A serial port of another to provide a makeshift console (no other pins connected), provided you selected the correct baud, parity, data, stop bits, etc it worked just fine.

My Mac Mini and my work Windows laptop can both see the Bluetooth module quite happily, I just need to connect to it via something like putty and change the baud rate to something a bit faster than 9600, this was achieved by connecting it to my PL2303 adapter and then issuing some AT commands via copy and paste (as you can't type them fast enough on a keyboard).

Printrun can connect to the bluetooth device, however cannot confirm the printer as online, let's wait and see what it thinks when we actually have a FTDI TTL chip sat in between the ATmega644p and the Bluetooth module, when the Sanguinololu board is all soldered up.

As a side note, I also discovered that if I have any kind of USB connection to my breadboard and connect up the 5V line, I don't actually need the voltage regulator circuit, as it will be provided by the USB connection.