August 09, 2006

ADVICE ON CMOS IC's

THIS IS A LETTER I SENT
to George Gallant, Jim Morris
and Jim Fiske

hi
just realized something troubling
I was reading some hints for using the PIC
microcontrollers and found this:

"unconnected port bits should never
be set up as inputs"

"when floating, CMOS inputs can flip rapidly
between states and cause excessive current draw,
heating and even damaging the PIC"

So - set all unused bits of ports to outputs.

I went back to one of my books talking about
CMOS IC's and noticed this warning:

ALL unused inputs MUST be connected to Vdd(+) or Vss(gnd)
otherwise erratic chip behavior and
excessive current consumption will occur.

other rules for CMOS were NEVER connect
an input signal to a cmos circuit when
the power is off.

another curious warning was to
avoid slowly rising and falling input signals
since they cause excessive power
consumption. it recommended
rise times faster than 15 usecs

I think I have been lucky so far
but I'm certainly going to observe
these precautions.

Regards.

Larry Keegan in Stoneham, MA

Posted by larrykeegan at 09:17 PM

August 22, 2005

MY NEW PROGRAMMER CIRCUIT

I have re-designed and simplified my circuit for my PIC programmer.
This circuit is connected to my laptop and a 5 volt power supply.
It takes about 25 seconds to go from assembly language program
to the burned in PIC microcontroller ready to run.

pgmr.JPG

Posted by larrykeegan at 10:05 PM

April 17, 2005

LATEST NEWS IN LARRY KEEGAN'S WORLD OF EXPERIMENTS !!!!!!

IN BRIEF:
1. Gave a talk to the QRA radio club on PIC Microcontrollers
2. Wired up a MING xmtr & rcvr & got it working
but want to package it more nicely and affix some PICs to it
3. Stripped apart som RC cars & trucks and set up an
RC system with a small relay attached to rcvr
4. Writing a PGM to read the infrared sigs from a handheld REMOTE.
Interesting article in SERVO mag outlines methodollogies.
PWM seems to be the most popular I think zero pulses are about 400 usecs
wide & ONE pulses are about 1200 usecs wide. There are about 34 pulses
& about 12 of them unique and determine the individual code
5. I'm in the process of firing up some of my other old laptops
The hell with batteries - they are expensive . I plan to solder conect
wires to the contact points where batteries would connect. They operate on
a whole range of voltages.

Posted by larrykeegan at 02:11 PM

February 06, 2005

AMAZING BREAK-THROUGHS !!!

HERE ARE THE BREAKTHROUGHS
(1) MY SPEAKING COUNTER WILL NOW COUNT CONTINUOUSLY TO 999
(2) MY PIC PROGRAMMER SOFTWARE NOW OPERATES A HUNDRED
TIMES FASTER!!
(3) MY DOS BATCH FILE NOW RUNS WITHOUT ANY INTERVENTION FROM
ASSEMBING THE PROGRAM THROUGH PRE-ERASING THE PIC, WRITING THE CONFIGURATION WORD, CREATING THE INTERMEDIATE FILE, TO LOADING THE PROGRAM ONTO THE PIC. IT ALL HAPPENS IN 15 TO 20 SECONDS.

THE SPEAKING COUNTER
The speaking counter uses 8 bytes of storage to contain 8 binary-coded decimal (BCD) numbers with a capacity of 99,999,999. The code for maintaining this counter is fully in place, but the logic for playing the numeric messages only foes up to 999 at the present time. I've had it count up to 275 so far. There is still work to be done on the delays and connecting between the messages involved.
"one" "hundred" "seventy" "one" has 4 messages for 171.

PIC PROGRAMMER 100 TIMES FASTER
To program the PICs, I use a Qbasic language pgm of my own, and an older PC laptop. The pgm sends control signals via the printer port and some TTL buffering to the PIC chip. The main signals are the clock and data lines which contain the
programming commands and the data of the PIC assembler pgm to be loaded.
I encountered a difficulty in that I was forced to enter one instruction, then to go out of programming mode and back in for the next instruction. I believe I was not allowing enough time (10 msec) after the "program one cycle" commands.
Well I made some changes and included the necessary delay and now I can just stay in programming mode.

DOS BATCH FILE COMPLETELY AUTOMATIC
I discovered that ther is a Basic command called SYSTEM. It closes all open files and returns control to the operating system. Before I used the command STOP.
But for this I had to intervene to get back into DOS. Now the batch file is completely automatic.

Posted by larrykeegan at 11:59 AM

January 17, 2005

I've Cleaned Up My Shop

Take a look! For a while I couldn't find my way around my shop!
My white counter-top was covered with resistors, batteries, capacitors, IC's , wire, connectors, breadboards, PC boards, relays potentiometers,screwdrivers, pliers, wire strippers, scissors, electric tape, stands of solder, machine screws and nuts, pieces of metal of all shapes, relays and switches. Well, look what has happened!

shop.jpg

When you are in the heat of a project, you don't want to waste time cleaning up, so you just push stuff aside. But finally you get to a point where you can't even move around in your shop, there's so much stuff on the floor. Then you have to make a tactical retreat and put everything back where they belong. That's where I am now and it's really helping me with my project.

Posted by larrykeegan at 08:10 PM

August 01, 2004

A ROBOT THAT AVOIDS OBSTACLES!

Well here it is!
THE SENSBOT - a robot the senses obstacles
and navigates to avoid them.


sensbot.jpg

I have been having a lot of fun placing boxes and things
around the floor and seeing how well SENSBOT does.
Sometimes it gets itself stuck. But it does very well
and sometimes great when it goes into a dead-end hall area
anbd manages to turn around and come out again all
by itself.

SENSBOT has a rotating turret driven by a stepping motor
controlled from the computer program in the PIC microcontroller.
In general my turret sweeps 90 degrees, and I have settled on
5 segmnents of detection. Extreme left and extreme right,
slightly left and slightly right, and direct ahead. My sensor is the
Sharp GP2Y0D340K. This infrared sensor is set to activate a
signal when object is less than 40 centimeters (about 15 inches?)
from sensor. I bought 4 of these sensors from junun.org at $6
each. I use only one in the rotating turret.

My program algorithm is as follows.
If object sensed on extreme left, stop right wheel for brief time.
If object sensed on extreme right, stop left wheel for brief time.
If object sensed slightly to left, stop right wheel for longer time.
If object sensed slightly to right, stop left wheel for longer time.
If object is directly ahead, I alternate between a hard right
and a hard left.

This robot is not set up to go in reverse. The PIC sends signals
to 2 transistors which control the on and off to the wheel motors.

The sensors are quite complex. An infrared signal is sent out
at some specified freequency, and a phototransistor or photodiode
detects signal. The receiver though will filter out any other signal
that is not at the specified frequency. This prevents false signals
from other sources.

Posted by larrykeegan at 11:06 AM

May 17, 2004

LIGHT-SEEKER WORKS!!

It works! The robot LIGHT-SEEKER was completed
and here ii is.

light-seeker.jpg

Here is how it works. It rotates around little by little
and checks for a light source ahead of it.
When it finds a light source it beeps and proceeds
in that direction. After a short distance it checks
if the light source is still there. If so it continues ahead,
otherwise it rotates again and seeks a light source.

Thanks to Bob Neidorff of NEMES for help with
293 H-bridges which worked well with
my DC motor control. However things did not go smoothly until
I put in the diodes to curb the spikes
from the motor coils, etc.

Posted by larrykeegan at 09:37 PM

May 10, 2004

A NEW ROBOT

This new robot is pictured on the right. It is called
STEPBOT and is powered by stepper motors.


IMAGE002.jpg


I am coming to grips with problems of torque. The wave pattern
is the easiest to drive a stepper. These are unipolar stepper
motors. So I went to a half-step pattern which should give me
more torque - I hope. There is still another pattern that I can look into.
With the DC motors there seems to be no problem with torque.

Stepper motors for locomotion do have some advantages.
To reverse direction, I just send the patterns in the opposite
sequence. To stop, I just stop sending the signals.

An example of wave pattern is as follows:
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1

