9:55 PM
10:00 PM
Eagle CAD Tips and Tricks
10:00 PMEagle CAD Tips and Tricks: Most hobbyists and many professionals use Eagle CAD as a daily tool in designing schematics and laying ...
Eagle CAD Tips and Tricks:
Most hobbyists and many professionals use Eagle CAD as a daily tool in designing schematics and laying out PCB. I’m going to share with you the most important tips and tricks for using Eagle CAD, which make my work much easier and faster.
Tip #1: Keep One Hand on the Keyboard, One on the Mouse
I see a lot of friends and colleagues use the mouse as their main tool for routing and selecting tools in the sidebar, but it’s much easier and faster to use the command line whenever you can.
By using your keyboard, you will omit the time you spend searching for the desired icon and moving mouse pointer back and forth.
My advice is to keep one hand on the mouse to do wiring, etc. inside the editor workspace and use the other hand on the keyboard to write commands and select tools. My advice of using the keyboard is not only for selecting tools. You will see the other benefits of using the keyboard in Eagle CAD in the rest of this series.
It can be difficult to remember the spelling and the name of every tool. The good news that the command line only needs the smallest accepted spelling to select the tool for you, so you don’t have to write down the complete word.
The table below shows the most-used tools and their corresponding shortest commands. To avoid duplication, the common tools between the schematic and board will not be listed twice:
Tool Name | Command (All accepted for command editor) |
Add element to schematic | a,ad,add |
Net | ne,Net |
Move | Mov,move |
Copy | Cop,copy |
Name | n,na,nam,name |
Value | v,va,value |
Label | l,la,lab,labe,label |
Text | T,tex,text |
Tool Name | Command (All accepted for command editor) |
Route | rou,rout,route |
Ripup | ri,rip,ripu,ripup |
Via | Vi,via |
Ratsnest | r,ra,rat,rasts,ratsn,ratsne,ratsnest |
Other useful and exclusive uses of the keyboard can be mapped as below (just two examples for now):
1- Text Tool:
When you select the text tool, you write your sentence in the pop-up window and then drop it wherever you want. But what if you want to add more?
In this case, just write down your sentence and hit enter without needing to select the text tool icon again.
2- Show Tool:
This tool is used exclusively with the keyboard. You need to enter the element name using the command line to highlight it. For example:
>Show R1
Or
>Show R1* (to show all elements start with R1)
This applies also for signal names.
3- Others:
To keep you excited (and to make things more organized), I will delay talking about other tools that are exclusively used with the command line to their respective tip/trick.
Tip #2: Use Your Mouse Effectively
There are many practical uses of the mouse in Eagle CAD, more than just using it as a pointer:
1- Changing Layer Using the Scroll Button:
Let's say you are routing your PCB. A lot of people used to change the layer of an object using the layers drop-down menu.
However, by using the mouse, you can change the layer by pressing the scroll button.
2- Change Wire Bend Styles:
Changing wire bend styles is one of the most common processes while routing.
The hard way is to change styles by selecting the wire bend style from upper toolbar every time. The easy way is by pressing the right mouse button.
You can see the practice of the past two mouse usages in the gif below:
Tip #3: Hit RATSNEST to Know How Many Signals Are Still Unrouted
By pressing RATSNEST, the number of unrouted wires (airwires) is shown in the bottom-left corner of the editor.
This feature is very useful for double-checking that you didn't miss any airwires, especially since sometimes you may not notice them when searching visually.
Tip #4: Make the Help Manual Your Friend
Whenever you want to learn more about the tool you're using, press F1 and read about it!
You will find really handy hidden usages of each tool in the manual.
And now for the "tricks"!
Trick #1: Change Wire Width without Moving Your Mouse
You can change the wire width without going to the width menu! Just write the width number and hit enter while you're holding the wire.
Trick #2: Hide Any Unrouted Wires You Want
The most annoying signal that contributes to a feeling of incompleteness and complexity is the GND signal.
You could hide it, or any other signal, by using the RATSNEST command in this form:
>ratsnest !
For example:
>ratsnest ! GND
To make it visible again just omit ‘!’:
>ratsnest GND
Trick #3: Turn Polygons Off
Let's say you've drawn a power polygon, like VCC or GND, and now you need to change some routes. Polygons become very annoying in this case because whenever you hit RATSNEST, a polygon will fill the PCB again.
You can keep working without polygons until you want to enable them again. Without deleting them, you can just turn them on or off as you like.
To turn polygons off, select ripup tool, ripup polygon, then write this command:
>set poly off
To turn them on, type this command:
>set poly on
Tool Name | Command (All accepted for command editor) |
---|---|
Add element to schematic | a,ad,add |
Net | ne,Net |
Move | Mov,move |
Copy | Cop,copy |
Name | n,na,nam,name |
Value | v,va,value |
Label | l,la,lab,labe,label |
ext | T,tex,text |
Tool Name | Command (All accepted for command editor) |
---|---|
Route | rou,rout,route |
Ripup | ri,rip,ripu,ripup |
Via | Vi,via |
Ratsnest | r,ra,rat,rasts,ratsn,ratsne,ratsnest |
Tip #5: Best Practices to Find the Parts You Need
Before searching on the internet for new libraries to add to Eagle, first make sure that your device does not already exist in your local libraries. To check, use a search pattern that includes ‘*’.
For example, if you want to add a 7805 5v regulator, you must search for *7805* instead of 7805. This will search for any part with 7805 in the middle of the name, without regard for the beginning or end of the part name.
Certain manufacturers may have their own extensions, and Eagle search is not smart enough to know these extensions for you. This explains why sometimes search can't pull up a part that you know is present, even when you search in an explicit way. You can see from the below GIF how search results will change using this tip:
If you didn't find your part, or at least a reasonable alternative (for example, an atmega8 device instead of atmega328 device), then try to add public libraries from other popular producers and designers like:
1. SparkFun
2. AdaFruit
If the parts you want to use were used in previous open source board, you can export these parts from (File>Export) and reuse them again in your design.
Tip #6: Don’t Always Trust Third-Party Libraries
Keep in mind that unverified parts are always there in the cloud. Especially when you use a library from an untrusted party, you need to make sure that you double-check the footprint and device connection with package pads to avoid errors in your PCB connections.
Tip #7: Use the Eagle Reference Library
When you build your own library, keep in mind that there is a reference library in Eagle called "Ref-packages.lib". This library has most packages' footprints, which make the creation of new libraries much easier.
Just copy the package to your library, then reuse it again to create a new device. This will save a lot of time and errors.
And now for the "tricks" section.
Trick #4: Ripup All Polygons with One Command
When you work on circuits with applications like high-power signals and you use more than just GND and VCC polygon planes, you can ripup all polygons using one command:
>ripup @ ;
This is much better than ripping up every polygon manually.
Trick #5: Route Your Trace from Any Point You Want
When you route a trace in PCB, you must have an airwire first. Eagle calculates the shortest path for the airwire and then draws it, but in some cases you need to use a different path than the default one.
You can draw a trace from any point by selecting the route tool and pressing ctrl with left click on the desired point.
Trick #6: Adding a Bar to a Signal Name
You can add a bar to a signal name,active low signal, using this formula:
>name !RES
If you need to add a bar just to a section, then use this formula:
>name !RES!_MCU
Trick #7: Enable/Disable Layers View
When you have your final design of PCB and you need to review it before sending the Gerber files to a manufacturer, a good practice is to review each group of layers individually.
For example, you can review the Top, tPlace, tOrigins, tNames, and tDocu layers, THEN the Bottom, bPlace, bOrigins, bNames and bDocu layers. Instead of choosing every single layer you want, you could disable/enable them using one command: DISPLAY.
The DISPLAY command is used to disable/enable view of the layers. Parameters of this command could be ALL to make all layers visible, or NONE to turn all layers off. You must put the layer name or the layer number as a parameter— when you use a negative sign before your layer name, the corresponding layer will be filtered out.
The following command will make just the Bottom layer visible:
DISPLAY NONE BOTTOM;
The following command will make TOP layer visible and hide BOTTOM layer:
DISPLAY TOP -BOTTOM ;
Here are some commands I formed that I'd like to share with you. I use these each time I review a design:
- Top Layers:
DISPLAY Top tPlace tOrigins tNames tDocu Dimension -Bottom -bPlace -bOrigins -bNames -bDocu;
- Bottom Layers:
DISPLAY Bottom bPlace bOrigins bNames bDocu Dimension -Top -tPlace -tOrigins -tNames -tDocu;
- Complete:
DISPLAY Bottom bPlace bOrigins bNames bDocu Dimension Top tPlace tOrigins tNames tDocu;
- Complete without naming:
DISPLAY -tNames -bNames Bottom bPlace bOrigins bDocu Dimension Top tPlace tOrigins tDocu;
Trick #8: Show the History of Some Icons
There is a useful hidden feature in EAGLE GUI which is shows the history of some icons, like ULP and Open.
So if there is a ULP and you use it in a regular base, you can just right-click on the ULP icon and a menu of the history of recently used ULPs will pop up.
Trick #9: The Renumbers Parts Tool
When you work on big projects and you have a really big schematic, you will need to do a lot of changes by adding and deleting components during verifying phase. This will make some mess in your number of parts.
For example, when you have resistors with numbers from R1 to R50, and you need to delete resistors from R10 to R12 and R25 to R30, R51 will be the number which Eagle will use when you add the next resistor.
For this reason, Eagle has a tool, ULP. In fact, ULP can do a renumbering for you instead of doing it manually, which is very hard in big schematics.
You can choose this tool via tools>Renumber parts— or via the ULP icon and selecting "renumber-sheet.ulp".
9:34 PM
Introduction to Capacitive Touch Sensing
9:34 PMIntroduction to Capacitive Touch Sensing: In this article, we will take a detailed (but not too detailed) look at the electrical pri...
Introduction to Capacitive Touch Sensing:
In this article, we will take a detailed (but not too detailed) look at the electrical principles that allow us to detect the presence of a human finger using little more than a capacitor.
Capacitors Can Be Sensitive
Within the last decade or so, it has become difficult indeed to imagine a world without touch-sensitive electronics. Smartphones are a prominent and ubiquitous example, but of course, there are numerous devices and systems that incorporate touch-sensitive functionality. Both resistance and capacitance can be employed as a means to achieving touch sensitivity; in this article, we will discuss only capacitive touch sensing, which has emerged as the preferred implementation.
Though applications based on capacitive touch sensing can be quite sophisticated, the fundamental principles underlying this technology are fairly straightforward. Indeed, if you understand the nature of capacitance and the factors that determine the capacitance of a particular capacitor, you are well on your way to understanding capacitive touch sensing.
Capacitive touch sensors fall into two general categories: the mutual-capacitance configuration and the self-capacitance configuration. The former, in which the sensing capacitor is composed of two terminals that function as emitting and receiving electrodes, is preferred for touch-sensitive displays. The latter, in which one terminal of the sensing capacitor is connected to ground, is a straightforward approach that is suitable for a touch-sensitive button, slider, or wheel. This article presents the self-capacitance configuration.
The PCB Capacitor
Capacitors come in many forms. We’re all accustomed to seeing capacitance in the form of leaded components or surface-mount packages, but actually, all you really need is two conductors separated by an insulating material (i.e., the dielectric). Thus, it is quite simple to create a capacitor using the conducting layers incorporated into a printed circuit board. For example, consider the following top view and side view representations of a PCB capacitor used as a touch-sensitive button (note that the solder-mask layer is omitted in the side-view diagram).
The insulating separation between the touch-sensitive button and the surrounding copper creates a capacitor. In this case, the surrounding copper is connected to the ground node, and consequently, our touch-sensitive button can be modeled as a capacitor between the touch-sensitive signal and ground.
At this point, you might be wondering about how much capacitance this little PCB arrangement really provides. Furthermore, how are we ever going to calculate it accurately. . . ? To answer the first question, the capacitance is very small, maybe around 10 pF. As for the second question: Don’t worry if you’ve forgotten your electrostatics, because the exact value of the capacitor is irrelevant. We are looking only for changes in capacitance, and we can detect these changes without knowing the nominal value of the PCB capacitor.
The Effect of a Finger
So what causes these capacitance changes that the touch-sense controller is going to detect? A human finger, of course.
Before we discuss why the finger changes the capacitance, it is important to understand that there is no direct conduction taking place here; the finger is insulated from the capacitor by the PCB’s solder mask and usually also by a layer of plastic that separates the device’s electronics from the external environment. So the finger is not discharging the capacitor, and furthermore, the amount of charge stored in the capacitor at a particular moment is not the quantity of interest—rather, the quantity of interest is the capacitance at a particular moment.
So then, why does the presence of the finger alter the capacitance? There are two reasons: The first involves the finger’s dielectric properties, and the second involves the finger’s conductive properties.
Finger as Dielectric
We usually think of a capacitor as having a fixed value determined by the area of two conducting plates, the distance between the plates, and the dielectric constant of the material between the plates. We certainly cannot change the physical dimensions of the capacitor just by touching it, but we can change the dielectric constant, because a human finger has different dielectric characteristics than the material (presumably air) that it is displacing. It’s true that the finger will not be located in the actual dielectric region, meaning the insulating space directly between the conductors, but such an “intrusion” into the capacitor itself is not necessary:
As shown in this diagram, the finger does not need to be between the plates to influence the dielectric characteristics because the capacitor’s electric field extends into the surrounding environment.
It turns out that human flesh is quite a good dielectric material because our bodies are mostly water. The dielectric constant of a vacuum is defined as 1, and the dielectric constant of air is just slightly higher (about 1.0006 at sea level and room temperature). The dielectric constant of water is much higher, around 80. So the finger’s interaction with the capacitor’s electric field represents an increase in the dielectric constant and hence an increase in the capacitance.
Finger as Conductor
Anyone who has experienced an electric shock knows that human skin is conductive. I mentioned above that direct conduction between the finger and the touch-sensitive button—i.e., a situation in which the finger discharges the PCB capacitor—does not occur. However, this doesn’t mean that the conductivity of the finger is irrelevant. It is actually quite relevant because the finger becomes the second conductive plate of an additional capacitor:
For practical purposes, we can assume that this new capacitor created by the finger (let’s call it the finger cap) is in parallel with the existing PCB capacitor. This situation is a bit complex because the person using the touch-sensitive device is not electrically connected to the PCB’s ground node, and thus the two capacitors are not “in parallel” in the typical circuit-analysis sense.
However, we can think of the human body as providing a virtual ground because it has a relatively large capacity to absorb electric charge. In any event, we don’t need to worry about the exact electrical relationship between the finger cap and the PCB cap; the important point is that the pseudo-parallel configuration of the two capacitors means that the finger will increase the overall capacitance because capacitors add in parallel.
Thus, we can see that both mechanisms governing the interaction between the finger and the capacitive touch sensor contribute to an increase in capacitance.
Proximity vs. Contact
The preceding discussion leads us to an interesting feature of capacitive “touch” sensing: a measurable change in capacitance can be generated not only by contact between the finger and the sensor but also byproximity between the finger and the sensor. I usually think of a touch-sensitive device as a replacement for a mechanical switch or button, but capacitive sensing technology actually introduces a new layer of functionality by allowing a system to determine the distance between a sensor and a finger.
Both of the capacitance-altering mechanisms described above produce effects that are proportional to distance. For the dielectric-constant-based mechanism, the amount of fleshy dielectric interacting with the capacitor’s electric field increases as the finger moves closer to the conductive portions of the PCB capacitor. For the conductivity-based mechanism, the capacitance of the finger cap (as with any cap) is inversely proportional to the distance between the conducting plates.
Keep in mind, though, that this is not a method for measuring the absolute distance between the sensor and the finger; capacitive sensing does not provide the sort of data that would be needed to perform precise absolute distance calculations. I assume that it would be possible to calibrate a capacitive sense system for rough distance measurements, but since capacitive sense circuitry is designed to detect changes in capacitance, it follows that this technology is particularly suitable for detecting changes in distance, i.e., when a finger is moving closer to or farther from a sensor.
Conclusion
You should now have a solid conceptual foundation upon which to build a soaring edifice of capacitive-touch-sense expertise. We’ll start construction in the next article by looking at implementation techniques that will help you to transition from theory to practice.
9:06 PM
MicroFAT: A File System for Microcontrollers
9:06 PMMicroFAT: A File System for Microcontrollers: File systems can be great for handling data and organizing memory, but most file sys...
MicroFAT: A File System for Microcontrollers:
File systems can be great for handling data and organizing memory, but most file systems require large amounts of memory. This is where MicroFAT comes in!
The Problem with Standard File Systems
Microcontrollers are becoming the core of many electronic projects for hobbyists and the norm in electronic design overall. With the complexity of projects increasing and the introduction of the IoT, it will not be long before micro users will need to also increase the capabilities of microcontrollers.
A common use for microcontrollers is to log data from sensors such as temperature, humidity, and other stimuli. This data can be streamed to an I2C EEPROM and then read back when this data is to be sent to an external server (via the IoT). If the user wishes to store separate instances of data (for example, different times of the day), then the memory needs to contain information regarding the time the data was sent and how the memory is organised.
While the user could design a system to cope with such matters, it would be easier to implement a file system such as FAT. However, many micros are not capable of using the FAT file system because of the memory requirements.
For example, to use FAT32 on the PIC range requires up to 12KB of program memory, 2KB of data memory. FAT16 and FAT32 are also not ideal for 8-bit systems and contain a lot of unnecessary metadata (file creation date, permissions, etc.).
Because the file system is for private use between the microcontroller and serial memory, the system does not need to be compatible with PC standards. If files are to be transferred between a microcontroller and PC, then a simple application made in either Visual C#, C++, or BASIC could stream the bytes in and then save to a file.
MicroFAT is a standard currently in development for use in 8-bit designs which has emphasis on low memory usage, smaller block sizes, and an easier interface. For example, the MicroFAT standard is designed to be used with serial memory so there is no need for a RAM copy of the current working directory (which would otherwise need an additional 256 bytes). This is because serial memory holds its own internal address and therefore any file operations need only to set the memory address to the directory location and stream in data byte by byte.
Generic Layout
Two memory models are possible with the MicroFAT system: absolute address and block address. As all addresses in the file system are encoded with a 16-bit number, the maximum number of locations is 65,535. Therefore, this allows for either 64KB (when the address points to individual bytes) or 16MB (with 256 byte block sizes).
Absolute addressing has the advantage of storing file sizes to the byte value (such as 10 bytes), whereas the block address model can only store file sizes as blocks (not ideal for file streaming). The larger memory model also requires the current address pointer to be stored for individual bytes in the current block but the advantage is the significantly larger amount of memory.
For the sake of implementation, this article considers the absolute addressing mode for MicroFAT as I2C serial memory to typically range from 1KB to 64KB.
All 16-bit values are in little endian form which means that the lower portion of the 16-bit number is stored in memory first with the upper portion stored afterwards. An example is given below:
The number 0x5ADA is stored in memory location 0x0010. This means that memory location 0x0010 has the number 0xDA and the memory location 0x0011 has the number 0x5A.
Memory Blocks
Memory is split into blocks of 256 bytes, which makes addressing very easy. As most FAT operations are concerned with blocks and 64KB is split into 256 blocks, only an 8-bit counter is needed to point to blocks in the system.
The very first block in memory is the root directory and is used to store information regarding the bitmap location and device size. It can also be used to indicate boot options and other configuration data regarding the file system.
Bitmap Block
When an operation requires a block in memory, it must not use a block that is in use. One block is devoted at the very end of the memory which keeps a record of the state of each individual block: This block is referred to as the bitmap block. Its purpose is to keep track of a block's state, such as if it's currently in use or damaged (unusable). As each block is represented by 1 byte additional information can be encoded into the bitmap system by the user (e.g. reserved / system / boot).
The location of the bitmap needs to be at the very end of the memory and its location must be stored in entry 0 of the root directory.
Since MicroFAT has two memory models (absolute and block), the bitmap is encoded as shown below.
- Absolute Addressing: Each block is represented by one byte
- Bit 0 – Block is in use
- Bit 1 – Block is damaged
- Bit 2:7 – Unused (Free for user)
- Block Addressing: Each bitmap byte represents 8 blocks. Each of the bits indicated if that block is in use or not. Damaged memory cannot be encoded.
Directories
Directories are 256 bytes in length (1 block) and can hold up to 16 entries. The first entry (FAT INFO) stores information about the current directory, which includes the block location of the parent directory (useful when going up a directory) and the current directory block location. The root directory contains an additional 4 bytes in its FAT INFO: the device size and the bitmap location.
File and Directory Entries
All entries, both directories and files, are 16 bytes in length (unlike the 32 bytes needed in FAT). Each directory holds up to 15 files/folders with the first 16 bytes being devoted to directory information.
Entry Type Byte (0xn0)
Bit 0 | Bit 1 | Bit 2 | Bit 3 | Bit 4 | Bit 5 | Bit 6 | Bit 7 |
In Use | File / Folder | Read Only | System File | Invisible | Not used | Not Used | Not Used |
1 - Yes | 1 - File | 1 - Read Only | 1 - Sys File | 1 - Invisible | |||
0 - No | 0 - Folder | 0 - RW | 0 - User File | 0 - Visible |
As each entry is only 16 bytes in length, it is easy to get to specific entries with the upper four bits of the address. Adding 0x10 and then performing a logical and with 0xF0 will get to either the next entry or the first entry (if the number overflows). Below is an example of getting to the next file in Z80 assembler:
nextEntry: ld a, (fileCounter)
add 0x10
and 0xF0
ld (fileCounter), a
Here is an example of a test root directory that shows the bitmap location, device size, and a few entries:
File Storing - Linked List
Files use the linked list system where the last two bytes of a block point to the next block to load. If the block pointer is 0x0000 then the end of the file has been reached as block 0x0000 refers to the root directory which is a reserved block. This means that the usable data in a block is actually 254 bytes. The benefit of this is that a table of file block ownership is not needed and significantly reduces the amount of memory needed.
The location of the first block is defined in the file entry bytes 0x01 and 0x02. The bytes are stored in little endian (like all data in the MicroFAT system), so if for example the file block was located at 0x1000, the entry bytes would be seen as 0x0001.
When deleting files, it is important that the file is scanned through the entire list to find which blocks are in use so that the bitmap can free the old blocks. It is also important that the last two bytes of every block are replaced with 0x0000 when freed so that the system does not mistake the end of the file as a load next block.
Infinite loop issue
The link system can get stuck in an infinite loop if the end-of-file pointer points to a previous block in the chain. It would be easy to create a search function that checks for such loops by keeping a record of all blocks loaded and comparing the next block load with the table. Once the file is loaded, the table can be discarded and the memory freed. If the small memory model is used, then a single 256-byte entry in memory could store the table comparison values and it would be large enough for any file (remember how blocks can be pointed to with a single 8-bit number).
Implementation
Currently, no implementation in C exists but a preliminary can be downloaded for Z80 assembler. In the future, a generic C header + source will be developed that only expects the user to create the writing and reading functions for MicroFAT. A typical example is given below:
unsigned char memoryRead(unsigned short address)
{
// User writes custom memory access code here
}
void memoryWrite(unsigned short address)
{
// User writes custom memory access code here
}
This enables the user to create his or her own code for accessing any type of serial memory, whether it is SPI, I2C, or even external microcontrollers. The Z80 assembler is still in progress, but functions that work are those with (d) next to their function name in the comments. The rst instructions are designed to work with a custom BIOS but below is a basic set of the I2C memory rst calls that the MicroFAT calls:
I2C External Memory Routines (RST 0x18) : Z80 BIOS Calls | |||
---|---|---|---|
Register A | Function | Registers | Description |
0x00 | Device Probe | Probes I2C Bus for selected device. Returns 1 upon detection | |
0x01 | Device ID | B | Sets current I2C device to register B |
0x02 | Read Byte | Reads a byte from I2C and returns result in register A | |
0x03 | Write Byte | B | Writes a byte to I2C found in register B |
0x04 | Read Block | HL | Reads a block of 256 bytes from I2C memory into address pointed by HL |
0x05 | Write Block | HL | Writes a block of 256 bytes to I2C memory found at address pointed by HL |
0x06 | Set Address | BC | Sets the current memory address of the current device to BC |
It should be noted that the Z80 assembler code provided makes a copy of the bitmap and current directory directly into RAM for the sake of speed. This, in turn, uses an additional 512 bytes but low memory implementation would not need more than 32 bytes of RAM. If the current directory name was needed, then an additional 32 bytes of RAM would be needed to store the name. However, this is only required where the user can access the file system with a keyboard and display.