All Blog Posts (123)

ADC Sample Code has a bug (it seems)

There seems to be a mistake, because the code did not work, and after my change, it did work.

 

MainLoop

    bsf        ADCON0,2        ;start conversion and wait for it to complete

    btfsc    ADCON0,2

    goto    $-2

 

goto $-2 is wrong, because it goes back 2 lines and starts the conversion all over again. You'll want to goto $-1 instead, to just test until the conversion is done.

 

However, I would reccommend this…

Continue

Added by Ritchie Thai on February 19, 2011 at 7:21pm — No Comments

EEPROM Access

The information regarding the EEPROM is minimal in the manual and you will need to go into the datasheets to get a bigger picture (as is the case for pretty much everything). This post is just to add to the stuff the manual is missing, so that you do not have to go searching through the datasheet.

 

First off, the datasheet itself uses VALUE and ADDR as registers to contain the data it would like to store. If you implement the code as is, it will not work. You will need to…

Continue

Added by Alim Jiwan on February 6, 2011 at 1:41am — No Comments

Tool: MPASM LCD String Writing Code Generator

http://dozydagger.com/misc/mpasm-lcd-writer.html

 

You know what I say to tables? Well, I don't say it, because I am not the type to publicly use such language, but once you get past the character limit it causes problems that can be tricky even if the solution is known.

 

Here's a work around that I'm using. "can" wasn't worth making a table for. A table would take 4 lines. If you include the code to…

Continue

Added by Ritchie Thai on February 1, 2011 at 1:30am — No Comments

Keypad Question

I am having some trouble with my keypad.  I build my code, then use PICUSB to write the

hex file.  The busy light comes on, then when it turns off, I switch from PRG to RUN. 

However, my keypad does not work at this point.  At one point in my code, I am prompted

to enter how many balls I want to dispense in Can1.  But when I press a key on the

keypad, it does not show up, and the program does not proceed.



However, if I switch back to PRG, turn the board OFF,… Continue

Added by Mohammed Patel on January 30, 2011 at 5:02pm — 4 Comments

Removed Post

I have removed this post because it was based on misinformation. I have decided not to delete the post because I wish the comments to be preserved.

Added by Ritchie Thai on January 28, 2011 at 5:00am — 7 Comments

PIC16 Table Lookups - A Guide

A table lookup on the PIC16 basically takes the following steps:

  • Get the address of index zero of the table
  • Add the table index to the address
  • Jump to that address

The table itself is a sequence of retlw instructions, which put a value into W and return. (dt and related directives are just assembler shorthand for inserting many retlws.)



A first try at implementing a table lookup thus looks like this:…



Continue

Added by Jack Sparrow on January 28, 2011 at 1:00am — 6 Comments

SN754110 claims it has internal clamping diodes - this means I don't need diodes in my circuit, right?

The datasheet for the motor driver SN754410 says that it has internal clamping diodes. My assumption is that if I use this IC, it has already taken care of the diode business for me and I can use it without worrying about that. Is this correct, or is this one of those things where you can't trust what the manufacturer says and have to put your own safety diodes in anyways?

Added by Neil Newman on January 26, 2011 at 11:53pm — 1 Comment

Anyone using a tube to vertically stack their tires?

I found a plastic vendor that sells acrylic tubes that are the perfect size to stack the tires (5" inner diameter and 5 1/4" outer diameter).



The only problem is that they only come in 6' long tubes. The 6' tube is ~$50 so I'm looking for 2 other groups who want to split up the 6' it'll be $15-20 for your 2' section of tube.



Heres the webpage for the plastic vendor…

Continue

Added by Timothy Ahong on January 26, 2011 at 10:00pm — No Comments

Code too long?

I have written some code (My main file is about 250 lines long) and I have been trying to test it. If I comment all except the first little bit of my code, it performs exactly as I expect when I test it on the LCD and keypad. Naturally then I uncomment a little bit more, and when I try to test it, part way through the operation, it reverts back to the beginning of the code. 
I was thinking there was an error in the code I had written, so…
Continue

Added by Matt Nejati on January 26, 2011 at 9:47pm — 10 Comments

Tip: DT location in code matters.

If there is a certain length of code coming before the DT (define table) directive, then characters/entries in the DT past a certain point will fail to return a value. Instead, upon reaching that character, the program will restart from the beginning.

 

Remember, or realize, that DT is actually a short form for a long list of retlw instructions. That means that having a DT holding a long string counts as many instructions.

 

