Skip to content. | Skip to navigation

Personal tools

Parts Tutorial Chapter 3

Previous Chapter: 2

 

Chapter 3: The rest of the XML file! and the folder!

Now that we have filled out most of the XML file and created our beautiful images, all we have to do is finish off the XML file, put all this stuff in a folder, and then put this folder in the right place.

Before we fill out the rest of the XML file we are going to need to do a few calculations. But, before we do that I think I should explain the what and why of these calculations. The calculations are going to set our Diode legs in the right spots, on the part and on the board. Below is the code in which we will enter numbers, take a look.

    <gridOffset x="0" y="0" units="himetric"/>
<bounds width="500" height="260" units="himetric"/>
<connectors units="tenths">
<nameLayout visible="false" />
<connector id="+" name="+" type="leg">
<point x="0" y="130" units="himetric"/>
<point x="-1" y="2" />
</connector>
<connector id="-" name="-" type="leg">
<point x="500" y="130" units="himetric"/>
<point x="2" y="2" />
</connector>
</connectors>

let's just go over this piece by piece.

    <gridOffset x="0" y="0" units="himetric"/>

The grid offset is used to position the part properly on Fritzing's stage. It is calculated from the top-left of the part image, for example, if we had a part with rounded corners, the top-left of the image would be the point where the top of the part and the left most edge of the part cross each other at a square angle.
We use a grid offset because not every part we make is on the 'tenth', having our parts on the tenth makes it easier for us to arrange our parts and connect their legs on the breadboard. It is the parts internal reference point and is the point from where all other sizes are measured.

    <bounds width="500" height="260" units="himetric"/> 

we already filled this line out in chapter 2, this is the bounding box that rectangles your part. It is important to note that the <bounds> tag is directly related to the size of the images used in Fritzing. If you have taken some artistic liberties in your image creation, now is the time to double check your numbers against your images. The easiest and most precise way to do this is to measure the 'part400.png' in pixels and multiply by 6.35. If you take a look at 'part400.png' from the previous chapter, its measurements in pixels are 82x42.

    <bounds width="521" height="267" units="himetric"/> 

82 x 6.35 = 520.7 after rounding gives us a width of '521'
42 x 6.35 = 266.7 after rounding gives us a height of '267'

    <connectors units="tenths">

The beginning of our connectors tags, all the information we need about our connectors is contained in this tag.

        <nameLayout visible="false" />
<connector id="+" name="+" type="leg">
<point x="0" y="133" units="himetric"/>

The first 'point' tag is the location of the starting point of the leg as it starts on the part. For this starting point we calculate its location in himetric because these are the units we build our parts in.

            <point x="-1" y="2" />

The second 'point' tag gives us the ending point of the leg. This point is calculated in 'tenths' so that the ends of our legs snap nicely into the breadboard.

        </connector>
<connector id="-" name="-" type="leg">
<point x="521" y="133" units="himetric"/>
<point x="2" y="2" />
</connector>
</connectors>

When we drew this part we made it a perfect rectangle, we can just make the gridOffset 0, 0. we will make our adjustments for the locations of the start and end point of our legs. The gridOffset and the starting points for our legs (the points x and y, calculated in himetric) have a balanced relationship, changing one of the coordinates in one place requires an inverse change in the other.

Since we have made our gridOffset 0, 0, we don't really have a gridOffset. This makes it easier to talk about our leg locations and what is in between them.

The first point we've set in the XML file is:

            <point x="0" y="133" units="himetric"/>

x = 0 because we are starting our leg on the left edge of the part, and we've started with a grid offSet of 0 for this axis.

y = 130 because we want our leg to come out in the middle of our part on the y axis. Since our part is 267 himetric units tall (or y) and the gridOffset is 0, 133 is the middle point. However, if we had a gridOffset of 10 for the y axis, to specify the middle point of our part we would need to add that to our total, making the point y 117.

Now we want to put all of our files together in a place where Fritzing can find it!
Place all of the images and the XML file into a folder and name the folder 'Diode'. Our files and folders are organized according to the species and genus that we entered into our XML file in Chapter 1 of this tutorial.

The folder with everything in it goes into the 'Basic' folder inside your own personal 'user' folder, like this: 'fritzing-0005\libraries\user\Basic'. If a folder called Basic doesn't exist in your user folder, make one if you want to keep your parts organized by genus+species.

The last thing we are going to do is make the proper footprint so that our part can be exported to Eagle.

Chapter 4: coming soon!!
Please be patient! <3

Document Actions
© 2007- 2008 University of Applied Sciences Potsdam \ Powered by Plone