Categories
Uncategorized

9V battery

The other day I was thinking about 9V batteries. I was wondering about their shape, and why are they a different shape than other batteries such as a C or D cell. Then two things occurred to me: First, the shape of a nine volt is not square on the bottom — it is a rectangle with a ratio of about 2 across by 3 down. You could fit six cylinders inside it neatly. Also, 9 is 6 times 1.5, which is the voltage of an AAA, AA, C or D cell battery. So then I thought, you know what, I bet a nine volt is made of six small batteries wired up in series. Sure enough….
View image

Categories
Uncategorized

Evolution Friday

No, its not Illustration Friday — a website that encourages people to draw something once a week. In reaction to the unending, uneducated, and overly vocalized mantra of creationists heard in school board meetings across the country, I’m launching “Evolution Friday”. My intent is to combat the their “creation science” drivel. As a veteran scientist — hmm, can I call myself that? A war “veteran” is someone who served in a war — even if only for a short time. I have served in science for six years, so I think I ought to qualify. But still, it sounds far to pretention to call myself “veteran”. How about “former”?. As a former scientist, I’ve seen first hand a lot of things that confirm the theory of evolution. It seems the least I could do is share it with you.
Today’s Evolution Friday Topic : Convergent Evolution.
As a student of Ichthyology, I spent a fair amount of time in the lab classifying fish species. Fish inhabit a wide variety of environments: Open ocean, shorelines, estuaries, rivers, streams, lakes, caves and even some extreme environments like arctic waters where the temperature is below freezing. Carl Linneaus (he was working in plants at the time, but his work applies to all living things) noticed that some species were quite similar to one another (such as two species of Oak), but were different than other species. He created a system called Taxonomy, by which he organized species based on these similarities and differences.

0.jpg 1.jpg
2.jpg 3.jpg

One interesting thing about Taxonomy is that something that seem quite similar are in fact quite different. For example, consider sharks, rays, walleye, and flounder. Superficially it seems that the shark and walleye are more similar based on their overall shape. Rays and flounder, on the other hand, while similar to each other, have a much different shape than the shark and walleye. So it would seem that the shark and the fish should be closer together taxonomically, as should the ray and flounder.
But upon closer investigation, it becomes clear that actually the shark and the ray are more similar to each other than either is to the walleye or flounder. And the walleye and flounder are quite similar as well. The shark and ray both have cartilagenous skeletons, whereas the walleye and flounder have bony skeletons. The shark and the ray both have seven gill slits, whereas the walleye and flounder have a single gill structure covered with a bony operculum. The walleye and flounder have different kinds of teeth than the shark and ray. Only the walleye has a swim bladder. Walleye and flounder have scales, the shark and ray have denticles. On a molecular level, the shark and ray share a greater percentage of their nucleic acid sequences than do the flounder and walleye.
This presents a riddle for Creationists. Why are similar functions “designed” in different ways. Both the ray and the flounder are bottom dwellers that move about using vertical oscillations of their limbs, but their structural make-up are radically different. Furthermore, why is the flounder built with a bizarre twisted face, so that one eyeball isn’t wasted staring at the mud? Wouldn’t it make more sense for a designer to build a flounder with its eyes evenly spaced on top? Why would a designer reinvent muscle fibers, skin coverings, neural circuitry, etc. to achieve the same purpose?
These strange observations are easily explained by the theory of evolution. The flounder and they walleye are descended from a common ancestor that looked much like the walleye does today. However, in one lineage, flounder’s ancestors found a good living was to be had by hiding on the sea floor. Eventually random changes accumulated that made flounder’s nearer ancestors more successful at that; it learned to swim on its side, its face started to twist, etc…. A similar process happened with the ray. An ancestral fish, probably lived in a way similar ot the dogfish (a kind of shark) does today — by skulking around on the bottom. Fins got longer and longer, as fish with bigger fins could skulk better. Eventually the fish looked and swam more and more like a ray.
This process by which two species acheive similar functionality via different processes is called convergent evolution. For the flounder and the ray, each acheive the abilities so hide on the bottom of the ocean and swim with vertical oscillations — but acheived them through separate processes. The natural world is filled with other examples of this process. Evolution explains it; creation science cannot.

