Is it possible? 7-seg LED MO8 4511

newbie2cnc

New Member
Is it possible to get a 7 segment led to count 0-9 with a M08 and a 4511?
Here is the code out of the book

Code:
main: for b1 = 0 to 9 ‘ Set up a for...next loop using variable b1
let pins=b1 ‘ Output b1 onto the four data lines
pause 1000 ‘ Pause 1 second
next b1 ‘ Next
goto main ‘ Loop back to start
I can only get 1 and 0

Thanks
 

westaust55

Moderator
Firstly, welcome to the PICAXE forum.


Okay see it comes from PICAXE Manual 3 page 20.
Which PICAXE chip are you using?


This for example will not work correctly as per the diagram in the manual with the 08M and you will only get 0 and 1.
With other PICAXE chips it works as per the manual

When the diagram indicates pin, confirm that you are using the pin designations as in OUT0, OUT1, OUT2 and OUT3. See PICAXE Manual 1 page 8.

The pin numbers are not the physical IC legs. This can be a bit confusing which is why most refer to the physical pins of the IC as "legs".

Can you upload a schematic (wiring) diagram of your circuit and/or a clear photo so we can see the wiring, and specifically to see where each wire end goes, to better help you get your project working.


If you are using the 08M, move from pin 3 to pin 4 then this should work

Code:
main: for b1 = 0 to 9 ‘ Set up a for...next loop using variable b1
let dirs = %000010111  ; [B][COLOR="Red"]required to set up 08M pins 1, 2 and 4 as outputs[/COLOR][/B]. pin 0 auto defaults to an output.
b2 = b1
If b1 > 7 THEN
  b2 = b2 AND 7 + 16
ENDIF
let pins=b2 ‘ Output b1 onto the four data lines
pause 1000 ‘ Pause 1 second
next b1 ‘ Next
goto main ‘ Loop back to start

EDIT: it is a good idea to let others know more about your hardware as well as software. Then for example, I would not be guessing that you might have an 08M. Can be good to advise which version of the Programming Editor you are using and maybe your experience level so we know how to pitch the answers.
 
Last edited:

newbie2cnc

New Member
That works great. Thanks you very much. I am using a 08M I just wrote it backwards in the title. Could you please explain to me how that is changing the pin 3 to pin 4? Please excuse my question but I am trying to learn.
 

westaust55

Moderator
That works great. Thanks you very much. I am using a 08M I just wrote it backwards in the title. :rolleyes:

Could you please explain to me how that is changing the pin 3 to pin 4? Please excuse my question but I am trying to learn.
Andrew has reiterated the hardware side. Namely pin 3 on an 08M can only ever be an input so you must use another pin for the fourth output.

ON the software side, within the program bit 3 (4th from the right/ least significant bit) equates to pin 3 and in binary a 1 at bit 3 of variable b1 represents the value 8. This pin will be high when the value of variable b1 is 8 or 9.

If these numbers and bits are confusing then try looking at my number conversion chart attached in this thread (will take a few seconds to get to the right post within the thread):
http://www.picaxeforum.co.uk/showthread.php?p=91966

What the program to change the pin number is at the lines
If b1 > 7 THEN
b2 = b2 AND 7 + 16
ENDIF​
If the counter (b1) and thus also b2 is greater then 7, that is 8 or 9.

I used b2 as the value to create the output signals since the counter variable b1 cannot be chnanged without affected the program operation.

first AND with 7 which masks of bit 3 then we add 16 which turns on bit 4.
Maybe a little less obvious but the line
b2 = b2 AND 7 + 16​
could be replaced with a simpler
b2 = b2 +8​
which will give the same result.

Hope this explanation helps.
 
Last edited:

newbie2cnc

New Member
Getting closer to understanding I still have some confusion. I have read all of the manuals and have made several boards to do some simple stuff (flashing LEDs, sound and so on) using code from the manuals. Just trying to get a grip and do some research on how it all works. I just need to read and read again until I grasp a little more. I might have a few more questions later.
Thanks for your help
 

westaust55

Moderator
Never a problem to help those who try and help themselves.

Besides the reading of the manuals, some googling may help.
With repect to the above program, try a search for Boolean or Boolean Logic.
Also AND, OR, NOR, XOR, etc. There are usually table provided that show how these funcitons work.

The aim is to have fun, experiment and learn.
 

Mycroft2152

Senior Member
That works great. Thanks you very much. I am using a 08M I just wrote it backwards in the title. Could you please explain to me how that is changing the pin 3 to pin 4? Please excuse my question but I am trying to learn.
As has been said, pin3 in an input only pin and you need a work around to use pin 0, 1,2, 4.

You might want to consider using a 14M or 20M instead. With either of these you will have 4 outputs in a row and the logic is much easier.

Another idea is to omit the 4511 and just drive the display directly from tne 14M or 20M outputs.

I originally used a 555-4510-4511 for a model rocket count down launcher a long time ago. It is so much easier today with a PICAXE

TANSTAAFL!

Myc Holmes
 
Top