Thread Tools
Oct 18, 2019, 09:54 PM
Registered User
I've done an attempt at splicing in the light functions from my own project. If this is something that would work for your project I can try to refine it and make it more readable. There are still some more variables left that are now unused. Feel free to use and modify.

This mod lets blink, softblink, fastblink, xenon and fadeoff work without blocking the code, so they can work independently at the same time. At the moment multiple pins of the same blink type (blink or softblink or fastblink) will flash in sync, but if you prefer them out of sync, that can be rewritten. I also included the "scheduled" radio reads to improve the fading performance.

I've only done quick testing breadboard testing with the first 5 light pins, but as far as I can tell, it matches the original.

All edits or additions are tagged with "-wombii"

This is based on version 2.24. Files changed are: AA_UserConfig.h, Lights.ino, RX_COMMANDS.ino, OpenSourceLights.ino.
The included zip file does not include the libraries.
Sign up now
to remove ads between posts
Oct 21, 2019, 05:06 PM
Registered User
LukeZ's Avatar
Thread OP
Wombii I really appreciate the time you've put into this. I am in the middle of a move at present and my equipment is in storage so I admit I have not done any physical testing, but I've read through it and it all seems good to me.

I've incorporated all your changes essentially unmodified (I did move some stuff around, for example I did put specialTimingArray as a global variable in the OpenSourceLights tab as you suggested).

I've posted these changes to the first post of this thread and also to GitHub with the new version being called 3.01.

If anyone has issues do please post them here so we can address them.

Wombii, you may be interested to look at a class I wrote long after I started this project which I call LED_Handler. Like your approach it uses polling to update the fade effect, but instead of pre-estimating the main loop time and basing timing decisions on that (which can change), you tell it how long you want the fade/blink/whatever to take and it takes care of the rest, all you have to do is call the update() function in the main loop (a new instance of the class is created for each individual LED, so if you have multiple LEDs you need to update all of them, eg Led1.update(), Led2.update(), etc... Of course you can also create an array of the class).

If the loop runs very fast and the update gets called before the next light change step is required, then LedHandler does nothing and waits for the next poll. There is no real penalty for calling update() too often. If the main loop is too slow and the update isn't called until multiple steps were required, then LedHandler skips ahead to stay current. Either way, the effect will take however long the user specifies, regardless of whether the loop is slow or fast or changes speed midway through. The worst that can happen if the main loop repeats too slowly is that a fade could look jerky, or a blink might be a few milliseconds off, but this would have to be pretty slow and you can also call update() multiple times per loop.

Of course this class doesn't have softblink or xenon effects and to make it compatible with the OSL would require some updates. I have wanted to do so but I just don't have the time to devote to it.

However as a coder yourself I thought you might nevertheless appreciate this approach.

(PS: The class requires a reference to the elapsedMillis class which you can get from Arduino or may even already be included in the standard Arduino libraries now)
Oct 25, 2019, 09:33 PM
Registered User
Thank you for trusting my messy attempt at hacking in my own code, even though it's a bit scary to have it implemented without a lot of testing. Are you sure you don't want to keep it as an alternative version until more people have gotten it to work?

The ledhandler thing looks very interesting. I might even understand it one day
Having to guess the timings is certainly an issue with radio refresh rates varying so much. I've tried in the past to do some auto calibration by measuring the loop times and doing some math to correct the timing every now and then, but I never got it to a state I was happy with.

I didn't know about elapsedmillis. Having that as a standard function would absolutely make sense.
Oct 28, 2019, 11:17 AM
Registered User
LukeZ's Avatar
Thread OP
Understanding the LedHnadler code is not difficult, at least the basic principle. It is no more complicated than what you have already done! It can be implemented even without elapsedMillis, you can just use the basic millis() counter and another variable to compare with in order to determine how much time has passed, but elapsedMillis is a more convenient way. The stream blinker struct and other actual effect functions look a bit complicated at first blush but aren't really related to the issue at hand, which is just the timing of the changes in LED state (blinking, fading, whatever).

I'm not too worried about your code, prior known-good releases are always available on GitHub here so we can roll-back easily if necessary.
Oct 29, 2019, 04:10 AM
Registered User
Good day.
Many thanks for your project !!!
Light like that.

I reworked the circuit and slightly modified the sketch for using the "Arduino Pro Mini"
4 control inputs, 11 outputs (9 lights, 2 serv)

Therefore, my decisions in the code are not optimal, but they work as I wanted))))


