Hello Everyone! I'm progressing with my Tach project. I finally have all the parts
I need at leastThings had been progressing until I ran into this bug...
The Circuit:
I'm using a 16F877 and a Max7219. I have each individual segment attached
to the anode of a discreet LED. The cathodes are all connected common to DIGO
of the Max7219. I have 8 LED's total connected (using the DP's output too).
The Code:
I've taken code written for the Basic Stamp 2 and modified it to work with my
PicBasic Pro / hardware setup. The final version will have 32 LED controlled
by Max7219 & 16F877. Code is listed below.
The Problem:
The code will count binary up to 14. When it reaches 15 (f) or 00001111 it
completely halts and all the LED's turn off. I thought it was pulling too
much current so I ran the shiftout function with %1111111111111111/16 which
turned on all the LED successfully so I'm guessing this is not an issue of
drawing too much current.
Request:
Anyone have PicBasic Pro Code that supports the Max7219 driving LED's and
not Digits? Ideally with the 16f877 and the microcontroller. If not, I can
remap the I/O pins.
I've explored modifying the scan limit, decode mode, intensity, shutdown
mode etc. still no favorable results.
Thank you for your time,
Netjammer-
Code:' ========================================================================= include "modedefs.bas" ' -----[ Program Description ]--------------------------------------------- ' Counting binary from 0 to 1111 (want to go to 11111111 but routine halts '& LED's turn off ' -----[ Revision History ]------------------------------------------------ ' -----[ I/O Definitions ]------------------------------------------------- 'symbol MAX_Data = PORTC.5 'line for data input connected to RC5 'symbol MAX_Clk = PORTC.3 'CLK line connected to pin RC3 'symbol MAX_Load = PORTA.3 symbol DOUT = PORTC.5 'line for data input connected to RC5 symbol CLK = PORTC.3 'CLK line connected to pin RC3 symbol Load = PORTA.3 'line for Load connected to RA3 ' -----[ Constants ]------------------------------------------------------- IsLow CON 0 IsHigh CON 1 ' -----[ Variables ]------------------------------------------------------- DIG0 VAR Word DIG1 VAR Word DIG2 VAR Word Value VAR byte Ken VAR byte ' -----[ EEPROM Data ]----------------------------------------------------- ' -----[ Initialization ]-------------------------------------------------- Dig0 = $0100 Dig1 = $0200 Dig2 = $0300 Value = 0 Ken = 0 ' -----[ Program Code ]---------------------------------------------------- Begin: GOSUB DecodeMode GOSUB ShutDownMode GOSUB ScanLimit GOSUB Intensity Continue: 'the for next loop is set up to cause each digit to count up 'sequentially from 1 to 100 FOR Ken = 0 TO 100 PAUSE 500 Dig0 = Dig0 | Value Dig1 = Dig1 | Value Dig2 = Dig2 | Value 'first digit least significant LOW Load SHIFTOUT DOUT, CLK, MSBFIRST,[Dig0\16] HIGH Load PAUSE 40 'second digit ' LOW Load ' SHIFTOUT DOUT, CLK, MSBFIRST,[Dig1\16] ' HIGH Load ' PAUSE 40 'third digit ' LOW Load ' SHIFTOUT DOUT, CLK, MSBFIRST,[Dig2\16] ' HIGH Load ' PAUSE 40 Value = Value + 1 Dig0 = $0100 ' Dig1 = $0200 ' Dig2 = $0300 NEXT Value = 0 Dig0 = $0100 ' Dig1 = $0200 ' Dig2 = $0300 GOTO Continue END ' -----[ Subroutines ]----------------------------------------------------- 'Decode mode for no decoding to BCD 'Least sig nibble: '0 = no decode '1 = decode digit 0 'F = decode digits 0-3 'FF = decode digits 0-7 DecodeMode: LOW Load ' SHIFTOUT DOUT, CLK, MSBFIRST,[$090F\16] SHIFTOUT DOUT, CLK, MSBFIRST,[$0900\16] HIGH Load RETURN 'Set shutdown mode so device is active ShutDownMode: LOW Load SHIFTOUT DOUT, CLK, MSBFIRST,[$0C01\16] HIGH Load RETURN 'Set scan limit mode for three digits ScanLimit: LOW Load ' SHIFTOUT DOUT, CLK, MSBFIRST,[$0B02\16] SHIFTOUT DOUT, CLK, MSBFIRST,[$0B00\16] HIGH Load RETURN 'Set intensity of LEdDs 'LSNibble 0 = min intensity and F = max intensity Intensity: LOW Load SHIFTOUT DOUT, CLK, MSBFIRST,[$0A09\16] HIGH Load RETURN


Things had been progressing until I ran into this bug...


Bookmarks