Categories
Uncategorized

Intelligent Nutrients….(snicker)

A new restaurant opened near us recently called “Intelligent Nutrients”. We could see the sign for it from I-35W just after you got on going south. It had a curious purple, orange and green color scheme that made us think — hippie, new age, organic and maybe even vegetarian. Thus we had to give it a try.
We tried to find out what their business hours were on their website. Good luck! It has lots of glitz but not so much content. No business hours, no menu… what were getting ourselves into? In any case, we decided to risk it. So last night we drove over along with our trusty companions Tismo & One Day at a Time. Boy were we in for a surprise.
First of all, to get to the restaurant, you must pass through a gift shop of sorts. It is more like a shrine to the pure, lofty, and guady — all of which was empregnated with essential oils. Truffles for “Aphrodite” or “Motivation” — listing the essential oils which endowed those properties (ginger, lemon peel, etc…). We were right, everything was “organic”. But more than that — they actually touted that some of the foods were “harmonically grown”. Do they have a zen master do feng-shui on the crops?
The seemed to specialize in jewelry with audaciously large glass stones. Like the size of a 50 cent piece or bigger. I can’t imagine that looks good as a necklace.
I just couldn’t fathom the point of this establishment. Why do people believe that giant gems will make them healthy? Why are combinations of essential oils believed to enhance attribute X — and if they do, why is that any different than a drug that do so? Steroids are bad, but this essential oil of stamina is okay?
The restaurant, when we finally made it there, seemed pleasant. It had a giant projection TV displaying geometric shapes that danced with the new-age music the drifted through the air. The employees were smartly dressed in white chef’s outfits. However, the menu was just as weird as the gift store. I bet the food was interesting, but I got the feeling that it would be more of an “experience” than it would be “satisfying”, if you know what I mean. Lima beans are great and all, but now what I’d consider a suppertime main dish. We decided we’d try it some other day, when we weren’t so hungry.
On final reflection, even though we didn’t understand what this place was about we figured it boded well for us. Intelligent Nutrients seemed very Boulder-esque. New age, hippie, granola, tree-hugger, etc… Say what you will about Boulder, CO, you might love it or think it is hoaky. But real estate prices in Boulder are a Mile High, and I own a home from what appears to be the beginnings of the new Boulder in Minnesota. Moo ho ha ha haha!

Categories
Genetics

Why Should I be afraid to talk Evolution?

At lunch today my friend Dave was wondering how long the human species has been around. I tried to recall, and threw out a number ( a million years ) that was a bit high. Current estimates have humans (Homo sapiens) evolving about 200-300 thousand years ago. To my credit, the very human-like species, Homo erectus was around a million years ago.
Dave then made a joke. He sarcastically retorted, “No, we all know that man was created exactly 7,000 (or whatever) years ago.” He immediately and profusely appologized, for not knowing if anyone listening was a Fundamentalist. I’m sure he didn’t mean to hurt anyone’s feelings.
But this makes me wonder about how to deal with diverse beliefs in a sensitive manner. On the one hand, evolution is a certainty. The age of the earth is undeniably billions of years old. But there are people who mix these scientific observations with religious faith. The web site Talk Origins discusses these issues in great detail, and presents the scientific point of view with clarity.
On the other hand, I have no need to embroil my coworkers in a debate about evolution. If one of them is a fundamentalist or a believer in “Intelligent Design”, isn’t that their problem? So do I avoid discussing evolution because it might incite them? No. Do I avoid making jokes about how stupid they are? I suppose I should… I really try to be nice to people, even if I think they’re stupid about something. But this creationism and I.D. crap is so bad. It undermines legitimate science. It poison’s peoples minds. How can someone become a successful scientific thinker if they’re uncertain about one of our most significant scientific discoveries? You know, I’m sure there is a trite metaphore about the building with a foundation made of shit.
If there was a religious group that didn’t believe in gravity, wouldn’t we all laugh at them?

