Generating Serial Output with set Period & Duty Cycle for RGB LED's
randonrose
Posts: 5
Hi All,
I am new to parallax.com and spin. I am using a Gadget Gangster Propeller development board and am trying to interface a RGB LED strip controlled by a TM1803 control circuit to it.
The TM1803 uses a 1-wire interface to communicate with the propeller. From the TM1803's data sheet, I need to create a series of pulses to represent a High, Low and Reset signal.
To represent a High signal the TM1803 expects to see a signal with a period of 2.04uS and a duty cycle of 66%
To represent a Low signal the TM1803 expects to see a signal with a period of 2.04uS and a duty cycle of 33%
To represent a Reset signal the TM1803 expects to see a Low for 24uS
How I understand the TM1803 works is that it waits for 24 bits (8 bits per LED) consisting of the High and Low signals followed by the Reset signal at which point the output is set to the LED's.
I have been able to create the timing need via a PWM object but I dont believe this is the correct way of doing it.
Ideally I would like a function that I could send a 24 bit value to that would create the correct timing need for the controller chip.
Any help and advice would be very much appreciated!
Attached is the data sheet for the TM1803
I am new to parallax.com and spin. I am using a Gadget Gangster Propeller development board and am trying to interface a RGB LED strip controlled by a TM1803 control circuit to it.
The TM1803 uses a 1-wire interface to communicate with the propeller. From the TM1803's data sheet, I need to create a series of pulses to represent a High, Low and Reset signal.
To represent a High signal the TM1803 expects to see a signal with a period of 2.04uS and a duty cycle of 66%
To represent a Low signal the TM1803 expects to see a signal with a period of 2.04uS and a duty cycle of 33%
To represent a Reset signal the TM1803 expects to see a Low for 24uS
How I understand the TM1803 works is that it waits for 24 bits (8 bits per LED) consisting of the High and Low signals followed by the Reset signal at which point the output is set to the LED's.
I have been able to create the timing need via a PWM object but I dont believe this is the correct way of doing it.
Ideally I would like a function that I could send a 24 bit value to that would create the correct timing need for the controller chip.
Any help and advice would be very much appreciated!
Attached is the data sheet for the TM1803
pdf
214K
Comments
Hi randonrose
You will soon be given excellent advice from th e code gurus here on the Parallax forums. In the meantime, Yes you should have no problem creating a 24-bit serial stream with the periods specified. I am still learning SPIN myself so can't provide any direct help. Have you searched the OBEX yet? There may be a suitable object (for some other device/purpose) that can be adapted to your needs.
As an aside, I have tried to have a look around the Titanmec website; painfully slow and some interesting chips are not documented yet.
Cheers
Thank you JonnyMac, the code works great with the chip and this is a very helpful starting point!
That's good news -- thanks for letting me know.
BTW, I just looked at that code again and found an error in the set_color method; this shift value should be 8, not 1. Here's the correction
Thanks for the update JonnyMac, that function works fine now as well. However the only problem I am running into now is that only 3 LED's light on the strip. from what I am able to make out from your code the following section setups the timing:
The data sheet states that once the first 24 bits are received it will hold the last value until it receives a reset code, which is a low signal for 24 uS. I am unsure about how this needs to be implemented. Dose another timing loop need to be created like the ones above, that a function could call to "reset" the chip and shiftout the data?
Thought I would update this tread to make you aware I have found out I explained how this chip operates incorrectly and that your code worked fine from the beginning based off of what I told you.
Turns out, this chip looks for a constant stream of bits and once it receives 24-bits, it pushes them out into the next chip. I was able to get this to work by editing the last line of the PASM code so that it avoids the clearcmd routine:
At this point I am trying to figure out how to write a Reset Function that can be called to send the reset low pulse for 24uS so that a new color can be updated.
Thanks again for all your help!
Randon
Johnny Mac would you have any further suggestions on why the above commented code allowed all the LED's to light up? Also I seem to be unable to update to a new color using the above commented code.