Speed 400 Speed Control
Programming
Programming the microprocessor requires one or more of the following files.
They should be renamed as given to work properly.
- HEX file
- This is the hex programming file for the processor shown on the parts
list. It should be stored as "speed400.hex" to work properly with
the programmers I know about. It is in Intel HEX format, as defined by Microchip,
Inc.
ASM file
- This is the assembly language source file. Store it as "speed400.asm".
Include file
- This include file should be stored as "speed400.inc". It defines
the transformation between servo pulse width and the operation of the speed
controller. It is used in speed400.asm.
Table generator
- This is a C++ program which generates the include file given above.
Store it as "s400tbl.cpp". I believe it should run as a C program,
but I haven't tried it.
There are two approaches you can take to programming:
- Use the hex file provided to program a one-time programmable device.
This requires access to a suitable programmer.
- Modify the source files provided to make it do something new. This will
not be discussed further; those who undertake such a modification need to
know more than I can teach here. Visit the
Microchip web site for a lot of good information. If a new include file
is needed for a different throttle response and if the user wishes to modify
the s400tbl program, he will need a C or C++ compiler, along with the knowledge
to use it.
I will describe using the Picstart Plus programmer and the MPLAB development
environment to program the devices with the hex file given. I do not have any
experience with other programmers.
- Start the MPLAB development environment, but do not load a project.
- Under the Options menu, select Development Mode. A dialog box will pop
up. Select the MPLAB-SIM Simulator button, then select the PIC12C509 processor.
- Under the File menu, select Import, then select Download to Memory.
A file open dialog box will appear. Locate the speed400.hex file described
above, and open it.
- Under the Picstart Plus menu, select Enable Programmer. If this fails,
look at the Options menu under Programmer Options. Verify that the Picstart
Plus is selected and that the correct com port is selected. Make certain
that everything is plugged in.
- If the enable succeeds, the programmer dialog box will appear. Verify
that the device is PIC12C509, the Oscillator is Internal RC, the Watchdog
Timer is ON, Code Protect is Off, and Master Clear is Internal. These should
be the values as loaded; if you have to change them, it is likely that the
processor setup described above is incorrect.
- Put in a new device. Be careful to put it so that pin 1 is all of the
way to the top of the socket.
- Click the Blank button in the dialog box. The program should reply with
a Device Is Blank message box.
- Click the Program button in the dialog box. A new dialog box will appear;
do not touch it. Programming should proceed to a successful conclusion.
At this point, it comes up with a message saying that the calibration location
is already programmed, and was not programmed at this time. This is a good
result; it means that the factory calibration of the 4 MHz oscillator on
the chip is present.
- Unload the chip from the programmer, and put it on the speed controller
board.
I do not know how other programmers for this processor work. However, a requirement
is that they not overwrite location H'3FF' in instruction memory; this location
is programmed at the factory to make the built in clock oscillator run at the
proper frequency. The hex file does not specify a value for this address, so
that programmers which program only what is in the hex file will work fine.
(Note: the hex file addresses are double the instruction memory addresses; two
bytes are present for each instruction.)
Copyright © 1998 by Michael J. Norton.
May be copied as desired and modified as needed so long as
this copyright notice is preserved.
Back to Mike Norton's Hobbies