Saturday, March 31, 2012

config vs config1 explained

Recently I started to use pic18f27j53 for a robot project. I picked it since it had USB functionality, and I thought I could learn about USB through it. Just as I copy-pasted my old code from my previous robot projects, error messages began to show up on the compiler output saying that opentimer1() was missing an argument. This confused me and, upon research, I discovered that many others were confused as well. So I decided to look through the source file (t1open.c) in the C18 library to see why there were two arguments (config and config1) as opposed to just one (config1).

Well, it turns out that some of the new microchip hardware has included some new functionality called Gate Control to the timer hardware, which introduces the possibility of controlling it through external asynchronous inputs such as the comparator module. This, I think, allows users to count the duration of an input.

Anyways, for those who do not intend to use the Gate Control Hardware, config1=0 should do the trick. Since config1 controls TxGCON (Timer X Gate Control), according to the datasheet, if you set config1 to zero Gate Control will be disabled.

Sunday, February 26, 2012

Optical Encoder Protoype



Above is the speed sensor prototype and its schematic. The infrared LED (TSMF1020) and photo-transistor (TEMT2020) will be reading from a rotating disk colored black and white. The photo-transistor will detect the highest levels of infrared light when it sees the white part of the disk, which will lead to a higher voltage drop across the 100 ohm resistor.

The board will be tested to find the optimum system geometry and the system's sensing limitations (e.g. max velocity).

Wednesday, August 10, 2011

Transmission Line Effect: Bouncing Voltages

It's 4am on black Friday at Walmart. A single door opens and millions of people including yourself run to the entrance as one mob. You're running as fast as everybody around you. As the people near the building, those who luckily made it to the door enter the building. However, you, being at the front of the mob and having not run close enough to the door, smash into the outer walls of the building. The people behind you don't see the wall yet and keep running, pushing you into the wall even more. Soon enough, you have the collective force of thousands of people squishing you. 

The same thing happens with voltage. When entering a high impedance load (narrow doorway) from a low impedance cable (wide parking lot), voltage (pain) can spike up as you can see in the simulations below (Line C, top trace). The input voltage is only 100V, but the voltage at the load jumps up to 160V.


When you push back, the people behind you push the people behind them, and a wave of shoving propagates down the mob of people. When this wave reaches the end of the mob (the people at the very back) they push forward and that wave propagates back to you. This phenomenon is called ringing as demonstrated in the oscillation seen in the top trace.

Below are models of cabling. The inductor keeps the current going, just like you want to run at the same speed as the people behind you (to stay alive). The capacitor is like the space infront of you; it's somewhere to run to. Almost all conducting cables can be modeled this way, a chain of infinitesimally small units of L, R, and C. All cables have parasitic inductance and capacitance. Line D and the top trace demonstrates how doubling the cable length (double length of Line C) doubles the amount of time for the voltage to hit the load. This is just like having the parking lot double in length. It takes twice as long for you to run into the wall.
 Moral of the story:
  • Walmart on black fridays is dangerous. 
  • Unexpected voltage spikes fry parts when cables are too long or impedances are not matched.

Tuesday, July 12, 2011

Dual H-Bridge Board

Below is the result of one full week of thinking, layout, and planning. These H-bridges are made to control two small dc motors. The H-bridge can take up to a 500 mA load. This board will probably be integrated into my scrapbot. The simulation for this circuit can be found here.

I am currently working on a microcontroller to modularize the h-bridge unit. The plan is to be able to send serial instructions to the H-bridge driver microcontroller to drive the motor.

Sunday, July 10, 2011

Awesome Resource on PIC ASM

I have recently been working on a project that requires me to return to Microchips Pic Assembly Suite. Having worked mostly on Pic C18 for a while, it was a little difficult to program in assembly again. After a couple minutes of research on the web, I found an awesome resource for Pic hardware and assembly.

Gooligum Electronics has very detailed information on various ranges of hardware complexity and accompanying assembly code to help use the hardware as well. This link will also be included in the useful links box on the right.

Thursday, June 30, 2011

H-bridge simulation

I always believed that to build an H-bridge I needed to use FETs. I'm guessing that it was because of the small device package of Bipolar Transistors that I thought that it will not be able to power it. Well today I realized that some of my motors are probably small enough (low power) to be powered by BJTs. This also made for a great opportunity to test LTSpice some more. Eventually I hope to improve my mobot H-bridge design in efficiency using these tools.

Below are the results. You can see that the flyback diodes really do help protect by limiting the various potential differences to below their respective breakdown levels. The blue trace represents the input signal and the green trace is the voltage at one end of the inductor with respect to ground. 






Saturday, June 25, 2011

WOOOOO! FPGAA

I just got my new FPGA development board, BASYS2, by Digilent. Since everybody at my workplace seems to be using VHDL rather than Verilog, which is what I learned in school, I will be attempting VHDL this summer!

My first project will be to make an oscilloscope by the end of this summer. I will be polling an external analog to digital converter, giving it a time stamp, and sending it over USB to a Python script that will process the data and display it. The reason for using an FPGA is first to get practice with it since it looks like people like digital hardware experience. The second reason is because I can simultaneously poll and communicate if I create a buffer. If I were to do this with a microcontroller I would have to interlace the two actions, which is a pain.

My first step is to make basic components such as a register so I can start creating finite state machines and whatnot.