Christmas ornament project

Post here to let others know of a project you're working on.

Moderators: Chuckt, Garth, bitfogav

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Christmas ornament project

Post by brad » Sun Dec 04, 2016 8:38 pm

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 698 times

MrDEB
I practically live here!
I practically live here!
Posts: 372
Joined: Fri Feb 18, 2011 4:24 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Christmas ornament project

Post by MrDEB » Tue Dec 06, 2016 11:18 pm

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

MrDEB
I practically live here!
I practically live here!
Posts: 372
Joined: Fri Feb 18, 2011 4:24 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Christmas ornament project

Post by MrDEB » Fri Dec 09, 2016 12:07 am

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

User avatar
bitfogav
Moderator
Moderator
Posts: 915
Joined: Sun Mar 28, 2010 9:03 pm
Location: United Kingdom
Contact:

Re: Christmas ornament project

Post by bitfogav » Fri Dec 09, 2016 4:18 am

Can you post you're current code so we can see what these "Const arrays" are..
If you don't know what Voltage your country is using, you shouldn't be doing electronics ;-)

MrDEB
I practically live here!
I practically live here!
Posts: 372
Joined: Fri Feb 18, 2011 4:24 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Christmas ornament project

Post by MrDEB » Fri Dec 09, 2016 8:30 am

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
Attachments
FirstScrollTest33.zip
(2.36 KiB) Downloaded 604 times

User avatar
bitfogav
Moderator
Moderator
Posts: 915
Joined: Sun Mar 28, 2010 9:03 pm
Location: United Kingdom
Contact:

Re: Christmas ornament project

Post by bitfogav » Fri Dec 09, 2016 8:54 am

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.
If you don't know what Voltage your country is using, you shouldn't be doing electronics ;-)

MrDEB
I practically live here!
I practically live here!
Posts: 372
Joined: Fri Feb 18, 2011 4:24 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Christmas ornament project

Post by MrDEB » Fri Dec 09, 2016 11:37 am

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.



MrDEB
I practically live here!
I practically live here!
Posts: 372
Joined: Fri Feb 18, 2011 4:24 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Christmas ornament project

Post by MrDEB » Sat Dec 10, 2016 5:11 am

found that the code freezes when using battery power but not when pickit2 connected.????

User avatar
bitfogav
Moderator
Moderator
Posts: 915
Joined: Sun Mar 28, 2010 9:03 pm
Location: United Kingdom
Contact:

Re: Christmas ornament project

Post by bitfogav » Sat Dec 10, 2016 5:32 am

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??? :?
If you don't know what Voltage your country is using, you shouldn't be doing electronics ;-)

MrDEB
I practically live here!
I practically live here!
Posts: 372
Joined: Fri Feb 18, 2011 4:24 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Christmas ornament project

Post by MrDEB » Sat Dec 10, 2016 7:16 am

It is the same issue as when I thought?? it was / is a memory issue
will try your suggestion

User avatar
bitfogav
Moderator
Moderator
Posts: 915
Joined: Sun Mar 28, 2010 9:03 pm
Location: United Kingdom
Contact:

Re: Christmas ornament project

Post by bitfogav » Sat Dec 10, 2016 7:49 am

Ok, well update us when you have tried adding the BOREN code. because I know Brads code works perfectly here on my hardware.
If you don't know what Voltage your country is using, you shouldn't be doing electronics ;-)

User avatar
bitfogav
Moderator
Moderator
Posts: 915
Joined: Sun Mar 28, 2010 9:03 pm
Location: United Kingdom
Contact:

Re: Christmas ornament project

Post by bitfogav » Sat Dec 10, 2016 9:51 pm

If you don't know what Voltage your country is using, you shouldn't be doing electronics ;-)

MrDEB
I practically live here!
I practically live here!
Posts: 372
Joined: Fri Feb 18, 2011 4:24 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Christmas ornament project

Post by MrDEB » Sun Dec 11, 2016 12:46 am

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

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Christmas ornament project

Post by brad » Sun Dec 11, 2016 8:27 pm

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 :)

MrDEB
I practically live here!
I practically live here!
Posts: 372
Joined: Fri Feb 18, 2011 4:24 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Christmas ornament project

Post by MrDEB » Mon Dec 12, 2016 6:38 am

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 ??
Attachments
Alphabete.zip
A to Z in binary
(10.2 KiB) Downloaded 617 times

Post Reply
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Who is online

Users browsing this forum: No registered users and 6 guests