Auteur Sujet: Using AccessoryLight with a multiple-LED-signal  (Lu 13821 fois)

taurus1047.5

  • Newbie
  • *
  • Messages: 3
    • Voir le profil
Using AccessoryLight with a multiple-LED-signal
« le: février 29, 2016, 08:10:04 pm »
Hello,

I have a question concerning AccessoryLight or AccessoryGroup:
I would like to implement Hungarian signals. On our signals, one or two lights can be lit at one time, they may also flash - and we have a max. of 5 lamps on a signal post. So I have a maximum of 8 signals (8 states), because our signals show the current speed limit and also act as a distant signal "repeating" the signal of the next signal post.

My idea was to do it like this: I have 4 DCC addresses with 2 state each representing one state.
Address | Signal0 | Signal 1
1 | red: stop signal | green: Vmax & distant signal's Vmax
2 | red & blinking white: on call signal (subsidiary signal) | white: shunting signal
3 | Vmax & distant signal's 40 km/h | 40 km/h + distant signal's 40 km/h
4 | ... | ....

I also saw, that my Multimaus is sending at least 8-10 packets for one short push of a button, therefore I wanted to implement a status array with the use of "void AccessoryDecoderPacketHandler(int address, boolean activate, byte data)" to prevent "bouncing" (a LED switching on and off at every data packet) - see attachment.
Everything should work (I switch the arduino's ports on and off manually), but I would need something for flashing and dimming.

I saw that AccessoryLight would be able to do such a thing, but I cannot bind one LED to one DCC address, because 5 LEDs belong together on a signal post.

Can I do it somehow without giving AccessoryLight a DCC address, or should I use an AccessoryGroup (defining every LED's state for every signal state)?

If I use AccessoryGroup and AccessoryLight: It there any possibility to implement a "state array" for preventing "bouncing"?

Thank you in advance,
Gabor

taurus1047.5

  • Newbie
  • *
  • Messages: 3
    • Voir le profil
Re : Using AccessoryLight with a multiple-LED-signal
« Réponse #1 le: février 29, 2016, 08:44:38 pm »
Another question is: we have - at our club - signals, which have a positive common for the LEDs and one negative cable for each LED. Therefore I have to switch the negative cables and invert the arduino's output (LED off: port = Vcc, LED on: port = GND). Would that be possible or shall I do this somehow with a hardware circuit?

Thanks,
Gabor

Thierry

  • Global Moderator
  • Hero Member
  • *****
  • Messages: 745
    • Voir le profil
Re : Using AccessoryLight with a multiple-LED-signal
« Réponse #2 le: mars 01, 2016, 09:34:04 am »
Hello

First, about signals. Before the actual 4.30 version of UAD, the AccessoryGroup was the only answer to your needs. It was a little bit heavy, and that's the reason why i created a new class AccessoryLightMulti. This class allows you to build a full signal into one class, handling blinking, dimming and combination of on/off lights with one Dcc code. The samples have been adapted to use this new class instead of the old groups. The groups are still usable for heterogeneous accessories moving together, like a pool of turnouts ...
Basically, you can define an AccessoryLightMulti, add leds with dimming arguments if necessary (beware of the pins used for these leds, dimming is only working on analog pins). then with AddDccPosition, you can fix combinations of lights on and off with a bit field. You will just have to set the blinking effect manually. See the ::Move in the sample SignalFrench. Even if this is not so easy, i think the best way for you should be probably to adapt signalFrench to your needs... If you decide to do that, tell me and i will give you an english translated ino file (comments mainly...) if you need.

Thierry

  • Global Moderator
  • Hero Member
  • *****
  • Messages: 745
    • Voir le profil
Re : Using AccessoryLight with a multiple-LED-signal
« Réponse #3 le: mars 01, 2016, 09:36:28 am »
Each led is linked to a port of the Arduino driver. When you define this port, you can declare it either DIGITAL, or DIGITAL_INVERTED according to the way you have connected your led !

Thierry

  • Global Moderator
  • Hero Member
  • *****
  • Messages: 745
    • Voir le profil
Re : Using AccessoryLight with a multiple-LED-signal
« Réponse #4 le: mars 01, 2016, 09:40:08 pm »
Good evening.

I have just posted a new version 4.35, with the possibility for an AccessoryLightMulti to handle blinking in an easier way. You can find also a new sample SimpleLedMulti.ino to illustrate the use of the class. The main change is in the AddDccPosition(). The third argument where already the bit mask to express which led have to be on, the new fourth argument is also a mask, but to say which led is blinking when on !

taurus1047.5

  • Newbie
  • *
  • Messages: 3
    • Voir le profil
Re : Using AccessoryLight with a multiple-LED-signal
« Réponse #5 le: mars 04, 2016, 10:14:58 pm »
Hello Thierry,

I will try out that new class, thanks for the hint. I have to look at this class, how it works, because the Multimaus cannot give "extended accessory" commands (where you have 0-31 aspects for one DCC address), so I have to implement the combinations of signal aspects with more DCC addresses using on-off states.

Thanks anyway :)

Best regards,
Gabor

Thierry

  • Global Moderator
  • Hero Member
  • *****
  • Messages: 745
    • Voir le profil
Re : Using AccessoryLight with a multiple-LED-signal
« Réponse #6 le: mars 05, 2016, 10:36:01 am »
Hello

In the given sample, you will see that for convenience and tests, i have used a different DCC address for each combination !

dtiganas

  • Newbie
  • *
  • Messages: 1
    • Voir le profil
Re : Using AccessoryLight with a multiple-LED-signal
« Réponse #7 le: mai 05, 2016, 11:03:43 pm »
Hi Thierry,
First of all, thank you very much for the excellent work!
I tried the AccessorryLightMulti class and it works great for 1 signal with 5 lights and 10 aspects.
As I am not a programmer, could you please guide me how can I extend the program to be able to control using an Mini pro, 4 signals of 4 lights each, with 4 aspects / signal (same aspects for all signals)? I attached my modified code which I am afraid it does not work as expected...
Thank you very much again!

Thierry

  • Global Moderator
  • Hero Member
  • *****
  • Messages: 745
    • Voir le profil
Re : Using AccessoryLight with a multiple-LED-signal
« Réponse #8 le: mai 08, 2016, 05:21:43 pm »
Hello. Nice to know that my class works !
I have edited your source, just to change a few things, like Arduino ports initialisations that were not correct for the second set of 4...
My problem is that i dont have a working mini pro to test your application. I have ordered things in china, but they will arrive in a few weeks only... In the meantime, tells me if the joined source works. For the mini usage, I am afraid by the number of pins you will need (4x4 : 16 !). You will have to also use analog pins as digital output...
« Modifié: mai 08, 2016, 05:29:06 pm par Thierry »

Thierry

  • Global Moderator
  • Hero Member
  • *****
  • Messages: 745
    • Voir le profil
Re : Using AccessoryLight with a multiple-LED-signal
« Réponse #9 le: mai 10, 2016, 09:12:30 pm »
After a fast control, the pins of a mini are globally the same than a Uno or a Nano R3. So it would work without problems or modifications.