This does NOT appear to be an issue of…

Continue

Added by Ritchie Thai on January 26, 2011 at 5:30am — 4 Comments

Rant: I know where the bug is, how to fix it, but why?

In one of my define tables, if the table gets to a certain length I get a bug in my code. Just take one character away from that and everything is fine. I have found no significance in regard to... actually, I never counted it until now.

If there are 33 characters, my code bugs out. 32 is okay. Well, 32 is a very important number, but I have longer tables elsewhere. There is also no reason for this to bug out. It's simply absurd!

Added by Ritchie Thai on January 26, 2011 at 12:54am — 1 Comment

Tip: DT Uses Up A LOT of lines.

Each dt (define table) directive uses up a line for each character in your table/string. If you're not careful, your code could get long despite being short.


Here's how the define table directive works. Each character in your string is actually translated into a single retlw (return literal in W).

 

For example:

dt "Hello!"

 

is translated into:

retlw 'H'
retlw 'e'

retlw 'l'
retlw 'l'
retlw 'o'
retlw '!'

Added by Ritchie Thai on January 26, 2011 at 12:00am — No Comments

Tip: The directory of your MPLAB project can cause problems.

If the path size of your MPLAB project's directory is too long, for example:

C:\Users\Main\Desktop\ritchie-thai\current-projects\aer201

then a .hex file will not be created.

 

I am now using a workspace with the much shorter path:

C:\mplab-test\KeyPad_LCD

 

Don't computers suck?

Added by Ritchie Thai on January 25, 2011 at 10:30pm — 1 Comment

Tennis Ball Experiment Results

Tennis%20Ball%20Rolling%20Experiments.xlsx

 

tl;dr

 

I rolled about 1000 tennis balls down an incline. It turns out that you need an angle greater than 7.7* to ensure a column of tennis balls will roll without error.

Added by Calvin Moes on January 23, 2011 at 3:00pm — 2 Comments

Sample codes for stepper motor

list p=16f877                 ; list directive to define processor      

#include <p16f877.inc>        ; processor specific variable definitions    

 __CONFIG _CP_OFF & _WDT_OFF & _BODEN_ON & _PWRTE_ON & _HS_OSC & _WRT_ENABLE_ON & _CPD_OFF & _LVP_ON

 

 

cblock 0x20

 COUNTH

  COUNTM

  COUNTL

endc



         ORG       0x0000     ;RESET vector must…

Continue

Added by PML on January 19, 2011 at 10:46pm — No Comments

PCB Design Softwares

Altium and Eagle are great softwares for PCB design. The softwares can be used to generate schematics and this information (all the parts and connections) can be automatically transferred to a PCB design layout where the parts can be manually arranged and then automatically routed (for relatively simple layouts). Altium also has a simulator and a 3D design layout mode that is helpful for complicated design. Eagle does not have these functions. However it is much less expensive than Altium.…

Continue

Added by Thineshan Kathirchelvan (TA) on January 13, 2011 at 11:00pm — No Comments

Introduction to USB Communication

Transactions: A USB transaction has three parts: the token packet, the optional data packet, and the status packet, which represent the header, payload, and data

acknowledge, respectively. Since USB is host-driven, the host initiates

transactions by sending the token packet. It also sends packets to indicate the

start of each frame, every millisecond. Packets on this layer are taken care

of, so the…

Continue

Added by Thineshan Kathirchelvan (TA) on August 17, 2010 at 10:41pm — No Comments

PIC delay code generator

Often times in project coding development, the programmer need to generate some sort of delay. It is hard and tedious to calculate by hand, an alternative way is to use the Pic Delay Code Generator for ASM Programmers made by N Golovchenko.…

Continue

Added by Yifan Wang on August 17, 2010 at 5:30pm — No Comments

Introduction to Inter-Integrated Circuit (I2C)

It is quite clear that the I2C bus can be very confusing for the newcomer. This short article therefore tries to de-mystify the I2C bus, I hope it doesn't have the opposite effect!…





Continue

Added by Shayegan (TA) on August 17, 2010 at 5:00pm — No Comments

Monthly Archives

2024

2023

2018

2016

2015

2014

2013

2012

2011

2010

2009

1999

1991

1990

1989

1988

1987

1986

1985

1984

1983

1982

1981

1980

1979

1978

1977

1976

1975

1974

1973

1972

1971

1970

1969

1968

1967

1966

1965

© 2024   Created by PML.   Powered by

Badges  |  Report an Issue  |  Terms of Service