Categories
Uncategorized

Calling all creative light blinkers

I’m runing out of time to complete the christmas present for my nephews. I’ve created a “build your own robot” kit. I have pretty much all the hardware assembled, but I have only a few days to write the software. That’s where you come in — I want suggestions for the most intersting ways to program my little beasts.
First, let me describe what they are: It is a small rectangular assembly of electronic parts and wires. It has one light sensor, two small switches (dip switches), a motor and lots of lights (I’m able to selectively turn on and off six different ones).
The kit will involve some amount of physical “put it together”. This includes attaching the wire legs, and clipping an off-center weight to the motor. The off center weight will make the robot appear to “walk” because it will vibrate the entire thing as it spins. You could also put a pinwheel or a spiral shape on the motor — which would look cool but wouldn’t make it move. You might even find a way to put a light spinning on the motor if you could find a way to make contact with a spining thing.
What kinds of behaviors should the robot have? With two dip switches, I have the ability to select up to four different behaviors. My current ideas are:

  • The robot starts to walk when it detects light. I’m including a small flashlight in the kit, so they can turn the robot on in the dark, and then illuminate it to start it going. What should the lights do during this time? Flash, pulsate, or be off, or on solid or dim?
  • The robot flashes its lights mimicing the pattern that it receives from the light sensor. So if you flash long, short short long, it would do that back.
  • The robot sits dark and quiet until the light level changes — then it goes bezerk. This is the ‘guardian’ mode and you could use it to guard your room.

Any other ideas of cool things the robot could do? What about cool ways that it could be accessorized, to make it more interesting to play with?
What are some nifty patterns of lights? With six lights available, I can do quite a few combinations of patterns…

Categories
Uncategorized

Comment SPAM

{sigh} Some moron named “TOM” keeps posting Spam comments on my blog. It is up to about four a day, and I delete them, and I block his IP address, but he keeps coming back.
So I’ve disable comments on all old posts — and moving forward I’ve change the id tags of the form data so that his script or whatever he is using won’t work anymore (I hope). In a way this is a challenge to see who is cleverer – me or Tom.
We will see. It is a toss up.

Categories
Uncategorized

USB PicKit tools for Mac OS X

A person named Orion created a nifty utility for programming PIC controllers. PICs, as you may recall are the brains of my robots. Specifically, this program controls the Microchip PicKitâ„¢ 1 Flash Starter Kit.
Orion called his software USB PICKIT.
Unfortunately, when Microchip, Inc. updated their software to version 2.0.2, Orion’s software stopped working on the Mac. This is because his comnputer got sent to Alaska. Go figure.
Fortunately, he posted his source code. So I took it and patched it up (which was not too hard, but did require making things more “Mac”centric, because the libusb support on Mac OS X isn’t the same as on Linux. Namely, interrupt mode didn’t seem to be supported.)
So, in order to be a good internet citizen, I’ll put up my Mac OS X version of usb_pickit for others to use.
Download file This is a Mac OS X 10.3 binary file in a zip archive.
For some reason I felt obligated to rename it Ezload. This wasn’t really intentional, oh well.
The way I did this was rather hacky… so I won’t post the source unless someone wants it.
———–
Update, I’ve cleaned the code a little bit and tried to integrate my changes in a way that won’t break the linux build either.
Download file
This version now has a UI, and as soon as you connect a device it either uploads or downloads. I’m also including all the source and the project file.
———–
Update, August 2011. The Download link above has been modified to reflect the new location on Google Code.

Categories
Uncategorized

Vegetable Oil : The other household cleaner