Each of the one's represents energizing one of the coils
in the stepper motor. You just repeat sending this pattern over and over
and the motor steps ahead. The pattern for the half-step
is more complicated, but basically energizes 2 coils
on some of the patterns.

Of course, I am sending these patterns to 2 stepper motors,
so I can make one stop or go in reverse while the other
goes forward.

Posted by larrykeegan at 09:52 PM

April 23, 2004

NEW VERSION OF PROGRAMMER SOFTWARE

I made 2 new QBASIC pgms for programming the PIC. These programs do not solve a problem I have been working on., but they clean up and speed up the process.

A program called INBTWEEN.BAS takes the hex file produced by my ASSEMBLER and prodeuces a file of 16 character strings, all containing 1's & 0's.

Ther second program WORKRND2.BAS reads the string file and sends this data along with the necessary programming COMMANDS to the PIC. Note that I still have to enter & leave programming mode each time I write an instruction to the PIC. But I have cleaned up the code and the processing. I have a variable I use for delay loops. Up to now I have been using 1000, but I have found by experiment that the program works at 100, which has speeded things up tremendously

Posted by larrykeegan at 07:04 PM

MY FIRST PIC-CONTROLLED ROBOT

Here are some new happenings in my PIC programming adventures.
This robot moves forward for several seconds then makes a 90 degree turn.
It continues to do this moving in a square path.

The program uses the timer0 with an interrupt. The pre-scaler is set for 1:256.
My interrupt routine subtracts from a register everytime there is an interrupt. When my register is zero, I make my turn. I get about 8 to 10 seconds delay.

Posted by larrykeegan at 06:49 PM

April 18, 2004

LATEST ON THE PIC - a letter to BOB

Here is the latest on what I am doing with the PIC
and my problem in making PROGRAMMING SOFTWARE
to load programs on to the PIC.

Hi Bob
I think I'll reply to your note and then plunk this message
right out on my BLOG. Basically, I got one PIC to drive a stepping motor
also successfully implemented INTERRUPTS and also got TIMER0 working
which also involves interrupts. At the point where I was going to do
a robot that would move around in the pattern of a square, I decided to go back to investigating my programming software again.

By the way, my communication between the 2 PICS was just input/output -
didn't even use an interrupt. I think I told you of the organ pipes
I picked up in Reading, but I just hooked up a blower I had to an organ pipe but the initial results were not to great. You seem to be dong your experiments much more scientifically, and you have garnered much more knowledge about them than I have.

Let me get back to my programming software for loading in my programs to the PIC. I explained how I am almost embarrassed to admit that all my programs have been loaded onto the PICs by software which is a WORKAROUND for a problem I have encountered. To program the PIC there are a handful of commands which are interspersed with the data you are sending to the PIC.
My QBASIC software sends 2 streams, clock & data, to the PIC.

My problem is that each time I write one line of data (an instruction) to the PIC, it either drops out of programming mode or something and does not carry out the remainder of the commands. My workaround has been to write one line of data to the PIC, then leave programming mode, then re-enter programming mode which always brings you to location zero. At this point,
I send the command to increment the program counter as many times as necessary to reach the new location where another line of data will be written.

I have talked with some people at MicroChip where I uncovered some errors in
the programming specs which I has found out on the Internet. Since there is no limit on how slow you can send the clock & data stream, I set up a very simple circuit and thru 2 set-reset flip-flops I fed in the data manually.
And to my surprise the same thing happened - only one line of data was accepted. I've tried many different PIC16F628 chips. I'm almost of a mind to jump to the PIC16F628A, which has some slight changes.

Well there it is, I'm sure much more than you wanted to hear.

Larry Keegan in Stoneham, MA

On 4/18/04 10:56 AM, "Robert Sweeney" wrote:

> Hi Larry,
>
> How are things going? I haven't heard from you in a while and I noticed
> on your blog that you are in a "tactical retreat" since March 21. I
> hope you are feeling better.
>
> It looks like you are making rapid progress with your pics. Did you set
> up communications between two pics with RS-232 (USART port) yet?
>
> My son and I are also taking a break from our projects. Although, I am
> writing a program to calculate the parameters for pipe organ pipes on
> the PC. I am writing a windows program in visual c++. I can select the
> pipes I want in my pipe organ and it will spit out all the dimensions
> for the wood pipes as well as the air consumption needed so I can design
> the appropriate wind system.
>
> Other than that I have been a slug. Enjoy the nice weather!
>
> Regards,
> Bob Sweeney
>
>

Posted by larrykeegan at 04:51 PM

March 21, 2004

TACTICAL RETREAT

Coincidental with getting a bad cold and disorienting dreams with psuedo computer & electronic stuff woven in, I have considered it time to take
a tactical retreat and an assessment of where I am working with the
PIC microcontroller.

Some of my accomplishments at the present time are as follows. I will begin with QBASIC programs that I have developed:

1. a load prm which reads from a hex file onto the PIC. It is slow but it works.

2. a verify pgm which reads out the instructions that have been written onto the EEPROM memory

3. a pgm which writes a new configuration word

4. a pgm which reads the pgm IDENT area and the config word

5. a pgm that creates a table or series of bytes in the EEPROM data memory area

6. a pgm to reads out EEPROM mem data & creates disk file called tableout.dat

7. Certainly not least, I have created an ASSEMBLER for appropriate text files written in PIC16F628 assembler language. Constraints: labels must begin in loc 1, opcodes in loc 9, & operands in 17. There are 2 out files: a .hex file and a .prt file which also includes the hex obj data

In the area of assembler code, I have come up with the following

1. dlymin, dlymed & dlymax which creates delays from 0 to 114 usecs,
from 114 usecs to 2 msecs, and from 2 msecs to about 45 secs respectively

2. I've installed code (not trivial) for accessing EEPROM data mem by PIC pgms

3. I've set up 2 PICS to talk to each other. One creates musical tones, the other
provides the delay controlling the duration of the tones

Posted by larrykeegan at 11:56 AM

February 29, 2004

SOME MORE APPs !

I have tons of applications I am looking at .
Some are simple, others more complex

I talked with my son Jeff last night. He is the author of the book
"Hacking Tivo: the Expansion, Enhancement and Development Starter Kit ". We inspire each other discussing various
ideas.

We discussed the interaction of 2 things:
1. The interaction of a cluster of PIC16F628's each programmed
the same way with a generic program and wired so that they
could communicate with each other. I have only a vague idea of what the programming would be, but we think of some algorithms comparable
the to rules of the game of LIFE.

2. The interaction of clusters of robots, similarly programmed. This seems
all especially feasible since I am buying PICs now at $2 a chip (see
Mouser Electronics).

We also discussed strategies for hardware. Jeff in software (and in hardware)
never likes to invent the wheel twice. He always thinks in terms of
developing a tool he can use over and over. I am in a tactical retreat at the moment on how to proceed with my experiments, and I think he has inspired me
study what I want in a basic mechanical and electrical hardware platform
for my robot experiments. If I can drop in a card with new software
onto a standard platform of interconnections, I will be making it easier
for myse3lf.

Posted by larrykeegan at 08:53 AM

February 27, 2004

THE AMAZING PIC !!

I would like to report great successes with my
experiments with the PIC16F628 micro-controller.
Thanks to help from guys like Bob Sweeney and a few other
guys like Mike Rioux of the QRA radio club,
a number of my programs are running smoothly.
One has a delay routine with 3 levels of loops
which can give me delays of up to 30 seconds.

Bob Sweeney warned me that the Watch Dog Timer could
be resetting my programs and I believe that was right.

Some of the things I have now done is write a configuration word on all my new chips. I am pleased to say that I got a bunch of PICs from Mouser for only
$2.06 each!
I also disable a lot of interrupts in my opening routines
using system registers option, intcom and pie1.

This afternoon, I will try to program a PIC to count in binary and display the count through 4 LEDs. I was just thinking - another version will count using a seven-segment display.

I will be putting in a program of mine called ROBOT2.ASM which will go forward for a few seconds, then make a right turn and then keep repeating this.

Here is a pic of my 4 bit counter:

piccntr.jpg

Posted by larrykeegan at 09:50 AM

January 22, 2004

MY ASSEMBLER PROGRAM

I have written a program which assembles
programs written in assembler code.
It is written in QBASIC and is called PICASM.BAS.
It produces a hex (hexadecimal notation) file
which can then be read by my PROGRAMMER
program PICLP542.bas, which loads the program serially
into the PIC.

The first version of the assembler has
certain limitations. All operands in the
assembler instructions must be a DECIMAL
number. A later version of the assembler will
accept labels, and the familiar "EQU" statements.
Labels such as "STRT1" & "LOOP1" occurring in the
ffirst pos of the instr line will be picked up automatically
by a later version of the assembler.

Posted by larrykeegan at 01:35 PM

MY PIC PROGRAM WORKS

My first program for the PIC is a program
that blinks an led through pin RB1 (pin #7)
of the chip.

By the way, here is a pic of our chip.
16f628.jpg

At first I was a bit disconcerted since
the blinking was erattic and sometimes stopped
when I picked up the breadboard. After investigation'
I conditioned a few of the pins. I put a 10k resistor on
pin 10 and applied Vdd to pin 4 (MCLR), using a diode to lower
the voltage a bit. I also found that by changing the value of
resistance to grd on pin 16 (osc1) I could change the clock
frequency of the chip computer. This would allow my delay loops to be even longer.

Posted by larrykeegan at 01:09 PM

January 12, 2004

More on the PIC16F628

I have read out the data which
sits in the configuration word area of the chip (PIC16F628)

the chip ID for 2 diff speed chips was
hex 07C0

the config word for both was 3FFF
the first ID field for the 20 MHZ chip was
hex 1800

the config word area begins at
loc hex 2000

Posted by larrykeegan at 02:34 PM

December 26, 2003

good things to COME !!!!

HI and hello world
join in the greatest fun of all
soon to come in this spot

programming the PIC microcontrollers
NOT - NOT - with the programmers provided
by the pros - but doing it yourself
depending on your knowledge of
electronics and programming
you can do it all yourself

program a complete COMPUTER
on a chip that costs approximately
$3 $3 yes $3
not $230 like sbc's of the past -
microprocessors on pcb's

dec 28,2003 I have not forgot to update
this entry. I am excited in my PIC programming
experiments and will be getting back to them shortly.
Stay tuned.

Jan 5, 2004
this is the very latest
I have succeeded in entering my 16 instruction
program onto the program memory (EEPROM)
of the PIC16F628.

I have verified that I have sent my program successfully
to the PIC16F628. This has been accomplished with a BASIC program
called PICRDALL.BAS. This program displays in hexadecimal
notation the data that it finds on the PIC. It utilizes the
READ command for use in programming the chip.

The program that I used to program the chip
is somewhat roundabout due to problems I
had with my sizeable BASIC programs.

I wanted to enter programming mode, which would bring
me to loc 0. Then I would write my first instruction
and then increment the program counter. However this never
worked in 2 programs. So, for the time being I loop thru a process
that goes into programming mode, increments the
program counter to the desired loc, and then writes
the instruction. It does this over and over, going in and out of
programming mode so it can go to loc 0.

Inefficient, but it works. Later I will get a more efficient BASIC
program.

DID THE LOADED PROGRAM WORK?

No. The first run did not show signs of working.
It was a program to make an led blink on & off.

Here is the hex and the assembler of the pgm:

0000
1683
30f0
0086
1283
1486
200a
1086
200a
2805
0fa0
280d
0008
0fa1
0000
280d
280a

and here is the assembler
statements

nop
bsf status, rp0
movlw f0h
movwf trisb
bcf status,rp0
loop1 bsf portb,rb1
call delay
bcf portb,rb1
call delay
goto loop1
delay incfsz accum1
goto step2
return
step2 incfsz accum2
nop
goto step2
goto delay

accum1 & accum2 are registers
20h & 21h.

I have some other hello world pgms
and I will let you know when I get this and
the others running

Larry Keegan Jan 5, 2004

Posted by larrykeegan at 08:16 PM