Channel 4 is controlled exclusively by serv. Not included in the settings table. Rigidly tied to pins and actions (3 positions - both 0, first 0 second 180, both 180.) are needed to turn on / off differentials in bridges.

Changes are made on the version of "OpenSourceLightsCode_v2-23".
The version of "OpenSourceLightsCode_v3" could not be made to work ((((

The boards are made using engraving (itís difficult and expensive to order industrial production)
the total cost of the finished module is approximately $ 10

Photos, schemes, sketch - I will post later.

P.S. I apologize for my English GOOGLE TRANSLATOR
Last edited by Nosfer; Oct 29, 2019 at 04:27 AM.
Oct 31, 2019, 06:25 PM
Registered User
Hey there, great project! Have an issue though. I finally got my board (Arduino Nano) to connect after a few days of struggling, code uploaded, and though I was good to go. But the code upload fine without errors now, but as soon as I power up the board it goes into radio setup mode, and stays there. I followed the process to completion and it just keep looping and starting over. Anyone have any idea why that could be?
Oct 31, 2019, 06:47 PM
Registered User
LukeZ's Avatar
Thread OP
Gswagg - It sounds like you have pin A0 connected to ground. On the OSL board it is connected to a button, when the button is pushed and brings the pin to ground you can enter the radio setup routine, but if you are making your own board with an Arduino Nano and you've somehow hardwired that pin to ground then it will constantly return to radio setup until the pin is disconnected.

Nosfer - Google translate is working well because I can understand you just fine. Very cool mods!
Oct 31, 2019, 07:48 PM
Registered User
Hi Luke,

Thanks for the input so quickly! That makes sense, but I do aheva button connected to A0 but maybe my jumper is shorting to ground. I will check it out and let you know.
Oct 31, 2019, 08:26 PM
Registered User
Just checked it out. No short to ground, I even replaced the button still loops the Radio Setup. Any other suggestions? I tried different boards, different breadboards, different jumpers. Still loopy!
Oct 31, 2019, 09:24 PM
Registered User
LukeZ's Avatar
Thread OP
What if you remove the button completely and leave the A0 pin disconnected from anything at all?

Maybe also post a photo of your setup.
Oct 31, 2019, 09:36 PM
Registered User
Yup tried removing the button and still no change. Its as if the button has no effect at all like the A0 Pin isn't even working. See attached for photo of my setup.
Oct 31, 2019, 11:29 PM
Registered User
Quote:
Originally Posted by Gswagg
Yup tried removing the button and still no change. Its as if the button has no effect at all like the A0 Pin isn't even working. See attached for photo of my setup.
Ok Update: I found where I grounded it under one of the LEDs. Yes, I am a rookie, lol!

Anyway, now I am fighting the same problem I have been fighting for a couple days. All I get is blinking LED's, all of them. It looks like what it would do if the failsafe triggered, or if it was indicated changing schemes, the only thing is that it does not stop. The only time i can get it to do something different is if I go into radio setup with the newly functioning (ungrounded) setup button, but once I complete the setup, all the LEDs start flashing again.

Anyone have any ideas about that?
Nov 01, 2019, 10:09 AM
Registered User
LukeZ's Avatar
Thread OP
I assume you are using the new v3.01 firmware. As a test, let's go back to the prior release which is 2.24, you can download it here (right click and save as) v00.02.24.zip

See if that makes any difference.
Nov 01, 2019, 04:57 PM
Registered User
Well now, I think we are getting somewhere! Thank you much for that. Now I get different types of flashing lights that seem to be reacting to transmitter inputs so let me play around with the schemes and see if it's fixed.

Thanks again!
Nov 01, 2019, 05:30 PM
Registered User
I was going to suggest that there might be a misbehaving connection that prevented the throttle signal from reaching D2, but if 2.24 works, that has me puzzled. On my nano + breadboard setup 3.01 and 2.24 both work with the standard setup.
Please update when you've verified it's fully working.


Quick Reply
Message:

Thread Tools

Similar Threads
Category Thread Thread Starter Forum Replies Last Post
Discussion Arduino Nav Light Controller chuck99z28 DIY Electronics 65 Mar 23, 2019 06:25 PM
Discussion Linux Based Open Source Control System (OSRC) Gizmoman31 UAV - Unmanned Aerial Vehicles 10 Mar 18, 2012 11:26 AM
Idea Linux Based Open Source Control System (OSRC) Gizmoman31 Aerial Photography 9 Mar 18, 2012 11:25 AM
Question Any open source ARM based multi roter heli? ctrl Multirotor Drone Talk 7 Jul 20, 2011 05:44 AM