serial In/Out register OBJ (CD4021B,74HC595)
janb
Posts: 74
Hi,
2 objects in attached library allow read/write from/to 8-bit serial regiters with simple command:
··reg1:"54HC595"
· reg1.init(CS1,clk,ser) { assign pins }
· repeat
··· x:=... 'assign· lower·8 bits
··· reg1.write(x)
· reg2:"CD4021"··
· reg2.init(CS2,clk,ser) { assign pins }
· repeat·
··· x:=reg2.read
··· '...user action··
Both·registers may share CLK & 'ser' pins, only CS should be different.
There are also two main programs· testing·the above OBJs.
Make sure the assignemnt·of pins·is correct,· diagrams are provided.
Enjoy
Jan
2 objects in attached library allow read/write from/to 8-bit serial regiters with simple command:
··reg1:"54HC595"
· reg1.init(CS1,clk,ser) { assign pins }
· repeat
··· x:=... 'assign· lower·8 bits
··· reg1.write(x)
· reg2:"CD4021"··
· reg2.init(CS2,clk,ser) { assign pins }
· repeat·
··· x:=reg2.read
··· '...user action··
Both·registers may share CLK & 'ser' pins, only CS should be different.
There are also two main programs· testing·the above OBJs.
Make sure the assignemnt·of pins·is correct,· diagrams are provided.
Enjoy
Jan
Comments
One addition I would suggest... make the number of bits to move at a time a pram on the start sub...
this way, if you daisy chain more then one, you can account for it without needing to modify the original object...
Lastly, and anyone who knows better then I should correct me on this, I think the speed of the propeller might affect the object.
My thought being if the propeller is running at 80 Mhz, is that too fast for the chips to handle?
Beau knows this stuff like the back of his hand and I'm sure he'll set me right if I'm off base...
Anyway... These two little objects will sit in my collection, a nice thing to have. Thanks!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller + Hardware - extra bits for the bit bucket =· 1 Coffeeless KaosKidd
·
This shouldn't be a problem since the object is not written in assembly.
If it were in assembly you might see nyquist issues.. (picket fence effect)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
thanks for advice - I never thougth to gang to ports in chain.
I have now·2 methods:
pub write8(data) 'write one byte
pub write(data,nBits) '# of bits to write out
At the beginning I have slowed down clock ticks by adding waitcnt(1000+cnt), but later I removed·delays and the hardware still worked.
My application ( mobile robot) time constant is of 1 sec, so I was happy it works at few Hz,
probably one should use ASM if ~MHz I/O is needed
Thanks
Jan
still work