Monday, 17 September 2012

STL to STEP...

Although there is significant amounts of hardware about the house, the kids have only shown marginal interest in computers and electronics for other than playing Minecraft with and occasionally homework. Along with Huxley #710, in an attempt to address this issue, we recently acquired a Raspberry PI for my two children to play with. Of course it needs a case and Thingiverse would be the place to go. But....
Raspberry PI E2712RSV1.0B1.1

I downloaded Thing 28070 and printed it out
It would seem our Raspberry PI is unlike others, specifically: -
  • The pitch of the audio and video connectors is different
  • The PCB is 1 mm wider
  • The network connector is longer
  • There is a white plastic tab on the underside of the USB connectors which fouls
On closer inspection of the pictures attached to Thing 28070 it would seem that others cases don't fit well, perhaps due to the network connector. It's unclear in the image for Thing 28070 that it cleared the case correctly in the original version.

Essentially this means that the cases on Thingiverse would not work out of the box. The problem with Thingiverse is that most people post STL files which are surface models (not easily manipulated) and those that post source files often post SKP (Goolge Sketchup) or OpenScad, neither of which I use or are 'portable'. Of course designing a new case is entirely possible but in doing so the efforts of others are lost. To this end I decided to revisit the use of a CAD file converter.

Sanity warning
CAD conversion tools should be avoided where ever possible as there are always translation errors. These errors result from things as simple as rounding up or down of dimensions, to complex issues such as how geometry should be interpreted and subsequently represented. I tread here where angels fear to walk!

The tool that popped out of a Goolge search for conversion of STL files to STEP files was InStep V2.0 by Solveering. I prefer STEP files as once they import into my CAD software they are quite manageable (modifiable), probably resulting from the fact that its format is defined in an ISO standard. Suitably downloaded and installed I threw the file at InStep and checked out the error report in InStep. It was quite an extensive list of errors and InStep's STL mesh correction tools were unable to fix the issue so it might be a dead end.

Issues with STL files are not particularly surprising as exported STL files often have errors and junk in them. The easiest tool to fix most STL files errors is NetFab which just about any one can use. Certainly it has fixed any STL's I have downloaded from Thingiverse or created for printing with Pronterface. In this instance though it was too tough a nut to crack. I had one more thing to try before starting from scratch.

MeshLab with Thing 28070

A more sophisticated tool I found some time ago is MeshLab. This has quite a number of menu options and I watched some videos on YouTube to see what it could do. Meshlab has lots of clean up options and the ability to create a script which can be used on imported STL files. Here is a copy of the script (.mlx file) I used to clean up Thing 28070:




filter name="Remove Duplicate Faces"
filter name="Remove Duplicated Vertex"
filter name="Merge Close Vertices" param max="1.09781" min="0" name="Threshold" type="RichAbsPerc" value="0.15489"

 
 



Having run this script on Thing 28070 and exported the updated STL from MeshLab, I then re-imported it into InStep and checked the error report. Here is a copy of the report from InStep

*** InStep V2.0 Data Summary ***
 File Name: RaspberryPi_v15 ML.stl
 File Path: C:\28070 - Pi Case
 Report Location: C:\Temp\tmp148.txt
--------------------------------------------------------

 Independent Bodies        : 2
 Total number of Vertices : 2658
 Total number of Edges    : 8142

 ### Features/Facets for the Bodies ###
 Body 1 : 4202
 Body 2 : 1226

 ### Degenerate Features ###
 None found

 ### Edge Issues ###
 No Issues detected

 ### Vertex Proximity ###

 Point 0 to Point 1 Distance is smallest at 0.024337

Using the Export option from from InStep I created a STEP file, then imported the STEP file it into my CAD software and to my surprise it worked!
InStep V2.0 with Thing 28070

In working with the files in my CAD system there have been some minor issues. It seems that the STEP file has to have operations performed on it separately from natively generated geometry. So a cut may have to be performed in two operations. However for the most part it proved very robust.

Imported Thing 28070 STEP file generated by InStep
Of course you're not interested in the Thing I created because now you can easily create your own custom version!

I can't promise the next STL will 'fix' so readily but if Solveering keep this tool available, it could be a very useful facility to have available.

2016 Edit :
 - Solveering upgraded the software.
 - Do check out my later post on FreeCad












Inspired by Thing 24721 and Thing 28070 is Thing 30646
Thing 30646 bottom with SD card protector
Thing 30646 top with cut out for network connector
Thing 30646 assembly (Thing 21718)
Thing 30646 Assembly


Thing 30646 with Raspberry PI (RS Version B1.1)


Rendering of PCB STEP file Thing 21718

Thing 30646 RS Raspberry PI case



