Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

3x3x3 LED Cube - can i use16f628 instead 16f690

Status
Not open for further replies.
You can't lite two whole rolls it pulls to much power If you lit all leds it uses 540mA
pic can only put out 200mA max two rolls is 320 mA one rollis 180 the cube blinks the led to make it look like it's lighing all of them
 
That's what current pass transistors are for.
 
I'm not even going to go there I show them how to change the code from 16f690 to a 16f628 and how to wire it up for the 16f628 but you can't light all the leds at 1 time you can blink them one at a time. Now if they want to light all them there on there own.
 
Be i try the code to my cube like this :

list p=16f628A ; list directive to define processor
#include <p16F628A.inc> ; processor specific variable definitions

errorlevel -302 ; suppress message 302 from list file

__CONFIG _CP_OFF & _DATA_CP_OFF & _LVP_OFF & _BOREN_OFF & _MCLRE_OFF & _WDT_OFF & _PWRTE_OFF & _INTOSC_OSC_NOCLKOUT

cblock 0x20 ;start of general purpose registers
count1 ;used in delay routine
counta ;used in delay routine
countb ;used in delay routine
endc


org 0x0000 ;org sets the origin, 0x0000 for the 16F628,
;this is where the program starts running
movlw 0x07
movwf CMCON ;turn comparators off (make it like a 16F84)
bsf STATUS, RP0 ;select bank 1
movlw b'00000000' ;set PortB all outputs
movwf TRISB
movwf TRISA ;set PortA all outputs
bcf STATUS, RP0 ;select bank 0

main:
banksel PORTA
bsf PORTA,2
bsf PORTA,7 ;change this for each roll 5,6 and then 7
bcf PORTA,5 ; can't turn off layer RA5
bcf PORTA,6 ; can't turn off layer RA7

goto blinkleds
blinkleds:
banksel PORTB
bsf PORTB,0
call delay
bcf PORTB,0
call delay
bsf PORTB,1
call delay
bcf PORTB,1
call delay
bsf PORTB,2
call delay
bcf PORTB,2
call delay
bsf PORTB,3
call delay
bcf PORTB,3
call delay
bsf PORTB,4
call delay
bcf PORTB,4
call delay
bsf PORTB,5
call delay
bcf PORTB,5
call delay
bsf PORTB,6
call delay
bcf PORTB,6
call delay
bsf PORTB,7
call delay
bcf PORTB,7
call delay
banksel PORTA
bsf PORTA,2
call delay
bcf PORTA,2
call delay
goto blinkleds


delay
movlw d'50' ;delay 250 ms (4 MHz clock)
movwf count1
d1 movlw 0xC7
movwf counta
movlw 0x01
movwf countb
Delay_0
decfsz counta, f
goto $+2
decfsz countb, f
goto Delay_0

decfsz count1 ,f
goto d1
retlw 0x00

end

what i have ? all led blink at layer5,6 and 7 could you explain it ? i am very curious couse i can't control led by led layer by layer....
 
Try this and see if it don't work for you
Code:
list p=16f628A ; list directive to define processor
 #include <p16F628A.inc> ; processor specific variable definitions

 errorlevel -302 ; suppress message 302 from list file

 __CONFIG _CP_OFF & _DATA_CP_OFF & _LVP_OFF & _BOREN_OFF & _MCLRE_OFF & _WDT_OFF & _PWRTE_OFF & _INTOSC_OSC_NOCLKOUT

	cblock 0x20 ;start of general purpose registers
	count1 ;used in delay routine
	counta ;used in delay routine
	countb ;used in delay routine
	endc


	org 0x0000 ;org sets the origin, 0x0000 for the 16F628,
	;this is where the program starts running
	movlw 0x07
	movwf CMCON ;turn comparators off (make it like a 16F84)
	bsf STATUS, RP0 ;select bank 1
	movlw b'00000000' ;set PortB all outputs
	movwf TRISB
	movwf TRISA ;set PortA all outputs
	bcf STATUS, RP0 ;select bank 0
	clrf PORTA

main:
	banksel PORTA
	bsf PORTA,7       	;turn on top
	call blinkleds    	; blink your leds
	bcf PORTA,7		  	;turn off top	
	bsf PORTA,6			;turn on middle
	call blinkleds		; blink your leds
	bcf PORTA,6			;turn off middle
	bsf PORTA,5			;turn on bottom
	call blinkleds		; blink your leds
	bcf PORTA,5			;turn off bottom
	goto main			;go back and keep doing it
