Sending data to a LED array

RickAlty

Senior Member
Hello again. I want to display numbers from the picaxe onto a bank of five 7-seg LED digits. I have the LEDs wired to an M5451 driver chip, which requires a clock signal and a data pulse signal. I wrote this code...

<BLOCKQUOTE><font size=1 face=arial>quote:<hr height=1 noshade>
main:

symbol clock=1
symbol data_out = 2
pause 500
high clock
pause 1
low clock
pause 1
for b0 = 1 to 36
high clock
high data_out
pause 1
low data_out
low clock
pause 1
next b0
pause 500
goto main
[/QUOTE]

Which I think should light all 7 segments of all five digits, but what actually happens is that the segments flash on and off apparently randomly.

Here.... http://www.ortodoxism.ro/datasheets2/e/0zqj6og5wcoq8y1zyxt7r79056py.pdf is a link to the datasheet for the driver chip, that shows the data sequence the chip needs.

I've tried changing the value of the &quot;b0 = 1 to 36&quot; to 35 and 37 in case it needs a gap bit or I'm misreading it, but it makes no difference.

Can anyone tell me what I'm doing wrong ?

Thanks in advance,
Richard <hr height=1 noshade></BLOCKQUOTE></font><font face='Verdana, Arial, Helvetica' size=2>
 

c930174

New Member
Your code doesn't match the spec. The clock must toggle Lo-Hi and Hi-Lo <i>while the data is stable </i> . Your code has the data line go low before the clock goes low.

There is a lot of superfluous code. Definitions should be before the executable code.

Try the following:
<code><pre><font size=2 face='Courier'>

symbol clock=1
symbol data_out = 2
main:
high data_out
for b0 = 1 to 36
high clock
pause 1
low clock
pause 1
next b0
alldone:goto alldone
</font></pre></code>
The code just fills the shift register up with 1's. Once this works, then you can start he fancy stuff.
 

RickAlty

Senior Member
Thanks, it looks like I was misreading the data spec then? To send, say, three segments as on-off-on, it would be data high, clock high, clock low, data low, clock high, clock low, data high, clock high, clock low, data low ?

I had it the other way round.

I'll try it when I get home tonight, thanks for the advice.

Richard
 

BeanieBots

Moderator
Sounds about right.
Or thinking about another way.
Set up the data on the data pin and then &quot;clock&quot; it in, with a pulse on the clock pin.
 

RickAlty

Senior Member
Hi Beanie... I thought about that way, maybe using a 555 timer to send the clock pulse, but then I have the problem of synching the clock pulses with the data ones.

Also, once this is working, the plan is to run six of these 5-digit displays from one PICAXE - I'll only need seven outputs to display a total of 30 digits. I can send the same clock pulse to all 5 M5451 chips, and only data pulse the ones that need to be changed.
Since that's all I need for the job, I thought, &quot;Why complicate it?&quot; :)

Richard
 

eclectic

Moderator
Richard.
This is VERY rough, but, amalgamating
the above postings,

<code><pre><font size=2 face='Courier'>
'Pieces of Eight?

'Assuming an 18 series chip

'Data outlets on output 18 pins 0 - 5
'connected to input on 5451

'Clock output from output pin 7
'connected to &quot;Clock input&quot; on ALL 5451 chips.

'which leave one spare output on 18 pin 6



symbol clock = 7

symbol array = b0

symbol segment = b1

for array = 0 to 5 ' pins 0 - 5 connected to individual 5451 data input pins

for segment = 1 to 36

high array ' sends a &quot;1&quot;

pulsout clock, 1 ' Equivalent to High 7. then LOW 7. But faster?

next

next
</font></pre></code>

e.












Edited by - eclectic on 09/08/2006 08:36:11
 

RickAlty

Senior Member
Thanks for all the hints... can't wait to ditch work and get home to try it :)

From a code / speed aspect, is there much difference between &quot;high 1, low 1&quot; and &quot;pulseout 1&quot; ?

Thanks,
Richard
 

inglewoodpete

Senior Member
There are a couple of considerations. One is memory (programme space) consideration and the other is code clarity. Timing is not really a problem unless it is critical, not the case here.

While writing the code you will know what you are doing. If you're like many of us, you may want to tweek the code in a few weeks/months. Its much easier to understand what pulseout is doing than high/pause/low.

Finally, on programme space usage, compare the two code arrangements: it will only take you 5 or 10 minutes. The 'compiler', or just the syntax checker, will tell you you many bytes each configuration takes up.
 

RickAlty

Senior Member
OK, I'm just as confused....
This :
main:
high data_out
for b0 = 1 to 36
pulsout clock, 1
pause 1
next b0

Sets all the segments to on, as I'd expect it to from reading the above hints.

But then I'd expect this :

main:
high data_out
pulsout clock, 1
low data_out
pause 1
for b0 = 1 to 36
pulsout clock, 1
pause 1
next b0

to set them all to off.... and it doesn't.

In fact, any attempt to toggle the data_out line after initially setting it high results in random patterns of segments.

Anyone got any more ideas?

(I'm only using an 08 at the moment, btw - my order I placed last month for 18X's from the US distributor has not yet been filled :-(

Richard
 

inglewoodpete

Senior Member
Rick,
Don't discount the 08M - its a capable little beast. It just has a few less pins and a bit less programme space.

I've a read of the datasheet and your code looks for setting all segments to 'on'. For the 'all off' code, you need a '1' <i>followed by 35 '0's </i> . Not a problem in itself but if your looping through the whole programme repeatedly, the the Start pulse would be out-of-sync on each progressive cycle. Try changing the loop counter to 35.

Also, you may want to slow the whole thing down while getting the basics right. I can't see why you couldn't slow it down to 1 or 2 seconds per loop. You'll then be able to see each bit with a meter, led+resistor or logic probe.
 

RickAlty

Senior Member
SUCCESS !!

Thanks for all the help everyone.

This code turns on four segments in each digit for a second, turns them all off for a second, turns all the segments on for a second, then turns them all off for a second, over and over.

Thanks again.

symbol clock=1
symbol data_out=2

main:

high data_out
high clock
low clock
low data_out

for b0=1 to 5
high data_out
pulsout clock,1
low data_out
'high data_out DONT LIGHT THIS SEGMENT
pulsout clock,1
'low data_out
high data_out
pulsout clock,1
low data_out
'high data_out DONT LIGHT THIS SEGMENT
pulsout clock,1
'low data_out
high data_out
pulsout clock,1
low data_out
'high data_out DONT LIGHT THIS SEGMENT
pulsout clock,1
'low data_out
high data_out
pulsout clock,1
low data_out

next b0

low data_out
pause 1000

high data_out
high clock
low clock
low data_out

for b0=1 to 35
pulsout clock,1
next b0

pause 1000

high data_out
high clock
low clock
low data_out

for b0=1 to 35
high data_out
pulsout clock,1
low data_out
next b0

low data_out
pause 1000

high data_out
high clock
low clock
low data_out

for b0=1 to 35
pulsout clock,1
next b0

pause 1000
goto main
 
Top