Friday, 14 September 2012

Huxley #710 brain surgery...

In order to support an LCD panel and perhaps other exciting upgrades. Huxley #710 needs a bit of a memory boost. The path to this is replacement of the supplied brains consisting of an ATmega 644P-PU part to an enhanced ATmega 1284P-PU.

There are two paths to performing such an upgrade. Buy a chip with the software pre-programmed or buy a blank part and program it your self. There are many Posts on upgrading Sanguinololu boards and boot loaders; this blog documents using an AVRISP mkII as the AVR programmer under Arduino 23 to install the necessary boot loader in place on a Sanguinolou board. Any software can then be downloaded into the AVR part once the boot loader has been programmed.
Sanguinololu Boot Loader Via AVRISP MkII

The following hardware configuration is assumed:
  Windows XP (SP3)
  Huxley ( eMaker )
  Sanguinololu board 1.3a ( RepRap Wiki )
  Arduino ( version 23 )
  AVRISP mkII ( Atmel )

I acquired the AVR programmer to install software onto a McWire as I had the time but not the money. Now I have the money, but not the time. "C'est la vie". At this time the fist thing I discovered was that Arduino IDE (Integrated Development Environment) needs a different driver for the AVRISP mkII than the Atmel programming environment uses. So its important to ensure that if you wish to use the AVRISP programmer, you install the correct driver that works with Arduino IDE. I think that using an Arduino as an ISP to program a boot loader is really cool. But if you use the same Arduino board as both boot loader programer and development board then one day you are going to end up stuck! A spare Arduino board of course is always cool.


Installing the correct AVRISP driver for Arduino 23
Assuming you have the Arduino IDE installed, the driver for the AVRISP mkII is bundled with the Arduino IDE software distribution. So on a clean system, its simply a matter of installing the driver.

If you have installed the Atmel IDE (Studio), I suggest you remove the software as both device drivers enabled will conflict. It can always be re-installed later. Alternatively you could disable the Atmel driver and switch between them, I haven't tried this but it should work in principle.

With Windows and USB devices, frequently the software is installed prior to plugging in the device. If, like me, you do it the other way round; follow the screen shots shown.



Hardware found dialog box
Install new hardware software search location dialog box








Install new hardware, software location selection dialog box


Install new hardware, software location specification dialog box
On my system this was:
C:\arduino-0023\hardware\tools\avr\utils\libusb\bin

Install new hardware, software installation dialog box








The net result of all this effort should be a driver which shows up in the device manger as a LibUSB-Win32 Device.
 

Sanguinololu board connections ready for boot loader programming
Sanguinololu re-programming connections
Now we need to install a boot loader onto the the ATmega 1284P-PU part and to do this we will need to connect to the Sanguinololu PCB. The connections are shown in the picture.

Sanity warning
Incorrectly removing or inserting the chip is almost certainly going to retire the device and potentially the PCB as well. Check many times BEFORE powering up!!

Removal of the original device can be tricky! The PCB and chip are easily damaged. On the board in the picture the 40 pin device is inserted into a socket allowing removal of the device. My 'weapon of choice' for such activities is a small 3mm diameter terminal screw driver with a shank around 10cm long. Keeping the screw driver as parallel as possible ease the screwdriver under the device and lever up at a small angle evenly lifting the device up by around 2 mm. Then move the screwdriver further in and repeat, trying to keep the device parallel to the PCB as you lever it out of the chip holder (IC Socket). With care and patience the device will pop out without so much as a disturbed leg. Be careful to lever only against the ribs of the socket under the chip and not components or the PCB. If you do you will damage the point you are reacting against.

You can see that two type B USB connections are being used here. The Sanguinololu USB connection is to power the board from the 5v of the host computer. The AVRISP mkII also needs a connection and is plugged into the Sanguinololu ISP/SPI port, so this may require you to unplug an SD card adapter from the ISP/SPI port if fitted.

This image is shown with the board not connected to Huxley #710. In fact Huxley #710 was re-programmed in-situ i.e. all motors and other connections in place. The picture was taken to make it clearer what's needed for reprogramming. We also have a spare Sanguinololu, so it was easier to take a nice picture. I intend to donate the old chips to the RepRap foundation.


With these connections were now ready to program the boot loader.

Sanguinololu AVRISP MkII boot loader programming
With everything installed and the board connected we are now ready to program the ATmega 1284P-PU part with a boot loader.

First select the correct target device










Next select the programmer device to be used to program or 'burn' the boot loader code onto the ATmega 1284P-PU










Whilst the boot loader is being upload the Arduino 23 IDE displays the 'please wait' message

