Jump to content

[solved] DOUT + ULN2803 problem


protofuse
 Share

Recommended Posts

hello,

I probably exhumed an old thread by posting that: http://www.midibox.o...index.php/topic,12786.msg121206/topicseen.html#msg121206

so I'd prefer to repost another topic.

1 DOUT where the first SR is connected to 1 ULN2803 with his pin 9 to GND (pin 10 not connected to anything)

the purpose is the handling of a 8x8 RGB common cathode led matrix.

the code comes from ain64_din128_dout128 apps.

SR_Service_Prepare has been modified to handle the ULN to cycle the matrix.

it doesn't work.

I guess it should, because noofny/mike did... we have the same code, and almost the same hardware.....

BUT, he chained his 2 DOUT on the same core, I have 1 DOUT per core.

the code has been altered to fit with my hardware, of course.

but I may missed something.

the code part to look at are :

void DisplayLED(unsigned char column, unsigned char color) __wparam

{

	color >>= 4;

	MIOS_DOUT_PinSet(column+8,		(color & 0x01)); 	// RED

	color >>= 1;

	MIOS_DOUT_PinSet(column+8+8,	(color & 0x01)); 	// BLUE

	color >>= 1;

	MIOS_DOUT_PinSet(column+8+8+8,	(color & 0x01));	// GREEN

}

/////////////////////////////////////////////////////////////////////////////

// This function is called by MIOS before the shift register are loaded

/////////////////////////////////////////////////////////////////////////////

void SR_Service_Prepare(void) __wparam

{

	// HELPED BY BUGFIGHT ON MIDIBOX - http://www.midibox.org/forum/index.php/topic,12786.0.html

	static unsigned char row;

	unsigned int x; 							//edit* just noticed, no reason for this to be static

	row = ++row & 0x07; 						//<-- here you were cycling 16 rows i think you meant 8, no?

												//this would have resulted in a 6.25% duty cycle (vs 12.5%).

												//note that the duomatrix uses a 25% duty cycle

	MIOS_DOUT_SRSet(_MATRIX_DOUT_START, 0);	//<-- hardwire bad, napster good. define constants

											// so you can move your matrix in the chain

	MIOS_DOUT_PinSet1(row);


	for (x = 0; x < 8; x++)

	{

		DisplayLED(x , matrix[row][x]);

	}

}

_MATRIX_DOUT_START is 0 in each case cause ULN is on the 1st SR.

NUMBER_OF_SRIO is defined to 12 cause I have 2 DIN + 1 DOUT on the core considered here (2x4 + 1x4 = 12)

I have big doubts about these constants.

I saw that: http://www.midibox.o...[]=din&s[]=dout

probably, I don't activate the correct pin...

if someone could point me in the right way, it would be very great and interesting :)

I attached my main.c and my main.h

main.c

main.h

main.c

main.h

Edited by protofuse
Link to comment
Share on other sites

the first SR  pin HEX numbers :

first  1  0  0×00  D0 / QA D7 / H

first  1  1  0×01  D1 / QB D6 / G

first  1  2  0×02  D2 / QC D5 / F

first  1  3  0×03  D3 / QD D4 / E

first  1  4  0×04  D4 / QE D3 / D

first  1  5  0×05  D5 / QF D2 / C

first  1  6  0×06  D6 / QG D1 / B

first  1  7  0×07  D7 / QH D0 / A

Link to comment
Share on other sites

ok janis, I saw that in the link I posted too.

but how can it help in my case? I mean: what should I change?

if I have 2 DIN + 1 DOUT, NUMBER_OF_SRIO = 12 ?

in the definition:

[tt]MIOS_DOUT_SRSet

void MIOS_DOUT_SRSet(unsigned char sr, unsigned char sr_value)

sets value of DOUT shift register

number of shift register in <sr>

value in <sr_value>[/tt]

when I do:

MIOS_DOUT_SRSet(_MATRIX_DOUT_START, 0);

MIOS_DOUT_PinSet1(row);

I guess I put 5V to the pin "row" of the _MATRIX_DOUT_START n-th shiftregister ?

I don't understand completely what MIOS_DOUT_SRSet() does...

Link to comment
Share on other sites

when I do:

MIOS_DOUT_SRSet(_MATRIX_DOUT_START, 0);

MIOS_DOUT_PinSet1(row);

I guess I put 5V to the pin "row" of the _MATRIX_DOUT_START n-th shiftregister ?

I don't understand completely what MIOS_DOUT_SRSet() does...

ok, it isn't right.

thanks nils for your few minutes :P

MIOS_DOUT_SRSet(_MATRIX_DOUT_START, 0); send 0 to all pin of the _MATRIX_DOUT_START n-th shiftregister ... in my case the first one

so

I cycle rows and I do:

MIOS_DOUT_SRSet(_MATRIX_DOUT_START, 0);

MIOS_DOUT_PinSet1(row);

it means that cyclicly, I put 5V to the pin 1 and nothing to the other, after that 5V to pin2 etc etc

so the row / ULN cycle seems to be correct..

where is my mistake . . . .?

in the code I attached, I commented all clearmatrix calls. the purpose is to light up leds to see if it works........

the matrix[][] structure is defined to make leds shining...

but, maybe, I missed something and ... all work and I don't know it causes the code switch off the led .... no... It cannot be that

