A possible schematic for understanding and playing with my jal libraries
and PIC16F877 is below:
The schematic shows also ( in the left&bottom
size of the drawing ) the corrected version of wloader hardware, tested
on many RS232 interfaces including laptop's. Both 9pin (x1) and 25pin
(x2), serial connectors are connected through about 1...1.5m of 7wires
ribbon ( 4 driving GNDs and the other DSR,TX,RX interlaced with grounds
) cable. The whole electronics (D1, D2, T2, R5, R6, R7, R9 )
fit into 1x2 cm board including 2.54mm wloader female connector (SV3).
Prototype board, must have the male connector to interface with wloader
hardware. A key ( pin3 of SW2, SW3 connectors) made by cutting a pin from
the male connector and soldering a whole in female connector prevent any
accidental reverse connections. Wloader
is
the bootloader name which will allow faster LVP ( low voltage programming
) of the pic microcontroller. ICSP ( in circuit serial programmer ) connector
(SW1) is used only once, to load the wloader firmware into the pic, or
anytime the user want to do a HVP ( high voltage programming ).
Two crystals are used: 4MHz for master clock and 32.768 Hz for real
time clock.
The analogic section can measure two
analogic signals ( ANA1 and ANA2 ), absolute maximum input ratings for
these inputs are: -0.5V to +5V. Two variable reference voltage, controlled
by R13 ( -0.5V...+5V ) and R14 ( 0V ...+5V ) supply the pic reference pins.
Even if Microchip specifications don't mention, 877 AD is capable for
negative input measurement with the same resolution and linearity
from -0.5V to +4.5V, without any chip damage, using adx_refboth procedures
from janalog.jal library and -Vref=-0.5 V, +Vref=+4.5V . WARNING: exceding
-0.6 V on any input will broke out the iinternal clamping diode if there
are no limiting current resistors ( in schematic, R11, R12, R15 )
The maximum adc gain without resolution loss is obtained for |+Vref|
- |-Vref| = 2.5V...3V and is slighty diffferent from pic to pic chip. This
condition is true only for:
0 < |-Vref| < +2.5V and
+2.5V < +Vref < +5V
Four buttons (BU1,BU2, BU3, BU4) are used
for user interface. A stepper driver (U12) ULN2803 can drive two 12V unipolar
steppers ( L1...L4 and L5...L8 ). The LCD display use 10 wire mode for
pic connection, 8 data bits and two control bits. For serial connection
between board and PC, I've use the cheapest interface method with 1488/1489
drivers. These needs +12V/-5V/+5V supply. In the above example, auxiliary
supply ( +12V, -5V ) are sourced from an external power supply ( a PC power
supply is really good ) because the steppers coud "eat" a large current.
For application using only 1488/1489 chips, which needs only a few miliampers
a simple charge pump design, driven by one pic pin could solve all problems.
To avoid noise problems, grounds where splitted in three: GND is the digital
ground, GND1 is the power ground and AGND is the analogic ground. The user,
must take care to connect these grounds in one point near x4 connector
supply.( Jp1 and Jp2 are doing this when a pcb is created from sch file)
Example1. Reading
ANA1 and displaying 10 bits as binary, hexadecimal and bcd value on LCD.
Set first -Vref =0V by R13 and +Vref=+5V by R14. Apply to ANA1 a variable
voltage between 0 and +5V using a 5K potentiometer connected as a voltage
divider, between GND and VCC, cursor to ANA1.
analog1.jal
-- the example program
f877_lcd.jal
-- lcd pin connection to pic
janalog.jal
-- analogic library, required also in exxample2
hd44780m.lib -- modified lcd
library, you need to change the "include hd44780" with
"include hd44780m" in hd447808.jal library
Example2. Reading
two analogic voltage ANA1 and ANA2 and displaying as BCD value on LCD's
line1 and line2.
Playing with references, -Vref = -0.5V, +Vref = +4.5V and -Vref
= 2V, +Vref = 4V. Build a table and check the measuring range for those
reference pairs, and the AD liniarity.
analog2.jal
-- read and display an AD result
analog3.jal
-- a faster reading of two channel and ddisplay
The other librarys from example1 are also required here.
Example3. Play a song using CCP1 module as PWM using music.jal. I hope that copy and paste tehnique, to obtain the real jal file is not too difficult for you... thanks to Microsoft for windows environment...or to Peter Norton for his commander...or to DOS for his help file...(or to God for our minds)
Example4. Debouncing
buttons and modify steppers direction.
stepper.jal
Example5. Test the
PIC16F877 USART at 115200 bps ( or your desired baud rate ) . In this example
PIC will ecchoing
the keyboard . Don't forget to set the terminal emulator parameters
identical with your communications
( here: 115200, 8, n, 1, no flow control or hardware flow control ).
Note that you need at least 10MHz or better a 20MHz quartz oscillator for
this baudrate.
usart.jal corrected and
updated !
Example6.This is your turn ! Send both analogic data from ANA1 and ANA2 ,sampled at every one second to the PC ! I'm waiting to see how you've solved the problem . Mail me at jallist@yahoogroups.com after you have a functional example and your name and your work will be in this page ! Great, isn't it ?
Fantastic ! A jal user has done this job. There is hope on this
Earth... Almost no one reader of these pages haven't decided to gave something
in exchange for those informations. Except Schäppi
Primus who have written a short jal program which will send to
the PC, with 9600, every second, the following four bytes: 241, 241, ch_hi,
ch_lo. The two 241 are marking the begining of the next transmit sequence.
In the PC you have two programs for receiving. The simpler one is rs.exe.
It is a DOS
program. Analog6.xls is an exel sheet with a VBA macro.
It works only if you have copied first the rsmini.dll
in the windows.000 folder or in the system files folder. Everything you
need for running this example is on the zipped file:
example6.zip
I'm waiting to see if you can do something better, like sending
the ADC value to the PC, directly in ASCII format, every
100 microseconds or less, using TMR0 for precise time generation !
This will be Example7 ... could you
write and test it just for free ?
To my PIC-page
Use all information on this page as do you want to,
feel
free even
to
dream the examples... A nice
postcard to me, from those will apply something from here into a production
product, and one dollar for Jal compiler creator will be nice too...
page address:
http://www.oocities.org/vsurducan/electro/PIC/f877.html
email address:
vasile@l30.itim-cj.ro