RANet Dimming Module! Usage?

Expansion modules and attachments
Post Reply
User avatar
cosmith71
Posts: 1432
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

RANet Dimming Module! Usage?

Post by cosmith71 »

I have one of these wonders on the way. Is it in the 1.1.1 libraries yet? How would I address it?

Also, I was looking at this bit of lightning code Roberto posted for the LED Driver.

Code: Select all

  int a=random(5);
  for (int i=0;i<a;i++)
  {
    int newdata=4095;
    Wire.beginTransmission(0x40);
    Wire.write(0x8+(4*2));
    Wire.write(newdata&0xff);
    Wire.write(newdata>>8);
    Wire.endTransmission();
    delay(20+random(50));
    newdata=0;
    Wire.beginTransmission(0x40);
    Wire.write(0x8+(4*2));
    Wire.write(newdata&0xff);
    Wire.write(newdata>>8);
    Wire.endTransmission();
    delay(30+random(20));
  }
  delay(random(1000));
Can someone (probably Roberto ;) ) explain the significance of the values here? I'm guessing that 0x40 is the address of the LED Controller. 0x8+(4*2) (16?), I have no clue, maybe how many bits we're sending? The values newdata&0xff, and newdata>>8: I understand the values we're sending, but what do these particular values represent, why the bitwise AND, and why the bitshift? I'm guessing there's a guide for the chip that explains all this.

Thanks,

--Colin
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: RANet Dimming Module! Usage?

Post by rimai »

