Adding support for 16 channel PWM expansion to libraries

Related to the development libraries, released by Curt Binder
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Adding support for 16 channel PWM expansion to libraries

Post by cosmith71 »

OK, got it fixed! I now have full 12 bit dimming on my RANet 6 channel dimming expansion! :ugeek:

Not sure what happened. I spotted an error in the receiver code that I swear I fixed earlier. Changed that and it's working.

I used a spare Xbee and the USB module I bought to program them to intercept the data stream. I used a program called RealTerm to look at the hex stream the module was receiving and made sure the 16 bit payload was being sent correctly. It was. That led me back to the receiver code. Turns out I had an error in the code that selects the channel I'm loading. Once that was fixed, it worked!

So now the RANet payload consists 8 bytes for relay boxes, 8 bytes for fallback relay values, 12 bytes for 6 channel dimming (2 bytes per channel) and 32 bytes for 16 channel dimming (not yet implemented, but would be same as 6 channel).

Now, I just need to implement lightning and clouds. It'll take an adjustment to the trigger mechanism.

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

Re: Adding support for 16 channel PWM expansion to libraries

Post by rimai »

Awesome!!!
While you are at it and hand on :), add the trigger to the payload.
If we add a new byte to the payload, we can trigger up to 255 commands.
So, 0 would be no commands, 1 would be lightning, 2 would be something else and so on.
Then, all the receiver needs to do is check for that byte and trigger it accordingly.
Roberto.
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Adding support for 16 channel PWM expansion to libraries

Post by cosmith71 »

Great idea! I was just going to hide it in the high 4 bits of one of the channels, but I like the idea of a dedicated byte better. Time to put my thinking cap back on. :ugeek:

--Colin
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Adding support for 16 channel PWM expansion to libraries

Post by cosmith71 »

OK, so that's done. I just added a byte onto the packet at the end right before the terminal <CR><LF>.

Now my problem is I don't know how to set it. :oops: I guess we need a new library function? Something like ReefAngel.SetRANetTrigger(trigger value)?

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

Re: Adding support for 16 channel PWM expansion to libraries

Post by rimai »

That should work :)
Roberto.
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Adding support for 16 channel PWM expansion to libraries

Post by cosmith71 »

Done. ReefAngel.RANetTrigger(byte) is now a thing. RANet Receiver with Lightning code updated as well. :ugeek: :ugeek:

--Colin
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Adding support for 16 channel PWM expansion to libraries

Post by lnevo »

Holy cow! Way to go colin!!!
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Adding support for 16 channel PWM expansion to libraries

Post by cosmith71 »

Yes, certainly my crowning achievement as a coder. :lol:

Roberto, should I submit pull requests? It won't work on a RANet dimmer without updated code.

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

Re: Adding support for 16 channel PWM expansion to libraries

Post by rimai »

Yes, send me a pull request and also the updated firmware for the receiver.
Roberto.
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Adding support for 16 channel PWM expansion to libraries

Post by cosmith71 »

Done.
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Adding support for 16 channel PWM expansion to libraries

Post by cosmith71 »

I had a thought. We could use different trigger values to trigger lightning on different channels. Say, 1 flashes channel 1, 2 flashes 2, 3 flashes 1 and 2, something like that.

Maybe even make the trigger an int to open up possibilities.

--Colin
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Adding support for 16 channel PWM expansion to libraries

Post by lnevo »

You can have 256 possibilities with a byte... just sayin :)
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Adding support for 16 channel PWM expansion to libraries

Post by cosmith71 »

I know. I'm just thinking out loud. :D
Post Reply