Daisy Chaining Shiftbrites

Support for Pololu products that are not covered by one of the above categories.

Daisy Chaining Shiftbrites

Postby aron42486 on Fri Jul 30, 2010 1:05 pm

Hello,

I am new to the Maestro's coding lanuage and I just need help on code for 2 daisy chained shiftbrites. I read the resources attached to the shiftbrites page but I do not know to translate arduino code into maestro code, and I cannot find any example codes for a daisychained setup. For the most part both shiftbrites will be displaying the same color, and maybe flashing between 2 different colors.

If someone could provide me with an example code or let me know where I can go to learn how to do the daisy chain, I would appreciate it. Thank you.
aron42486
 
Posts: 4
Joined: Fri Jul 30, 2010 12:49 pm

Re: Daisy Chaining Shiftbrites

Postby paul on Fri Jul 30, 2010 1:21 pm

Hello,

Have you seen our example Maestro program (at the end of this page)? The following lines in that program shift out three 10-bit values plus the two command bits required for the ShiftBrite, for a total of 32 bits:

Code: Select all
  0 send_bit # this bit does not matter
  0 send_bit # the "address" bit - 0 means a color command
  swap rot rot
  send_10_bit_value
  send_10_bit_value
  send_10_bit_value


If you want to send two sets of RGB colors to two ShiftBrites, you should be able to just duplicate this block of code. That will cause it to shift out two sets of color commands instead of one, for a total of 64 bits. Then, when you call the rgb function, you will need to give it two sets of RGB values. For example:

Code: Select all
1023 511 255 1023 511 255 rgb 


will set the two to the same color. Notice that the latch pin is only toggled once if you do it this way - otherwise you would briefly see the colors appear on the wrong ShfitBrites before they get shifted onto the correct ones.

-Paul
User avatar
paul
Site Admin
 
Posts: 912
Joined: Sun Nov 30, 2003 12:06 am
Location: Las Vegas, NV

Re: Daisy Chaining Shiftbrites

Postby paul on Fri Jul 30, 2010 1:21 pm

By the way, I have not actually tried this code, so please let me know if it does not work for you (and post your complete code).

-Paul
User avatar
paul
Site Admin
 
Posts: 912
Joined: Sun Nov 30, 2003 12:06 am
Location: Las Vegas, NV

Re: Daisy Chaining Shiftbrites

Postby aron42486 on Fri Jul 30, 2010 1:35 pm

Thanks Paul, I will try that this weekend and let you know how it turns out
aron42486
 
Posts: 4
Joined: Fri Jul 30, 2010 12:49 pm

Re: Daisy Chaining Shiftbrites

Postby aron42486 on Sat Jul 31, 2010 7:09 pm

So I tried the code out and it works. I have made the shiftbrites alternate between blue and orange colors. Here is the code in case any wants it for an example:
Code: Select all
begin
1020 297 0 0 264 1023 rgb
1000 delay
0 264 1023 1020 297 0 rgb
1000 delay
repeat

# Subroutine for setting the RGB value of a ShiftBrite/ShiftBar.
# example usage: 1023 511 255 rgb
sub rgb
0 send_bit # this bit does not matter
0 send_bit # the "address" bit - 0 means a color command
swap rot rot
send_10_bit_value
send_10_bit_value
send_10_bit_value

0 send_bit # this bit does not matter
0 send_bit # the "address" bit - 0 means a color command
swap rot rot
send_10_bit_value
send_10_bit_value
send_10_bit_value

0 1 8000 1 servo servo # toggle the latch pin
return

# sends a numerical value as a sequence of 10 bits
sub send_10_bit_value
512
begin
dup
while
over over bitwise_and send_bit
1 shift_right
repeat
drop drop
return

# sends a single bit
sub send_bit
if 8000 else 0 endif
2 servo # set DATA to 0 or 1
0 0 8000 0 servo servo # toggle CLOCK
return

sub stopper
0 0 0 rgb
quit

Thanks again Paul. I would also like to know if it is possible to use a "get_moving_state" command to make the shiftbrites slowly dim or get brighter? Or would there be an easier way of programming that sort of action? I will test it out and see how it works.
aron42486
 
Posts: 4
Joined: Fri Jul 30, 2010 12:49 pm


Return to Other Pololu Products

Who is online

Users browsing this forum: No registered users and 1 guest