[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 580: sizeof(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 636: sizeof(): Parameter must be an array or an object that implements Countable
Brads Electronic Projects Forum • Christmas ornament project - Page 2
Page 2 of 2

Re: Christmas ornament project

Posted: Sun Dec 04, 2016 8:38 pm
by brad
I just found some code from a number of years ago which should really help you out. It uses a different microcontroller however you should be able to simply change the ports to the ports you are using for the RED cathodes, Green cathodes and the common anodes - then change the microcontroller details, update clock settings etc.

Let me know how you go with this code - I hope it helps out.
FirstScrollTest.bas.zip
(1.28 KiB) Downloaded 640 times

Re: Christmas ornament project

Posted: Tue Dec 06, 2016 11:18 pm
by MrDEB
your code really helped.
I changed the ports, eliminated portE and D, redid the const arrays and ran out of memory (too many bytes in the const arrays).
Thanks

Re: Christmas ornament project

Posted: Fri Dec 09, 2016 12:07 am
by MrDEB
One big issue now is it cycles one time correctly then starts jumbeling text then freezes up.
thinking it is running out of memory with all the const arrays etc.
usiong an 18F24k20 pic

Re: Christmas ornament project

Posted: Fri Dec 09, 2016 4:18 am
by bitfogav
Can you post you're current code so we can see what these "Const arrays" are..

Re: Christmas ornament project

Posted: Fri Dec 09, 2016 8:30 am
by MrDEB
here is the compressed file. It shouldn't matter that I had to rearrange the const data array bits as I mistakenly had the boards wired wrong (the first 4 bits had to be reversed) but it shouldn't make a difference.
going to try the code on my proto-type display to see if it locks up as well.
Looking at why are the constant arrays loaded more than one time?? maybe running out of memmory?
this code shows 685 program bytes used and 50 variables

Re: Christmas ornament project

Posted: Fri Dec 09, 2016 8:54 am
by bitfogav
I kind of find it hard that it's running out of memory?. Can you please upload the .bas file for the code please as the file you uploaded only contains the .idf file.

Re: Christmas ornament project

Posted: Fri Dec 09, 2016 11:37 am
by MrDEB

Code: Select all

' 8x8 RG Matrix Scrolling text test
' PORTB = RED LED Cathodes
' PORTB = GREEN LED Cathodes
' PORTC = Anodes


DEVICE = 18F24K20           ' Tell the compiler what chip we are using
CLOCK = 8                  ' Tell the compiler what we will be setting the clock to (in Mhz)           
CONFIG MCLRE = OFF          
CONFIG FOSC = intio67       ' Internal oscillator, IO on pins 6 and 7

INCLUDE "utils.bas"



CONST RedData(105) AS BYTE =     (%00110111,%01000000,%00100000,%01000000,%00110111,%00000000,%01110111,%01010100,
                                  %01000010,%00000000,%01110111,%01000001,%01110010,%00000100,%00000000,%01111110,
                                  %01000001,%01110001,%00000010,%00000100,%00000000,%01100000,%00010000,%00000111,
                                  %00010000,%01100000,%00000000,%00000000,%00000000,%01110111,%01000100,%01000100,                                
                                  %00000000,%01110111,%00010000,%00010000,%01110111,%00000000,%01110111,%01000001,
                                  %00110010,%00000100,%00000000,%01110111,%00000000,%01110100,%01010100,%01010111,
                                  %00000000,%01000000,%01000000,%01110111,%01000000,%01000000,%00000000,%00110111,
                                  %01000000,%01000000,%00100000,%01000000,%01110111,%00000000,%00110111,%01010000,
                                  %01010000,%01110111,%00000000,%01110100,%01010100,%01010111,%00000000,%00000000,// custom
                                  %01110111,%01010100,%01000100,%00000000,%01110111,%00000100,%00000100,%00000000,
                                  %01110111,%01010100,%01000100,%00000000,%01110111,%01000100,%01000100,%00000000,
                                  %01110111,%01000001,%01110010,%00000100,%00000000,%00110011,%01000100,%01000100,
                                  %00110010,%00000000,%01110111,%00000100,%00000011,%00000100,%01110111,%00000000,
                                  %00000000)

''CONST GreenData(105) AS BYTE = (%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%01111100,%10000010,%10000010,%01000100,%00000000,%11111110,%00010000,%00010000,%11111110,%00000000,%11111110,%00010010,%00010010,%11101100,%00000000,%10000010,%11111110,%10000010,%00000000,%01001100,%10010010,%10010010,%01100100,%00000000,%00000010,%11111110,%00000010,%00000000,%11111110,%00000100,%00011000,%00000100,%11111110,%00000000,%11111100,%00010010,%11111100,%00000000,%01001100,%10010010,%10010010,%01100100,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000)



DIM RedLEDs AS PORTb
DIM GreenLEDs AS PORTa
DIM Anodes AS PORTC




DIM GreenBuffer(8) AS BYTE
DIM RedBuffer(8) AS BYTE
DIM x AS BYTE
DIM ScrollingTextOffset AS WORD
DIM ScrollingTextSpeed AS BYTE
DIM DefaultScrollingTextSpeed AS BYTE

SUB UpdateScrollingText()
    IF ScrollingTextSpeed <> 0 THEN
        DEC(ScrollingTextSpeed)
    ELSE
        ScrollingTextSpeed = DefaultScrollingTextSpeed 
        INC(ScrollingTextOffset)
        IF ScrollingTextOffset > (BOUND(RedData) - 8) THEN ' we need to check if we have reached the start of the last eight columns of data that's why we take away 8
            ScrollingTextOffset = 0
        ENDIF
    ENDIF         
END SUB

SUB SaveGraphics()
    FOR x = 0 TO 7
        ''GreenBuffer(x) = GreenData(x + ScrollingTextOffset)
        RedBuffer(x) = RedData(x + ScrollingTextOffset)
    NEXT
END SUB

SUB DisplayGraphics()
    FOR x = 0 TO 7
        ''GreenLEDs = GreenBuffer(x) XOR %11111111
        RedLEDs = RedBuffer(x) XOR %11111111
        Anodes.bits(7 - x) = 1
        DELAYUS(520)
        Anodes.bits(7 - x) = 0
    NEXT
END SUB

SetAllDigital

TRISA = %00000000           ' PORTA outputs 
TRISB = %00000000           ' PORTB outputs
TRISC = %00000000           ' PORTC outputs
'TRISD = %00000000           ' PORTC outputs
'TRISE = %00000001           ' PORTC outputs  except pin 0

// Start Of Program
OSCCON = %01100000          ' Internal oscillator running at 8mHz
'OSCTUNE.bits(6) = 1         ' enable PLL so we can run this thing at 32Mhz

//GreenLEDs = %00000000   ' we will be xor'ing the led data to make sure it sends logic 0's to turn on the LED
RedLEDs = %00000000   ' we will be xor'ing the led data to make sure it sends logic 0's to turn on the LED
Anodes = %00000000

ScrollingTextOffset = 0     
DefaultScrollingTextSpeed = 45  
ScrollingTextSpeed = DefaultScrollingTextSpeed
 SaveGraphics
// Main Loop
WHILE True()                        // This creates an infinite loop
    UpdateScrollingText  
    
    DisplayGraphics                                   
WEND                                // Loop back to the while loop as long as we havent finished.



Re: Christmas ornament project

Posted: Sat Dec 10, 2016 5:11 am
by MrDEB
found that the code freezes when using battery power but not when pickit2 connected.????

Re: Christmas ornament project

Posted: Sat Dec 10, 2016 5:32 am
by bitfogav
I can only suspect that when using battery power that the BOR is resetting due to a low voltage.

Try adding the following to the code within you're CONFIG section:

Code: Select all

CONFIG  BOREN = OFF
Also is this the same fault as before? running out of memory??? :?

Re: Christmas ornament project

Posted: Sat Dec 10, 2016 7:16 am
by MrDEB
It is the same issue as when I thought?? it was / is a memory issue
will try your suggestion

Re: Christmas ornament project

Posted: Sat Dec 10, 2016 7:49 am
by bitfogav
Ok, well update us when you have tried adding the BOREN code. because I know Brads code works perfectly here on my hardware.

Re: Christmas ornament project

Posted: Sat Dec 10, 2016 9:51 pm
by bitfogav

Re: Christmas ornament project

Posted: Sun Dec 11, 2016 12:46 am
by MrDEB
YES thank you.
I just need to correct my schematic incase I decide to make more.
I have the first 4 bits connected to the matrix wrong

Re: Christmas ornament project

Posted: Sun Dec 11, 2016 8:27 pm
by brad
Sorry I'm just now back after a busy week. Good to see things are working out well and good pickup with the Brown Out Gav :)

Re: Christmas ornament project

Posted: Mon Dec 12, 2016 6:38 am
by MrDEB
Well here is an Alphabete file with upper / lower case letters. Did it in open office
hope you can use.
As for the brightness of the LED display, iy appearsd very bright. Could be using the 18F24K20 ??