When the boot loader has been uploaded the Arduino 23 IDE displays the done message. We are now ready to load the firmware of our choice onto the target through the USB serial port without the need for the AVRISP.


Of course the connections etc. work just as well if you want to burn a boot loader onto an ATmeage 644P-PU devices as well.




 Next step is to load the firmware code of your choice


Downloading Marlin onto ATmega 1284P-PU
To be able to compile the firmware code of your choice you will need a version of WIRE for the Arduino 23 IDE, you can get this here. You may also need the Sanguino code as well from here. Note the comments on the move to version 1 of the Arduino IDE 5 days ago (September 08th 2012). I shall be testing a move to version 1 of the Arduino IDE this week

If you haven't downloaded code before then these are the steps necessary to put Marlin onto your ATmega 1284P-PU

Press and hold the reset button until you see the text in the 'Binary sketch size ....' text. As soon as this text is displayed release the reset button. On Arduino 23 no indication is given that anything is happening over the next stage.


When the down load has completed successfully then the done message is displayed.
 
If you get an error message similar to the one shown, here are a few of the most common causes (not in any order):

  Target device not plugged in correctly
     - check chip seating
     - check USB cable connections
  Reset link on PCB in wrong state
    - make sure the reset link is in the correct state on the Sanguinololu PCB
  FTDI Driver not installed correctly
    - Use the Arduino 023 FTDI drivers
  Wrong board type selected as the target device
     - select correct board type in the Arduino IDE
     - ensure board type settings in boards.txt and avrdude.conf of the Arduine IDE are correct
  Target device won't respond
    - baud rate too high for computer or cable, lower baud rate and get a better cable
  Target device really is the wrong one
    - put in the correct device
  Target device is incorrectly inserted (wrong way round)
    - buy a new target device

  Device is not correctly synchronizing with Arduino IDE
    - re program boot loader code
    - re load firmware


Useful links
  http://stevesfixitshop.blogspot.co.uk/2011/12/sanguinololu-13a-part-2-trouble-in.html
  https://s3.amazonaws.com/rms-projects/Sanguino-0023/Wire-Sanguino-0023.zip
  http://code.google.com/p/sanguino/downloads/detail?name=Sanguino-0023r4.zip&can=2&q=
  Marlin ( ErikZalm / Marlin )
  Pronterface ( eMaker Sources )
  Wikipedia ( Arduino )

Contents of boards.txt for the 1284P
##############################################################
atmega1284.name=Sanguino W/ ATmega1284p 16mhz
atmega1284.upload.protocol=stk500
atmega1284.upload.maximum_size=131072
atmega1284.upload.speed=38400
atmega1284.bootloader.low_fuses=0xFF
atmega1284.bootloader.high_fuses=0x99
atmega1284.bootloader.extended_fuses=0xFF
atmega1284.bootloader.path=atmega
atmega1284.bootloader.file=ATmegaBOOT_168_atmega1284p.hex
atmega1284.bootloader.unlock_bits=0x3F
atmega1284.bootloader.lock_bits=0x0F
atmega1284.build.mcu=atmega1284p
atmega1284.build.f_cpu=16000000L
atmega1284.build.core=arduino


Contents of arduino.conf
#------------------------------------------------------------
# ATmega1284P
#------------------------------------------------------------

# similar to ATmega164p

