Help ! PICAXE 08M2 with a 74HC595 Shift Register, and Im a total noob.

robbert229

New Member
Hello, my name is John. I am currently new to the whole Microcontroller buisness, along with ICs in general. I have a pretty good idea about electronics, circuits, etc in general but I cant seem to find a proper code for an 08M2 to just turn one led on with my 74HC595 shift register, and then for the code to be broken down into somthing that I can understand, I thank anyone who helps me on this matter. I do have about 2 years of experience in C++, and a whole lot of experience in other languages, but with the shift registers, the main thing I see is people bit banging them in a knowledgeable way, I dont yet have that knowledge so I am looking to learn how.
Sincerely John.
 

westaust55

Moderator
Welcome to the Picaxe forum.

You could have a look at the project I posted here:
http://www.picaxeforum.co.uk/showthread.php?13687-3-digit-display-using-74HC595

This was using an earlier Picaxe chip and three shift registers in series/cascaded to drive 3 7-segment displays.
While it may be larger than your present goal you should find details useful therein.

The thread includes schematics and program examples for earlier 08M and larger 28/40X1 chips.
You mainly just need to remove hardware and code for the 2nd and 3rd '595 shift registers.
 
Last edited:

robbert229

New Member
Okay thanks. (Dont know why I didn't see that thread in the hours of searching for 74hc595 examples). Just to confirm from the example


LOOKUP digit, ($7D,$60,$5E,$7A,$63,$3B,$3F,$70,$7F,$7B), digout : This assigns data to the variable I am going to shift out.


mask = digout & $80 ; Mask out the MSB : I have no idea what this means by the way.

LOW sdata : turns off the serial line.

IF mask = 0 THEN skipMSB : Another part I don't understand

HIGH sdata : serial line high

skipMSB: pulsout sclk,1 : Pulses out the Serial Clock

digout = digout * 2 : I dont know what this does


And then all in all this is repeated for each bit. Could some one explain a bit on the different pieces of code and their meaning.
 

westaust55

Moderator
Yes, the Lookup command was used to get the 7-seg data combination for 0 to 9.

Because the data is shifted serially 1 bit at a time with the msb first, the code extracts that bit which is used to set the serial data line. We first clear (set to 0) the data line then test the msb. if the msb is 1 then we correspondingly set the serial data line to 1, then once the data line is set, clock out the bit and shift the data left (x2) ready for the next bit.

The serial shift out code is as per examples in the PICAXE manual2 -see the SHIFTOUT command.
 

robbert229

New Member
Thanks a lot for the help, this will definitively help with trying to control 216 LEDs with an 08M2 and some spare 74hc595s.
 

westaust55

Moderator
...I cant seem to find a proper code for an 08M2 to just turn one led on with my 74HC595 shift register, ......
this will definitively help with trying to control 216 LEDs with an 08M2 and some spare 74hc595s.
Wow! thats just a slight increment from one LED to 216 LED's :)
As you have an 08M2 which includes i2c capabilities, another option to consider may be an MCP23017 i2c IO expander based scheme, each chip providing two 8-bit ports for a total of 16 IO for one chip and i2c address.
Do a forum search on MCP23017. as an example see: http://www.picaxeforum.co.uk/showthread.php?12531-MCP23017-i2c-IO-exapander-data
 

robbert229

New Member
Wow! thats just a slight increment from one LED to 216 LED's :)
The one led part was about the coding side of the 74hc595, I just wanted to know the principle about working with shift registers, because if I learn the principle then I can use it for other similar purposes.
 
Top