Serial code help needed

tomo99

New Member
Hi Forgive me first time poster.Have played with the Picaxes for a while but am no expert, or even talented amateur.I'm still enjoying making LEDs flash.
The Project is to make multiple rgb banks of LED fade and change colour.
For example if i had ten banks of LEDs changing from red to blue and the banks were at slightly different start colours,
not only would the colour change but would also seem to wash along, or up, or what ever orientation the banks were.

Now before you all sigh and say not the RGB thing again let me explain.

I have built single unit involving one 08m running three 08ms with PWM, then wrote code for a 40x2 to control 30 08m's but the cost of 30 became to costly.
Have played with using HPWM and PWM on same chip, but did not like the effect,also have tried multiplexing but not bright enough.

Now the problem, discovered http://picprojects.org.uk/projects/simplergb/index.htm
Just what i need mayby so built a programmer and burnt some chips,
but i would like to control vie a picaxe as i understand Basic slightly more than the voodoo of assembly.
But i am stumped on the code to send, any help or just an example of a string to send.
Do not not want code writing just a little explanation.
PS its not homework

Thanks Gav
 

jodicalhon

New Member
Hi Gav, I'm possibly even more confused than you are, but I had a quick peek at your link.

At first glance it seems as simple as sending 4 data bytes and a checksum to the LED driver, but lower down the page the SequenceData.inc file contains info for fade rate and hold time, and it's not clear (to me at least, as my assembly's not up to it) how this is incorporated into the pwm data for each LED that is sent in the 5 frame packet.

Hopefully others can do better than I have. :(
 

tomo99

New Member
Further study of the assembly code gives more clues
I need to be able to send in this format

Asynchronous serial data is received on RxD input at 2400 bits per second
; Frames use 1 start, 8 data , 1 stop and no parity
; The software is written to receive a fixed length packet of 5 bytes
; The first frame is a start-of-packet delimiter, always 0x81
; The last byte is a checksum of the values in the previous four frames
; The checksum is computed by the sender to make validation as fast as possible for the receiver.
; When the received checksum is added to the sum of all four preceeding frames, the result should
; be zero. If not the packet is discarded.
;
; Packet format. 5 frames
; 0: start = 0x81 start delimiter, always 0x81
; 1: red = 0x00-0xFF RED PWM value
; 2: green = 0x00-0xFF GREEN PWM value
; 3: blue = 0x00-0xFF BLUE PWM value
; 4: checksum = 2's complement of sum [frames 0::3]


Have tried all sorts of code to output in this format ,but my ignorance shines through.
Any help with code appreiciated
Gav
 

hippy

Ex-Staff (retired)
If I understand correctly ... You have one or more of these modules, and they are expecting commands in the form of the protocol described, and you'd like to control such a module from a PICAXE ?

That seems to be a simple case of building up the desired packet and calculating the checksum ...

b0 = $81 ' Start delimiter
b1 = $FF ' Red level
b2 = $00 ' Green level
b3 = $00 ' Blue Level
b4 = - b0 - b1 - b2 - b3 ' Get the two's complement checksum
SerOut txPin, N2400, ( b0, b1, b2, b3, b4 )

You may have to use a T2400 baud rate which would be ...

High txPin
Pause 10
SerOut txPin, T2400, ( b0, b1, b2, b3, b4 )
 
Top