part
    id               = "m1284p";
    desc             = "ATMEGA1284P";
    has_jtag         = yes;
    stk500_devcode   = 0x82; # no STK500v1 support, use the ATmega16 one
    avr910_devcode   = 0x74;
    signature        = 0x1e 0x97 0x05;
    pagel            = 0xd7;
    bs2              = 0xa0;
    chip_erase_delay = 9000;
    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
                       "x x x x  x x x x    x x x x  x x x x";

    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 x  x x x x",
                       "x x x x  x x x x    x x x x  x x x x";

    timeout        = 200;
    stabdelay        = 100;
    cmdexedelay        = 25;
    synchloops        = 32;
    bytedelay        = 0;
    pollindex        = 3;
    pollvalue        = 0x53;
    predelay        = 1;
    postdelay        = 1;
    pollmethod        = 1;

    pp_controlstack     =
        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02;
    hventerstabdelay    = 100;
    progmodedelay       = 0;
    latchcycles         = 6;
    togglevtg           = 1;
    poweroffdelay       = 15;
    resetdelayms        = 1;
    resetdelayus        = 0;
    hvleavestabdelay    = 15;
    chiperasepulsewidth = 0;
    chiperasepolltimeout = 10;
    programfusepulsewidth = 0;
    programfusepolltimeout = 5;
    programlockpulsewidth = 0;
    programlockpolltimeout = 5;

    idr                 = 0x31;
    spmcr               = 0x57;
    allowfullpagebitstream = no;

    memory "eeprom"
        paged           = no; /* leave this "no" */
        page_size       = 8;  /* for parallel programming */
        size            = 4096;
        min_write_delay = 9000;
        max_write_delay = 9000;
        readback_p1     = 0xff;
        readback_p2     = 0xff;
    read            = "  1   0   1   0      0   0   0   0",
                          "  0   0   x   x    a11 a10  a9  a8",
                          " a7  a6  a5  a4     a3  a2  a1  a0",
                          "  o   o   o   o      o   o   o   o";

    write           = "  1   1   0   0      0   0   0   0",
                          "  0   0   x   x    a11 a10  a9  a8",
                          " a7  a6  a5  a4     a3  a2  a1  a0",
                          "  i   i   i   i      i   i   i   i";

    loadpage_lo    = "  1   1   0   0      0   0   0   1",
              "  0   0   0   0      0   0   0   0",
              "  0   0   0   0      0  a2  a1  a0",
              "  i   i   i   i      i   i   i   i";

    writepage    = "  1   1   0   0      0   0   1   0",
              "  0   0   x   x    a11 a10  a9  a8",
              " a7  a6  a5  a4     a3   0   0   0",
              "  x   x   x   x      x   x   x   x";

    mode        = 0x41;
    delay        = 10;
    blocksize    = 128;
    readsize    = 256;
      ;

    memory "flash"
        paged           = yes;
        size            = 131072;
        page_size       = 256;
        num_pages       = 512;
        min_write_delay = 4500;
        max_write_delay = 4500;
        readback_p1     = 0xff;
        readback_p2     = 0xff;
        read_lo         = "  0   0   1   0      0   0   0   0",
                          "a15 a14 a13 a12    a11 a10  a9  a8",
                          " a7  a6  a5  a4     a3  a2  a1  a0",
                          "  o   o   o   o      o   o   o   o";

        read_hi         = "  0   0   1   0      1   0   0   0",
                          "a15 a14 a13 a12    a11 a10  a9  a8",
                          " a7  a6  a5  a4     a3  a2  a1  a0",
                          "  o   o   o   o      o   o   o   o";

        loadpage_lo     = "  0   1   0   0      0   0   0   0",
                          "  0   0   x   x      x   x   x   x",
                          "  x  a6  a5  a4     a3  a2  a1  a0",
                          "  i   i   i   i      i   i   i   i";

        loadpage_hi     = "  0   1   0   0      1   0   0   0",
                          "  0   0   x   x      x   x   x   x",
                          "  x  a6  a5  a4     a3  a2  a1  a0",
                          "  i   i   i   i      i   i   i   i";

        writepage       = "  0   1   0   0      1   1   0   0",
                          "a15 a14 a13 a12    a11 a10  a9  a8",
                          " a7   x   x   x      x   x   x   x",
                          "  x   x   x   x      x   x   x   x";

    mode        = 0x41;
    delay        = 10;
    blocksize    = 256;
    readsize    = 256;
      ;

    memory "lock"
        size            = 1;
        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
                          "x x x x  x x x x   x x o o  o o o o";

        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
                          "x x x x  x x x x   1 1 i i  i i i i";
        min_write_delay = 9000;
        max_write_delay = 9000;
      ;

    memory "lfuse"
        size            = 1;
        read            = "0 1 0 1  0 0 0 0   0 0 0 0  0 0 0 0",
                          "x x x x  x x x x   o o o o  o o o o";

        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 0 0 0",
                          "x x x x  x x x x   i i i i  i i i i";
        min_write_delay = 9000;
        max_write_delay = 9000;
      ;

    memory "hfuse"
        size            = 1;
        read            = "0 1 0 1  1 0 0 0   0 0 0 0  1 0 0 0",
                          "x x x x  x x x x   o o o o  o o o o";

        write           = "1 0 1 0  1 1 0 0   1 0 1 0  1 0 0 0",
                          "x x x x  x x x x   i i i i  i i i i";
        min_write_delay = 9000;
        max_write_delay = 9000;
      ;

    memory "efuse"
        size            = 1;

        read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
                          "x x x x  x x x x  o o o o  o o o o";

        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
                          "x x x x  x x x x  1 1 1 1  1 i i i";
        min_write_delay = 9000;
        max_write_delay = 9000;
      ;

    memory "signature"
        size            = 3;
        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x  x",
                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
      ;

    memory "calibration"
        size            = 1;

        read            = "0 0 1 1  1 0 0 0   0 0 0 x  x x x x",
                          "0 0 0 0  0 0 0 0   o o o o  o o o o";
        ;
  ;