Tech Talk with Gus 028 - Bit-Banging Part 2

In this episode, we continue our talk about the concept of Bit-Banging, how it works and why it is used.

2 Likes

Code Samples:

As posted on YouTube :

in WriteLED you only count to 12…

for (int count = 0; count < 12; count++) {
Send16bit( leds[count]);
}

and in a later block from 12 to 24.

Why dont you send them all at once?

@ Beelzebub - correct 12 LEDs. Where is the error?

@ Gus -
hard to tell without the specs, but for me it seems unlogical to send the command twice and then send another set of leds. have you tried to just send 24 leds sequentially in one run?

another idea is that the command for the second set of led’s is another one. Some bit is switched, to indicate another address to push the values to (the second chip)

PS: is didn’t see the second loop at first. introduction of some helper methods could make the code a bit more readable :slight_smile:
Edit: and viewing it in VS hinted me at the urls on top of the file … dang!

@ Gus -
Ok, after checking the full specs here: http://www.led-studien.de/datasheet/MY9221.pdf i came accross some points in your code.
Im not sure why you have an thread sleep 1 after sending the first command, and the empty nibble seems to make no sense (its sending the last bit of the command 4 times?) also there was an additional bit after the first set of led’s.

second is, that the leds that are sent first, will be shifted through to the second controller when more data is added. so the second led-set should be sent first.

i combined the changes and pushed it to my fork:
https://gist.github.com/Vittel/59ae3236d708b793f036f3b1d7901e87

there is no way for me to try this, but i hope my guesses are getting better :slight_smile:

This is clever. Putting a bounty on an issue like that to spark user interaction. Good job GHI.

Something I didn’t understand about the led driver. It needs 4 pulses on the Input to realize that you want to latch? If so, and the devices are daisy chained, then how is the data line on the first chip being toggled, as to indicate to the second chip when to latch?

I say, put put a DS1054Z on the device to see what data is actually being received.

@ cyberh0me - it’s in the diagrams. What is sent first, will be on the output of the first chip, after the first one is filled.

but anyway; i think, i got the overall word order wrong, so i reverted that change.

Haven’t read such specs for some years now. Maybe i got it totally wrong :wink: