Lego-Knex
Robbert
Mattijs
Mindstorms PIC programmer 
(hardware version 2)
Stef Mientki
september  2001
Software

Download

Why another PICprogrammer 
The reason is simple, everything I tried didn't work for 100% (specially programming the normal version of the PIC16F84 give rise to problems). For more background information and things I tried, see hardware version 1.

Specifications 
The programmer connects to a free RS232 port of the PC and doesn't need external power supply.
The programmer is tested under windows-98 on a PII-66 and a PIII-1000.
Everything, including sources, is available (for free of course).

Tested PICs (ordened by family)
16x8x 16F62x 16F87x
16F84
16F84A
16F628 16F876

Operating Instructions 
It's important to follow the steps described below in the right order, because applying a voltage to the programmer pin of the PIC, without the PIC is supplied from a +5Volt source, can damage the PIC.

  1. start the program and select the right RS232 port (this will ensure that the voltage on the programmer will be ok) The voltages generated by the circuit can be tested before inserting a PIC, see here)
  2. set the switch on the programmer in the run mode (this will ensure that the program voltage will not be present until the +5Volt is present)
  3. now connect the programmer to the selected RS232 port
  4. now you can savely put the switch on the programmer in program mode


Circuit 
The circuit shown below is straight forward. The major differences with other simple programmers is the feedback lines for both clock and data signals (see for futher details, the current design).
You can roughly test if your serial port is capable of delivering enough current, by connecting a resistor between DTR and GND and measuring the voltage.

Finding the optimal signal connections
Programming Running RCX MindScope
DTR program clock,
when 0 = +5V power
0 = 5V power supply for PIC not used, low 1 = power generating for batteryless tower
DSR echo of DTR (clock) - - -
RTS program data,
power for RS232 from PIC
when 0 = +5V power
1 = enable PIC, 
power for RS232
1 = tower on
0 = tower off (after 3 seconds)
1 = tower on
0 = tower off
CTS echo of RTS (data)
or
Read data
- = RTS, 
used to check if tower is present
= RTS
TxD +5V power supply RS232 data to PIC
when 0=+5V power supply
TxD TxD
RxD - RS232 data from PIC,
gets positive power supply from RTS
RxD RxD

Start the program, Tools / Settings / Commport / ...
Connect to right port, enable DTR and measure the voltage between DTR (pin 4) and GND (pin5)
The voltage should be >=5Volt, for the resistor value yields
     1 kOhm  --> 5 mA  (will do for the new devices, i.e. 16F84A)
     500 Ohm  --> 10 mA  (necessary for old devices, i.e. 16F84


 

Testing the circuit

  1. check the wiring
  2. always start the program before connecting the circuit to the RS232 port (another program could set the RS232 port totally wrong)
  3. goto menu Tools / Settings / Commport / ... CTS and DSR panels light yellow
  4. set the switch in RUN mode and connect the circuit to the RS232 port
  5. now activate the connect checkbox, and CTS and DSR panels should light green
  6. activate DTR checkbox and CTS panel should light red
  7. activate RTS checkbox and DSR panel should light red
  8. Now test if the voltage on the PIC-foot are according to the next table
With the switch in RUN mode, approximally the following voltages should be measured at the mentioned PIC pins
DTR low, RTS low DTR high, RTS low DTR low, RTS high DTR high, RTS high
4 = 5.5 V
13 = 1.5 V
14 = 5.5 V
all others 0 V
4 = 5.5 V
13 = 4.5 V
14 = 5.5 V
all others 0 V
4 = 5.5 V
12 = 10 .. 14 V
13 = 1.5 V
14 = 5.5 V
all others 0 V
4 = 5.5 V
12 = 10 .. 14 V
13 = 4.5 V
14 = 5.5 V
all others 0 V
With the switch in program mode, all measurements should be the same, except pin 4 should measure 13 Volt in case DTR and/or RTS is high.
 

History 
 
ideas for the future
  • some suggest small capacitors (of 300 pF ?) are needed across data and clock lines ?
3-11-2001
  • disabling the oscillator, in case a X-tal is connected to the PIC
  • connector with signals for in-circuit-programming of PIC's on other boards
  • connecting an external power supply (if more electronics is present)
  • make it fully compatible with the cheaper (and complexer) 16F627/16F628
October 2001
  • Idea added to increase the program voltage in case of bad RS232 lines
Septemnber 2001
  • The first design