Link to comment
Share on other sites

I'm not sure if this is the cause of your problem but I noticed your code reads;

Code:

/////////////////////////////////////////////////////////////////////////////
// This function is called by MIOS before the shift register are loaded
/////////////////////////////////////////////////////////////////////////////
void SR_Service_Prepare(void) __wparam
{
	// HELPED BY BUGFIGHT ON MIDIBOX - http://www.midibox.org/forum/index.php/topic,12786.0.html
	static unsigned char row;
	unsigned int x; 							//edit* just noticed, no reason for this to be static
	row = ++row & 0x07; 						//<-- here you were cycling 16 rows i think you meant 8, no?
												//this would have resulted in a 6.25% duty cycle (vs 12.5%).
												//note that the duomatrix uses a 25% duty cycle
	MIOS_DOUT_SRSet(_MATRIX_DOUT_START, 0);	//<-- hardwire bad, napster good.  define constants
											//    so you can move your matrix in the chain
	MIOS_DOUT_PinSet1(row);

	for (x = 0; x < 8; x++)
	{
		DisplayLED(x , matrix[row][x]);
	}
}
whereas if you remove the reference to 2nd DOUT mine would be;
void SR_Service_Prepare(void) __wparam
{
	// HELPED BY BUGFIGHT ON MIDIBOX - http://www.midibox.org/forum/index.php/topic,12786.0.html
	static unsigned char row;
	unsigned int x; 							//edit* just noticed, no reason for this to be static
	row = ++row & 0x07; 						//<-- here you were cycling 16 rows i think you meant 8, no?  
												//this would have resulted in a 6.25% duty cycle (vs 12.5%).  
												//note that the duomatrix uses a 25% duty cycle
	MIOS_DOUT_SRSet(_MATRIX_1_DOUT_START, 0);	//<-- hardwire bad, napster good.  define constants  so you can move your matrix in the chain

	MIOS_DOUT_PinSet1(row + (_MATRIX_1_DOUT_START * 8));
	for (x = 0; x < 8; x++)
	{
		DisplayLED(x + (_MATRIX_1_DOUT_START * 8), matrix_1[row][x]);
	}
}

So what is actually the problem you get - is it no lights at all? And how are you testing? When I tested mine first I made a function that was called after INIT - event though this is not ideal - it removes other possible problems like MIDI related or button/DIN/AIN related causes. I would reccomend updating your code to my example above, then set a whole row/column of LED's on and put a multimeter accross various pins to see where voltage is being directed. Ensure that voltages are getting to your DOUT and ULN's first. It could be that it is working but the wrong columns/pins are being sent voltage....just some ideas to try.

Sorry I cannot be much more help at the moment but try those things and let us know your results.

The LED matrix can be tricky to get working - you do need to understand a few things and I think I speak for most of us here when I saw it's pain we all share with you but you'll get it going soon.

Link to comment
Share on other sites

I made a lot of tests this morning (and still on this)

1) I remove all the din, ain hook in order to test only DOUT. => it doesn't work

2) 1) + I tested without ISR.. all the lighting stuff in INIT (I only light up 1 led by using 2 MIOS_DOUT_PinSet1(); instruction... it doesn't work

my LED are common cathode... sold as common cathode BUT I have a big doubt!

I searched a lot, find a lot of schematics.

cathode is the pin from which the current goes out ??? right?

if it is right, it means my matrix is driven like that: 3x74HC595 drive anode (current enter in LED from 595) and ULN2803 sink current from all cathode... Right??

I take a led alone...

I connected the longest pin (supposed to be the "common" cathode) to GND and one of other pin to 5V....... nothing happens! ! ! ! ! !

I reversed it: longest pin to 5V, another one to Gnd........ LIGHT UP!

My conclusion, I have a matrix of common anode ! ! ! ! ! !  !!  and I bought common cathode ... I guess there was a mistake in the shipment :-(

so 2 questions:

1) are my experiments exact ?

2) if they are, it means I have a common anode matrix, pretty, but common anode. Could I use it with the same kind of DOUT / ULN2803 ???

if I can't, no problem, I spent too much time to track this stupid problem, and I'm ready to buy again buttons + CC LED in order to redbuild the stuff.

Link to comment
Share on other sites

btw, on this : http://www.sparkfun.com/commerce/product_info.php?products_id=105

we can see 2 things confusing (for me, but for other I guess):

- if I read the text I read: common cathode.

- If I read the name: triple output LED RGB.

in my (little) head, I think the title should be ... triple input LED RGB

am I stupid? or just ... cursed (private joke for nils) ..?

Link to comment
Share on other sites

blm-module ?

http://svnmios.midibox.org/listing.php?repname=svn.mios&path=%2Ftrunk%2Fmodules%2Fblm%2F

I never used it, and it's for duo, not RGB LED's, and written in asm. From your code I guess your are not targeting mios32. There are two BLM-modules for mios32:

http://svnmios.midibox.org/listing.php?repname=svn.mios32&path=%2Ftrunk%2Fmodules%2Fblm%2F

http://svnmios.midibox.org/listing.php?repname=svn.mios32&path=%2Ftrunk%2Fmodules%2Fblm_x%2F

Maybe you could find some inspiration there, or port parts of the code for your application.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...