A few weeks ago, my dog Lucy found a tube of printing ink and chewed it up. This resulted in some inky black paws! It was an oil-based ink, and soap and water wasn’t getting it out of her fur. So I mixed equal parts vegetable oil and soap in the palm of my hand and washed her feet with that. The ink came out!
Why does vegetable oil help remove ink?
To answer this question, we need to understand the wonderful concept of “hydrophobicity”. Hydrophobicity is a measure of how much a material “hates” water. Oil, grease, wax and oil-based ink are all hydrophobic. They do not mix with water at all. The opposite of hydrophobic is hydrophilic — meaning water loving — and that refers to any material that “loves” water — such as sugar, salt, alcohol, vinegar and antifreeze to name a few examples.
So what is the molecular basis for hydrophobicity? It all comes down to the quirky personality of water. You know the age old addage, “opposites attract”. Well, it is true on a molecular level, too! For example, sodium ion has a positive charge, and chloride ion has a negative charge — mix them together and you get salt. All of the substances I listed as hydrophilic (water loving) are either charged overall (such as the ions in salt) or have regions of charge (as in alcohol or antifreeze).
Hydrophobic substances do not have any charges. This means they are usually made of chemicals that have lots of carbon atoms but no oxygen atoms. You may have heard terms such as “unsaturated fats” or “saturated fats” — these words describe the arrangement of the strings of carbon atoms that are in fat.
What makes water quirky is that even though it has no charge, it loves other charged molecules. This is because water can quickly convert from H2O (with no charge) to just HO (with a negative charge) or to H3O (with a positive charge). In addition, although H2O is not charged, it is a little bit “polar” — this means that on one side it has a slight positive charge and on the other it has a slight negative charge. The flexible distribution of charges in water means that it can surround other charged molecules with ease (which is what happens when something hydrophilic dissolves in water).
What happens if you take a long molecule and put a charge at one end, but make the rest of it hydrophobic? You’ve created soap! The soap molecule can wrap up an oily molecule. When it does that, the charged part of the soap is the only thing left on the outside — so now water can surround it and make it dissolve.
When Lucy’s paw was covered in black ink, there was too much oily ink for the soap to penetrate. Plus, ink is a very thick sludgy mixture of oils. Vegetable oil, on the other hand is runnier and can be cleaned with soap more easily. By mixing vegetable oil in, the ink molecules mixed with the oil (because they are both hydrophobic) and loosened it away from Lucy’s fur. Then the soap and water was able to lift them both away.
Try mixing vegetable oil with dish soap next time you have grease or pine sap stuck in your hair or on your hands.

Categories
Uncategorized

A/D conversion

I’ve gotten the A/D converter on the Microchip PIC P12F675 to work. The pulse width modulation technique is allowing me to simulate different intensities of light. What you do is send extremely fast pulses of light on and off. Your eye “averages” these out to appear as a middle intensity brightness.

Here is a movie:







Here is the source code:

  1  ;Software License Agreement                                         
  2  ;                                                                    
  3  ;The software supplied herewith by Microchip Technology             
  4  ;Incorporated (the "Company") is intended and supplied to you, the  
  5  ;Company~Rs customer, for use solely and exclusively on Microchip    
  6  ;products. The software is owned by the Company and/or its supplier,
  7  ;and is protected under applicable copyright laws. All rights are   
  8  ;reserved. Any use in violation of the foregoing restrictions may   
  9  ;subject the user to criminal sanctions under applicable laws, as   
 10  ;well as to civil liability for the breach of the terms and         
 11  ;conditions of this license.                                        
 12  ;                                                                    
 13  ;THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO WARRANTIES,  
 14  ;WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED  
 15  ;TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A       
 16  ;PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,  
 17  ;IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR         
 18  ;CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.       
 19  ;****************************************************************************
 20  ;Filename:      atod.asm
 21  ;Author:        Ruan Lourens
 22  ;Date:          1.03.03 
 23  ;Version:       1.0 (A/D Version)
 24  ;Description:   This is an ASSEMBLY written program designed to show the user  
 25  ;               a timer driven analog-to-digital conversion.It is based on the 
 26  ;               interrupt driven conversionLED State Machine used in 
 27  ;               tutorial #3.     
 28  ;****************************************************************************
 29  ;Revision History
 30  ;****************************************************************************
 31
 32
 33      list      p=12F675              ; list directive to define processor
 34      #include <p12f675.inc>          ; processor specific variable definitions
 35      ;#include "atod.h"
 36      errorlevel  -302               ; suppress message 302 from list file
 37
 38      __CONFIG   _CP_OFF & _CPD_OFF & _BODEN_OFF & _MCLRE_OFF & _WDT_OFF & _PWRTE_ON & _INTRC_OSC_NOCLKOUT
 39
 40  ; '__CONFIG' directive is used to embed configuration word within .asm file.
 41  ; The lables following the directive are located in the respective .inc file.
 42  ; See data sheet for additional information on configuration word settings.
 43
 44  ;****************************************************************************
 45  ;Defines
 46  ;****************************************************************************
 47  #define BANK1       bsf     STATUS,RP0  ; Bank1
 48  #define BANK0       bcf     STATUS,RP0  ; Bank0
 49  #define LED1TRIS    b'11001111'
 50  #define LED2TRIS    b'11001111'
 51  #define LED3TRIS    b'11101011'
 52  #define LED4TRIS    b'11101011'
 53  #define LED5TRIS    b'11011011'
 54  #define LED6TRIS    b'11011011'
 55  #define LED7TRIS    b'11111001'
 56  #define LED8TRIS    b'11111001'
 57  #define LED1ON      b'00010000'
 58  #define LED2ON      b'00100000'
 59  #define LED3ON      b'00010000'
 60  #define LED4ON      b'00000100'
 61  #define LED5ON      b'00100000'
 62  #define LED6ON      b'00000100'
 63  #define LED7ON      b'00000100'
 64  #define LED8ON      b'00000010'
 65  #define NUMBEROFBITS    .8
 66  #define ANSelect    b'00010001'     ;Used to configure AD
 67  #define ADControl   b'00000001'     ;Used to configure AD
 68
 69  LEDREGISTER EQU 0x31
 70
 71  mcount        EQU     22h
 72  ncount        EQU     23h
 73  new_tris        EQU     24h
 74  new_gpio        EQU     25h
 75  brightness_num  EQU  26h
 76  brightness_den  EQU 27h
 77  brightness_dat  EQU 28h
 78  IS_ON_BIT       EQU 0
 79  brightness_count EQU 29h
 80  temp EQU 30h
 81  ALL_OFF_TRIS EQU b'11111111'
 82
 83  ;****************************************************************************
 84  ;General Purpose Registers (GPR's) 
 85  ;****************************************************************************
 86      ; UDATA_SHR
 87  WTEMP       res 1           ; register used in Interrupt Routine
 88  STATUSTEMP  res 1           ; register used in Interrupt Routine
 89  PCLATHTEMP  res 1           ; register used in Interrupt Routine
 90  FSRTEMP     res 1           ; register used in Interrupt Routine
 91  FLAGS       res 1           ; register used to set flags
 92
 93  ;****************************************************************************
 94  ;Reset Vector
 95  ;****************************************************************************
 96      ORG     0x000             ; processor reset vector
 97      nop                       ; Inserted For ICD2 Use
 98      goto    Init              ; go to beginning of program
 99
100  ;****************************************************************************
101  ;Interrupt Vector - Interrupts only active during animation sequence
102  ;                 - Interrupt Sources:  1.  TIMER0 Overflow
103  ;
104  ;FLAGS register - bit0:  1 = A/D will be serviced, 0 = Display will be serviced
105  ;
106  ;****************************************************************************
107      ORG     0x004             ; interrupt vector location
108  Isr
109      movwf   WTEMP           ;Save off current W register contents
110      movf    STATUS,w
111      clrf    STATUS          ;Force to page0
112      movwf   STATUSTEMP
113      ;movf   PCLATH,w
114      ;movwf  PCLATHTEMP      ;Save PCLATH
115      ;movf   FSR,w
116      ;movwf  FSRTEMP         ;Save FSR
117
118
119  ;****************************************************************************
120  ;Interrupt Source Checks
121  ;****************************************************************************
122  Timer0InterruptCheck
123      BANK1                   ; BANK1   
124      movf    INTCON,w
125      andlw   0x20
126      btfsc   STATUS,Z        ;Is T0IE Set?
127      goto    Next1           ;No
128      movf    INTCON,w        ;Yes
129      andlw   0x04
130      btfss   STATUS,Z        ;Is TOIF Set?
131      goto    Timer0Interrupt ;Yes
132
133  Next1
134  GPIFInterruptCheck
135      movf    INTCON,w
136      andlw   0x08
137      btfsc   STATUS,Z        ;Is GPIE Set?
138      goto    Next2           ;No
139      movf    INTCON,w        ;Yes
140      andlw   0x01
141      btfss   STATUS,Z        ;Is GPIF Set?
142      goto    GPIFInterrupt   ;Yes
143
144  Next2
145  GP2_INT_ExternalInterruptCheck
146      movf    INTCON,w
147      andlw   0x10
148      btfsc   STATUS,Z        ;Is INTE Set?
149      goto    Next3           ;No
150      movf    INTCON,w        ;Yes
151      andlw   0x02
152      btfss   STATUS,Z        ;Is INTF Set?
153      goto    GP2_INTExternalInterrupt;Yes
154
155  Next3
156  PeripheralInterruptCheck
157      movf    INTCON,w
158      andlw   0x40
159      btfsc   STATUS,Z        ;Is PEIE Set?
160      goto    EndIsr          ;No
161
162  Next4
163  EEIFInterruptCheck
164      movf    PIE1,w
165      andlw   0x80
166      btfsc   STATUS,Z        ;Is EEIE Set?
167      goto    Next5           ;No
168      BANK0                   ;Yes
169      movf    PIR1,w
170      BANK1
171      andlw   0x80
172      btfss   STATUS,Z        ;Is EEIF Set?
173      goto    EEPROMInterrupt;Yes
174
175  Next5
176  ADIFInterruptCheck
177      movf    PIE1,w
178      andlw   0x40
179      btfsc   STATUS,Z        ;Is ADIE Set?
180      goto    Next6           ;No
181      BANK0
182      movf    PIR1,w
183      BANK1
184      andlw   0x40
185      btfss   STATUS,Z        ;Is ADIF Set?
186      goto    A_DConverterInterrupt;Yes   
187
188  Next6
189  CMIFInterruptCheck
190      movf    PIE1,w
191      andlw   0x08
192      btfsc   STATUS,Z        ;Is CMIE Set?
193      goto    Next7           ;No
194      BANK0                   ;Yes
195      movf    PIR1,w
196      BANK1
197      andlw   0x08
198      btfss   STATUS,Z        ;Is CMIF Set?
199      goto    ComparatorInterrupt;Yes
200
201  Next7
202  TMR1IFInterruptCheck
203      movf    PIE1,w
204      andlw   0x01
205      btfsc   STATUS,Z        ;Is TMR1IE Set?
206      goto    EndIsr          ;No
207      BANK0                   ;Yes
208      movf    PIR1,w
209      BANK1
210      andlw   0x01
211      btfss   STATUS,Z        ;Is TMR1IF Set?
212      goto    Timer1Interrupt ;Yes
213      goto    EndIsr          ;No
214
215  Timer0Interrupt             ;Interrupt every 1024 uS
216      BANK0               ;BANK0
217      btfsc   FLAGS,0         ;Check if A/D functions will be serviced or the display routine                 
218      call    AD_Functions        ;Yes, service A/D
219      BANK0               ;BANK0
220      btfss   FLAGS,0         ;Check if Display functions will be serviced
221      call    Display         ;Yes, goto Display
222      BANK0               ;BANK0
223      movlw   b'00000001'
224      xorwf   FLAGS,F         ;Toggle FLAGS,1
225      BANK1               ;BANK1
226      bcf     INTCON,T0IF ;Clear TMR0 Interrupt Flag  
227      goto    EndIsr
228
229  Display
230      decfsz brightness_count,f
231      goto activate_leds
232      goto toggle_on_off
233  toggle_on_off:
234      movlw   b'11111111'
235      xorwf   brightness_dat,f
236      btfsc   brightness_dat,IS_ON_BIT
237      goto store_off_time
238      goto store_on_time
239  store_on_time:
240      movfw   brightness_num
241      movwf   brightness_count
242      goto activate_leds
243  store_off_time:
244      movfw   brightness_den
245      movwf   brightness_count
246  activate_leds:
247      btfsc   brightness_dat,IS_ON_BIT
248      goto show_black
249      goto show_lights
250  show_black:
251          movlw   b'11111111'
252          bsf     STATUS,RP0  ;Bank 1
253          movwf   TRISIO      ;and set GP<5:4,1:0>
254          bcf     STATUS,RP0  ;Bank 0
255          movlw   b'00000000'
256          movwf   GPIO
257      goto end_of_intr
258  show_lights:
259          movfw   new_tris;
260          bsf     STATUS,RP0  ;Bank 1
261      ;movlw b'11001111'
262          movwf   TRISIO      ;and set GP<5:4,1:0>
263          bcf     STATUS,RP0  ;Bank 0
264          movfw   new_gpio
265      ;movlw  b'00010000'
266          movwf   GPIO
267  end_of_intr:
268      return
269
270
271
272
273  GPIFInterrupt
274      goto    EndIsr
275
276  GP2_INTExternalInterrupt
277      goto    EndIsr
278
279  EEPROMInterrupt
280      goto    EndIsr
281
282  A_DConverterInterrupt
283      goto    EndIsr
284
285  ComparatorInterrupt
286      goto    EndIsr
287
288  Timer1Interrupt
289
290  EndIsr
291      clrf    STATUS            ;Select Bank0
292      ;movf   FSRTEMP,w
293      ;movwf  FSR               ;Restore FSR
294      ;movf   PCLATHTEMP,w
295      ;movwf  PCLATH            ;Restore PCLATH
296      movf    STATUSTEMP,w
297      movwf   STATUS            ;Restore STATUS
298      swapf   WTEMP,f
299      swapf   WTEMP,w           ;Restore W without corrupting STATUS bits
300      retfie                    ;Return from interrupt    
301
302
303  ;****************************************************************************
304  ;AD_Functions
305  ;****************************************************************************
306  AD_Functions
307      BANK0               ;BANK0
308      movf    ADRESH,W        ;Move the most significant byte of A/D Result to W
309      movwf   LEDREGISTER     ;The A/D result is moved to LEDREGISTER and will be displayed
310      bsf ADCON0,GO       ;Start A/D
311      return
312
313  ;****************************************************************************
314  ;Initialization
315  ;****************************************************************************
316  Init
317      ;call    0x3FF      ; retrieve factory calibration value
318                          ; comment instruction if using simulator, ICD2, or ICE2000
319      BANK1
320      movwf   OSCCAL      ; update register with factory cal value 
321      ;call   InitLED     ;Initialize LED Routine Variables
322      movlw   b'00000001'
323      movwf   TRISIO          ;Tri-State All Inputs
324      BANK0               ;BANK 0
325      clrf    GPIO            ;Clear Port
326      movlw   b'00100000'
327      movwf   GPIO
328
329      BANK1               ;BANK 1
330      clrf    VRCON           ;Vref Off
331      BANK0               ;BANK 0
332      clrf    TMR0
333      movlw   0x07
334      movwf   CMCON           ;Comparator Off
335
336      BANK1                   ;BANK 1 
337      movlw   b'10000001'
338      movwf   OPTION_REG      ;TIMER0 Prescaler = 4 and pull-ups disabled
339      bsf     INTCON,T0IE     ;Interrupt on TIMER0 Overflow Enabled
340      bcf     INTCON,T0IF     ;Clear TIMER0 Overflow Interrupt Flag
341      bsf     INTCON,GIE      ;Turn on Global Interrupts
342      movlw   ANSelect
343      movwf   ANSEL           ;Configure AN0 & prescale to A/D    
344
345      BANK0                   ;BANK 0
346      movlw   ADControl
347      movwf   ADCON0          ;Select AN0, Left justified & enables A/D
348      NOP
349      NOP
350      NOP
351      NOP                     ; Give 4 uS delay before starting A/D
352      bsf ADCON0,GO           ; Start A/D
353
354  ;****************************************************************************
355  ;MAIN - Main Routine
356  ;****************************************************************************
357  Main
358          movlw   0x02
359          movwf   brightness_num
360          movlw   0x1F
361          movwf   brightness_den
362          movlw   0xFF
363          movwf   brightness_count
364  go
365          ; D0
366          movlw   b'11001111'
367          movwf   new_tris
368          movlw   b'00010000'
369          movwf   new_gpio
370          call    delay
371          ; D0
372          movlw   b'11001111'
373          movwf   new_tris        ;and set GP<5:4,1:0>
374          movlw   b'00100000'
375          movwf   new_gpio
376          call    delay
377          ; D0
378          movlw   b'11101011'
379          movwf   new_tris        ;and set GP<5:4,1:0>
380          movlw   b'00010000'
381          movwf   new_gpio
382          call    delay
383          ; D0
384          movlw   b'11101011'
385          movwf   new_tris        ;and set GP<5:4,1:0>
386          movlw   b'00000100'
387          movwf   new_gpio
388          call    delay
389          ; D7
390          movlw   b'11111001'
391          movwf   new_tris        ;and set GP<5:4,1:0>
392          movlw   b'00000010'
393          movwf   new_gpio
394          call    delay
395          ; D6
396          movlw   b'11111001'
397          movwf   new_tris        ;and set GP<5:4,1:0>
398          movlw   b'00000100'
399          movwf   new_gpio
400          call    delay
401          ; D5
402          movlw   b'11011011'
403          movwf   new_tris        ;and set GP<5:4,1:0>
404          movlw   b'00000100'
405          movwf   new_gpio
406          call    delay
407          ; D0
408          movlw   b'11011011'
409          movwf   new_tris        ;and set GP<5:4,1:0>
410          movlw   b'00100000'
411          movwf   new_gpio
412          call    delay
413         goto go
414
415
416  ;delay loop
417  delay   movlw   0x01
418          movwf   temp
419          movwf   brightness_num
420  loadm2   movlw   0x2f
421          movwf   mcount
422  loadn2  movfw   LEDREGISTER
423          addlw   1
424          movwf   ncount
425  repeat2
426          decfsz  ncount,f
427          goto    repeat2
428          decfsz  mcount,f
429          goto    loadn2
430          incf    brightness_num,f
431          movlw   0x13
432          movwf   brightness_den
433          movfw   brightness_num
434          subwf   brightness_den,f
435          incf    brightness_den,f
436          movlw   0x13
437          xorwf   brightness_num,w
438          movwf   temp
439          incf    temp,f
440          decfsz  temp,f
441          goto    loadm2
442          goto delay2
443  delay2   movlw   0x13
444          movwf   brightness_num
445  loadm   movlw   0x2f
446          movwf   mcount
447          movlw   0x13
448          movwf   brightness_den
449          movfw   brightness_num,f
450          subwf   brightness_den,f
451          incf    brightness_den,f
452  loadn   movfw   LEDREGISTER
453          addlw   1
454          movwf   ncount
455  repeat
456          decfsz  ncount,f
457          goto    repeat
458          decfsz  mcount,f
459          goto    loadn
460          decfsz  brightness_num,f
461          goto    loadm
462          return
463
464
465  ; initialize eeprom locations
466
467          ORG 0x2100
468          DE  0x00, 0x01, 0x02, 0x03
469
470
471          END                       ; directive 'end of program'
472
Categories
Uncategorized

Is that what you would call “geeky”?

I have to share my solution for this problem I was having. My PIC controller programmer only works on Windows (for the time being) because of various technical difficulties (I’ll spare you the details). I only have a Mac at home.
So I plugged the pic controller programmer into my Windows machine at work and turned on Remote Desktop. With Remote Dekstop, I can control my Windows machine from home.
Then I pointed the iSight camera attached to my work Mac at the programmer.
Finally, if I remote desktop into both machines at work, I can dial myself up on iChatAV and get a view of the programmer (and the important 10 LEDs). I can also run the programmer software on the Windows machine to upload new software into the PIC.
geek.png
W00T!