Here is the code with some comments. Sorry about that :(
I'm terrible for placing comments on my codes.

Code: Select all

  int a=random(5); // get a random number of strikes
  for (int i=0;i<a;i++) // loop through until we reach the number of strikes we will have
  {
    int newdata=4095; // strike is at 100%
    Wire.beginTransmission(0x40); // 0x40 is the address of the IC we are using on the dimming expansion module
    Wire.write(0x8+(4*2)); // Send the 100% to channel 2 - Address location for channel 0 is 0x8, channel 1 is 0x12 and so on
    Wire.write(newdata&0xff); // Send the LSB of the 100%
    Wire.write(newdata>>8); // Send the MSB of the 100%
    Wire.endTransmission();
    delay(20+random(50)); // delay each strike by a random number from 20ms to 70ms
    newdata=0; // turn off strike after delay
    Wire.beginTransmission(0x40); // Same as above
    Wire.write(0x8+(4*2));
    Wire.write(newdata&0xff);
    Wire.write(newdata>>8);
    Wire.endTransmission();
    delay(30+random(20)); // delay each strike by a random number from 30ms to 50ms
  }
  delay(random(1000));
Roberto.
User avatar
cosmith71
Posts: 1432
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: RANet Dimming Module! Usage?

Post by cosmith71 »

OK, so we're sending 16 bits (really only using 12) 8 bits at a time? What's the bitwise AND doing to the MSB?

--C
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: RANet Dimming Module! Usage?

Post by rimai »

Well, you caught my mistake :oops:
MSB is most significant byte and LSB is lowest significant byte.
So, if a 16bit number is represented by 0x0123, the MSB would be 0x01 and the LSB would be 0x23.
So, to extract the LSB, we AND it with 0xff ( 0x0123 && 0xff = 0x23 ) and to extract the MSB, we shift right by 8 bits ( 0x0123 >> 8 ). This is a very common method of splitting MSB and LSB out of a 16bit number.
You are correct the the number is represented by 16bits, but we only use 12bits out of it.
Roberto.
User avatar
cosmith71
Posts: 1432
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: RANet Dimming Module! Usage?

Post by cosmith71 »

Got it! I was starting to wonder if the MSB and LSB were reversed. :D And I thought I'd never use that VAX Assembler class I took 20 years ago. :ugeek:

Is there anything in the libraries, or do I need to cobble something together?

Thanks,

--Colin
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: RANet Dimming Module! Usage?

Post by rimai »

For standard waveforms, everything is in the libs. The only thing you can't do is the lightning.
The new RANet will require a change on the core library released by the Arduino team.
Attached is the file you will need to replace.
Replace the original SoftwareSerial.cpp located at C:\Program Files (x86)\Reef Angel Controller\libraries\SoftwareSerial with the one attached.
Then add this include on your code:

Code: Select all

#include <SoftwareSerial.h>
And add this to setup():

Code: Select all

ReefAngel.AddRANet();
Code the dimming module the same way as the non-wireless version.
Attachments
SoftwareSerial.zip
(4.26 KiB) Downloaded 530 times
Roberto.
User avatar
cosmith71
Posts: 1432
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: RANet Dimming Module! Usage?

Post by cosmith71 »

The new RANet will require a change on the core library released by the Arduino team.
Just out of curiosity, can you explain further on this?

Thanks,

--Colin
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: RANet Dimming Module! Usage?

Post by rimai »

It's the attached file :)
Basically it is because we use interrupts to catch the button press and the SoftwareSerial library also uses interrupts to generate the correct baud rate clock pulses, so we had a conflict.
I had to disable INT0 inside the SoftwareSerial to be able to get RANet to work.
This isn't final yet. I may need to tweak and see how to best handle this.
Roberto.
User avatar
cosmith71
Posts: 1432
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: RANet Dimming Module! Usage?

Post by cosmith71 »

Got the RANet dimming module. Playing with it now.

Is 0x40 the correct address for the RANet dimming module?

--Colin
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: RANet Dimming Module! Usage?

Post by rimai »

yes. you don't need to do anything to the dimming module except configure your dimming signal voltage
Roberto.
User avatar
cosmith71
Posts: 1432
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: RANet Dimming Module! Usage?

Post by cosmith71 »

rimai wrote:yes. you don't need to do anything to the dimming module except configure your dimming signal voltage
Got it running. I took the daughterboard off to set the jumpers and couldn't figure out which way it went back. It was nice of you to make it only fit one way. :lol:

I'll probably hook up my Jebao's tonight or tomorrow. I think I'll wait on hooking up the LED's. I still need to study the hi resolution dimming, etc.

Thanks!

--Colin
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: RANet Dimming Module! Usage?

Post by rimai »

If you connect the wrong way, you can't close the box.
Roberto.
User avatar
cosmith71
Posts: 1432
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: RANet Dimming Module! Usage?

Post by cosmith71 »

rimai wrote:If you connect the wrong way, you can't close the box.
So I found out! That's good design!

--Colin
bencollinz
Posts: 140
Joined: Wed Mar 13, 2013 5:36 pm

Re: RANet Dimming Module! Usage?

Post by bencollinz »

rimai wrote:yes. you don't need to do anything to the dimming module except configure your dimming signal voltage
is this still the case? and where do I do that? and are the pin layouts the same as the PWM dimming module?
Image
User avatar
cosmith71
Posts: 1432
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: RANet Dimming Module! Usage?

Post by cosmith71 »

bencollinz
Posts: 140
Joined: Wed Mar 13, 2013 5:36 pm

Re: RANet Dimming Module! Usage?

Post by bencollinz »

cosmith71 wrote:Yup. Look here on page 5.

http://www.reefangel.com/files/Dimming% ... _1.4.2.pdf

--Colin
20150103_171855.jpg
20150103_171855.jpg (728.55 KiB) Viewed 7028 times
Thank you.

So, I'm OK if I put my wires in the same place on the new RAnet dimming as the old wired dimming?
Image
User avatar
cosmith71
Posts: 1432
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: RANet Dimming Module! Usage?

Post by cosmith71 »

Here you go:
20150103_171855.jpg
20150103_171855.jpg (255.79 KiB) Viewed 7028 times
bencollinz
Posts: 140
Joined: Wed Mar 13, 2013 5:36 pm

Re: RANet Dimming Module! Usage?

Post by bencollinz »

cosmith71 wrote:Here you go:
20150103_171855.jpg
thank you
Image
Post Reply