Picaxe 08M, 4017 decade counter problem

rctrainer

New Member
hi, i am doing a GCSE project for DT and i am making an LED flasher sequence using a Picaxe 08M and a 4017 decade counter for the 10 LEDs i am using.
 
Last edited:

westaust55

Moderator
Rctrainer,

Firstly, welcome to the PICAXE forum.

Since your yellow LED is coming on (pin is going high) then it seems most likely the problem is in the program.

Have you tried your program in the Programming Editor simulator?
Do you have the same problem there?

As eclectic has indicated, please upload your program.
Also upload your schematic.
 

westaust55

Moderator
Deleted: misread the second last sentence in post 1. :eek:


Also I suggest that you increase the resistance value of the resistors to the LED's to around 330 Ohms. They should still be bright enough.
 
Last edited:

Rickharris

Senior Member
Starting with the hardware side of things,

Try modify the wiring from the PICAXE chip leg 5 which goes to the same side of R6 (150 Ohm) as the 4017 chip.
Instead go from the PICAXE chip leg 5 through another resistor and direct to the LED D6. See attached diagram.

As wired at the moment, PICAXE output 2 and the 4017 output are wired together directly. If the 4017 is low, even with the PICAE output high the LED will not light and there is every chance you can cause damage to the PICAXE chip since it will be like a short from PICAXE to 4017 under these conditions.

Also I suggest that you increase the resistance value of the resistors to the LED's to around 330 Ohms. They should still be bright enough.
I think from the programme, leg 5 is used as an input to detect if LED 5 is on - it isn't detecting this condition correctly which is his problem.
 

kevrus

New Member
Just tried the code in the simulator and that works fine for me. Havn't got time to dig out a 4017 to breadboard it, but have you fitted a 'pull down' resistor on pin2 as I didn't see one on your schematic, (may not be necessary as the 4017 may act as a 'pull down' when O/P is low), and as Westaust says, increase the LEDs series resistor value. If you are using high intensity LEDs, you could even go to 1K while still keeping good illumination.
 
Last edited:

westaust55

Moderator
PICAXE 08M input 2 (physical leg 5) is a Schmitt Trigger Input.

According to the datasheet,

Input 2 ==> GP2 = ST CMOS GPIO I/O
VIL = Input Low Voltage (with TTL buffer)
min=Vss to 0.8 Volts


and


Input 3 ==> GP3 = TTL — GPIO input

VIL = Input Low Voltage (with Schmitt Trigger buffer)
min=Vss to max=0.2 x VDD Volts


So at 5V x 0.2 = 1 Volt for Input 2 (leg 5)


a 4017 output will be a max of 0.05V in the low state.

So there should not be a problem.


Measure the exact voltage you are getting at PICAXE phgysical leg 5 when the LED is off.
 
Last edited:

kevrus

New Member
Initial glance at your code, you are stepping b11 through 11 steps, which are 0 to 10, try changing from b11=0 to b11=1 in 'start' and 'resetcount'to step through 1 to 10...works every time when b11=5 in simulator.
 
Last edited:

kevrus

New Member
If I understand correctly, you want the yellow LED to be 'b11=5' on each level, and not b11=5 on level1, b11=4 on l.evel2 etc. Thats how it works for me in the sim when b11 starts from 1 instead of 0.
 

Rickharris

Senior Member
thats great will give it a try out on monday when i go back to school and hopefully we'll get it sorted out. Thanks, Ryan
I see what you mean. the code below will reset the 4017 after showing the level and reset the counter so they both start at 1 on changing levels.

it works when I simulate it.

I have commented this. you should explain what your peoblem was and where you got your help in your evaluation. No marks lost.

Code:
b0=0
b11=1
w4=1000
Start:
Goto onsound

onsound:
Sound 4,(50,100)
Sound 4,(100,100)
Sound 4,(50,100)
goto mainprogram

mainprogram:
high 1
pause w4
low 1
b11=b11+1
if pin3=1 then hit
if b11=10 then resetcount
goto mainprogram

hit:
if b11=5 then winsound
goto nothitsound
return

nothitsound:
sound 4, (50,200)
goto start

resetcount:
b11=0
goto mainprogram


winsound:

sound 4,(126,100)
pause 100
goto Level

Level:
b0=b0+1 'level counter
w4=w4-95
High 0
Pause 25
Low 0 'resets 4017 to the beginning
For b1=0 to b0
High 1
Pause 25
Low 1
Next b1 'counter to level
Pause 5000
high 0   'after showing level sets 4017 back to 0 so LEDs and count are the same
pause 25
low 0
b11=1   'starts recounting from 1 after changing level
Goto mainprogram


finalsound:
sound 4, (70,100)
end
 

eclectic

Moderator
FWIW. I'm using the circuit from post #4,
with a real 4017

Program is a severely cut down version
of Ryan's original code.
Code:
w4=1000

mainprogram:
High 1 
pause w4 
Low 1
if pin3 = 1 and pin2 = 1 then goto check

Goto mainprogram

check:
for b10=1 to 5
sound 4,(126,10)
pause 100
next b10
GOSUB flashybits ;delete afterwards

goto mainprogram

flashybits:  ;Delete or keep?
for b0 = 1 to 100
high 1 : pause 50 : low 1
next
return
Not perfect, but, it might help.
e
 

lbenson

Senior Member
Probably the best way to track down a problem like this is to copy the code into the simulater, click beside the first statement to set a breakpoint, click simulate, and then single-step through the code (with "{" in the simulation window). Watch how your variable values change as you step through and click the pin3 button on and off at various points.

But ... is what you want to do just setting your level counter, b0, to 0 in resetcount?

Notice that you have a "return" after the "hit" label, but you enter that with an implied "goto", not a gosub. This will eventually produce a stack error and the program will fail.
 
Last edited:

lbenson

Senior Member
I believe so, but you can also put a label at the very beginning of your program and jump to that.

The simulator is included with the program editor. The "Simulate" button is next to the "Program" button. Even if you have no PICAXE, you can download the program editor and run your program in the simulator. It's a good idea to do this--you can work through a lot of bugs in a hurry.
 

rctrainer

New Member
hi again, i think i know how to get round the level problem, final final problem is playing a tune on the 08m. i have the piezo connected to pin4 of the picaxe but when i play the tune it is hardly audible. help please???
 

rctrainer

New Member
Do you have a link to the piezo?
Do you have any resistors/how have you connected it?
What voltage are you running off?

A
hi, the piezo is connected straight from pin4 of the picaxe and then to ground, i am using 3 AA batteries (4.5v), and there is no resistor connected?, do you think it may be the tune i am trying to play as it is an external tune i have downloaded off the picaxe software site.
 

Rickharris

Senior Member
hi, the piezo is connected straight from pin4 of the picaxe and then to ground, i am using 3 AA batteries (4.5v), and there is no resistor connected?, do you think it may be the tune i am trying to play as it is an external tune i have downloaded off the picaxe software site.
Some sounders are louder than others. An amplifier in series with the picaxe out put is really the answer or replace the sounder with a small loudspeaker and capacitor as in the interface manual - BUt you may not have room in your project caase for this.

If not don't worry just write it up in the evaluation and suggest a solution with a couple of sketches for extra marks!!! :)
 
Top