blinkleds:
	banksel PORTB
	bsf PORTB,0
	call delay
	bcf PORTB,0
	call delay
	bsf PORTB,1
	call delay
	bcf PORTB,1
	call delay
	bsf PORTB,2
	call delay
	bcf PORTB,2
	call delay
	bsf PORTB,3
	call delay
	bcf PORTB,3
	call delay
	bsf PORTB,4
	call delay
	bcf PORTB,4
	call delay
	bsf PORTB,5
	call delay
	bcf PORTB,5
	call delay
	bsf PORTB,6
	call delay
	bcf PORTB,6
	call delay
	bsf PORTB,7
	call delay
	bcf PORTB,7
	call delay
	banksel PORTA
	bsf PORTA,2
	call delay
	bcf PORTA,2
	call delay
        goto main


delay
 	movlw d'50' ;delay 250 ms (4 MHz clock)
 	movwf count1
d1 
	movlw 0xC7
	movwf counta
	movlw 0x01
	movwf countb
Delay_0
	decfsz counta, f
	goto $+2
	decfsz countb, f
	goto Delay_0
	
	decfsz count1 ,f
	goto d1
	retlw 0x00

	end
 
Last edited:
yoo hoo!

Post your code if don't get it to work use the code tags and maybe get that bike rolling

i got it right what i want it...
i put some code before 'output'
here they are....

Outputa:
btfss PORTA,1
goto Loop
btfss PORTA,2
goto Loop
call Output
return

Outputb:
btfss PORTA,1
goto Loop
btfss PORTA,5
goto Loop
call Output
return

Outputc:
btfss PORTA,2
goto Loop
btfss PORTA,5
goto Loop
call Output
return

so now when i push one of the button
the subroutine is change imidiately....
i'm soooo happpppyyy''' :D:D:D
 
now i'm trying to put one switch (@RA5 maybe?) to change mode...
mode1 for a default
switch1 run subroutine1a, sw2 run sr2a and sw3 run sr3a
when i push that button
it change to mode2
switch1 run subroutine1b, sw2 run sr2b and sw3 run sr3b
push it again
to change to mode3
switch1 run subroutine1c, sw2 run sr2c and sw3 run sr3c

any suggestion?
 
You can poll the switches and when it gos high have it go any where you want with a goto
 
Last edited:
Hey be80be i was looking at the schematic you posted earlier and the values for the resistors are different from the values used by the one on instructables **broken link removed** . So i was wondering are those values different because you used a pic16f628a and he used a 690 or because u used different leds (the ones i will be using have a max current of 25mA)? I have a 628a which plan to use for this project and i have 220 and 330 ohm resistors at home already, so i just wanted to know whether i could sub them in instead of the ones you used. Sorry if this is stupid question, I am fairly new to PICs.
 
The values I posted gets the most out of your cube make sure you use this circuit
 

Attachments

  • 16f628led cube.PNG
    16f628led cube.PNG
    11.1 KB · Views: 454
Last edited:
Dear be80be,

this is what i've achieved

YouTube - Microcontroller LED on Bike

but i always failed to give it fade effect on Magicball subroutine
(i attach the asm)
i already tried everything said in this forum with no result
could you help me on this one sir

Best Regards,

Welflash
 

Attachments

  • Lights.asm
    33.2 KB · Views: 283
That looks grate if you want to fade you use pwm on the row transistors and set the duty to start at 100 and go to 0 then it's all up to setting the timing right i haven't done any pwm with that chip have to read the datasheet. but the pwm is the best way to dim leds in and out
 
It will work just change ports to what your going to use and the config.
16f628.inc to 16f877 and the List.
 
Hey be80be thanks for replying. I constructed my circuit using your schematic, but nothing happens when i plug in my 9v adapter, the cube doesn't light up. Is there any specific way that I should solder the cathodes of the leds together for each layer, or it doesn't matter as long as all the cathodes for each layer are connected?
 
Never mind turns out i had used the old led.hex file u had posted. I programmed the pic again with the other hex file and it works! Thanks
 
hehe. I've done that before, took me 20 minutes to figure out what I was doing wrong.
 
Haha yea it took me longer than that. It was bothering me the whole night until finally i thought that it might be the pic. Anybody know any more projects i can do with the pic16f628a? Ive done the cube and also an 8 channel pwm led chaser. I have an obsession with leds so any projects that use them would be cool.
 
Status
Not open for further replies.

Latest threads

Back
Top