Memory full error - using an 08

9

911

Guest
Hi team,

Well Ive finally got round to playing with PIC's after getting pressure from Master BeanieBots - yes I'm lucky enough to work with him.

Anyhow, just for fun I'm making a A3 size LED sign to go in our games room. After talking with BenieBots, he recommended using PIC's to drive the LED circuits. This has given me flexibility to write and rewrite LED light flows ( I love these things , I wish they had them 30 years ago !).

Anyhow, the sign is split in to three sections. Two pictures and the third is words.

The first picture ( the easy one is running on a 08 that I had spare from a previous project. The only problem i have is space for coding.

The LED flow is very basic as well as the circuit.

Firstly the circuit, one out put is driven as a PWM connected to a transistor which in turn will fade up and down some LED's

Next we have three outputs driving a 74LS138 , which in turn drive 8 clusters of LED's ( through drivers of course).

Upon power up, the flow is

PWM up
PWM down
PWM up
Count to 8 , 5 times
return and start again ( I hope that makes sense)

Anyhow, running the code below ( which I'm not good at at all !) , I need to reduce so I can add more effects.

question, is it possible, is there some hidden space in the PIC I can use or combine the code in any way.

Many thanks in advance for your support.

Ade...


Main:
'low 0
'low 1
'low 2
gosub up
high 4
pause 1000
gosub down
low 4
pause 1000
gosub up
high 4
pause 1000
gosub BCD
pause 1000
gosub down
pause 1000
goto main


Up:
inc b5
pwm 4,b5,1
if b5 =255 then return
end if
goto up

Down:
dec b5
pwm 4,b5,1
if b5 =0 then return
end if
goto down

' Binary to Decimal convertor 74LS138

BCD:
pause 200
for b1 = 0 to 5 'Cycle 5 times
high 0 '1
low 1 '2
low 2 '4
' total = 1
gosub delay
low 0 '1
high 1 '2
' total = 2
gosub delay
high 0 '1
' total = 3
gosub delay
low 0 '1
low 1 '2
high 2 '4
' total = 4
gosub delay
high 0 '1
' total = 5
gosub delay
high 2 '4
low 0 '1
high 1 '2
' total = 6
gosub delay
high 0 '1
' total = 7
gosub delay
next b1
return

delay:
pause 300
return
 

gbrusseau

Senior Member
You can eek out a few more bytes as follows

Up:
do
inc b5
pwm 4,b5,1
loop while B5<255
return

Down:
do
dec b5
pwm 4,b5,1
loop while B5>0
return
 
Last edited:

gbrusseau

Senior Member
A few more as follows

' Binary to Decimal convertor 74LS138

BCD:
pause 200
for b1 = 0 to 5 'Cycle 5 times
high 0 '1
low 1 '2
low 2 '4
' total = 1
pause 300
low 0 '1
high 1 '2
' total = 2
pause 300
high 0 '1
' total = 3
pause 300
low 0 '1
low 1 '2
high 2 '4
' total = 4
pause 300
high 0 '1
' total = 5
pause 300
high 2 '4
low 0 '1
high 1 '2
' total = 6
pause 300
high 0 '1
' total = 7
pause 300
next b1
return
 

BeanieBots

Moderator
Splash out and treat yourself to an 08M:p

The sequence is a simple count, so probably something you can do with pins=var + inc within a for/next loop rather than setting each pin individually.
 
Last edited:

gbrusseau

Senior Member
Good catch BeanieBot. I didn't notice the I/O pins are counting binary.

So the BCD subroutine can be as follows

BCD:
for B1=0 to 5
for B0=1 to 7
let pins=B0
pause 300
next
next
return
 
Last edited:

moxhamj

New Member
You are already hooked on picaxe if you have filled up the memory! The beauty of the picaxe system is that when you run out of memory or pins you just upgrade to the next one in the series. In this case, an 08M with twice the memory for only a few cents more. Don't worry about the 08 you have - you will find a use for it. The 18X has even more memory again.

Something just struck me. You say you work with BeanieBots, and he has replied to this post. Are you guys communicating from one cubicle to the next via this forum?!
 
Last edited:
9

911

Guest
Different departments, someone gets his ear bent if we talk about PIC’s
 
9

911

Guest
Thank you all for your great support and idea's.

I'm having issues though with the cut down version of the Binary counter. I understand how it works but only couple of outputs seem to be working (the nit goes in to some strange uncontrollable light patten on two LED's). Probing the PIC with a logic probe, output PIN 6/7 of the chip seem to be floating.

Any idea's ?

The old version still works ...
 

gbrusseau

Senior Member
The entire code is

Main:
low 0
low 1
low 2
gosub up
high 4
pause 1000
gosub down
low 4
pause 1000
gosub up
high 4
pause 1000
gosub BCD
pause 1000
gosub down
pause 1000
goto main

Up:
do
inc b5
pwm 4,b5,1
loop while B5<255
return

Down:
do
dec b5
pwm 4,b5,1
loop while B5>0
return

BCD:
pause 200
for B1=0 to 5
for B0=1 to 7
let pins=B0
pause 300
next
next
return
 
9

911

Guest
Hello gbrusseau,

Thank you for this code, it seems to work except for one issue.

My PWM lights go out when you cycle the code. Talking with BeanieBots today , he did mention that this would happen.

I need the PWM lights ( Pin 4 ) to stay high when I count from 1 > 7

Any idea's ??
- Sorry
 

gbrusseau

Senior Member
Yes, the PWM command provides a burst of pulses with the duty and cycle specified in the command. After the command is executed, pin 4 reverts to an input pin.

BCD:
high 4 Sets pin 4 as an output port
pause 200
for B1=0 to 5
for B0=17 to 24 This should keep pin 4 high
let pins=B0
pause 300
next
next
return
 
Last edited:
9

911

Guest
That seems to have fixed it, can you please expalin how it works, I mean;

for B0=17 to 24 'This should keep pin 4 high

Many thanks.

A very happey person...
 

Technical

Technical Support
Staff member
Think in binary:

17 = 10001
18 = 10010
19 = 10011
20 = 10100
21 = 10101
22 = 10110
23 = 10111
24 = 11000

so whilst pins 0-3 vary, 4 is always on
 
9

911

Guest
O, now I understand. That’s clever Luke - the force is strong !

Thanks gang, back soon after building the next phase I’m sure ....
 
9

911

Guest
LED Sign

Well after getting time to finish my LED sign off its finally running.

I needed to replace the 08 with a 28X , so now I have three circuits running , all independent on 28X chips.

You can see it on U tube here http://uk.youtube.com/watch?v=L5IAAqDpUMg

Before you say anything, yes I could have made other pattens but I'm sure that will come in the following months.

Thanks again for all the support I got.
 
Top