Arduino Uno Programming Assistance Request

Advert

Arduino Uno Programming Assistance Request

Home Forums Electronics in the Workshop Arduino Uno Programming Assistance Request

Viewing 25 posts - 26 through 50 (of 86 total)
  • Author
    Posts
  • #335141
    Grizzly bear
    Participant
      @grizzlybear

      For those of you picturing a swinging picaxe, try this:

      http://www.picaxe.com/

      Picaxe has a superb forum.

      Regards, bear..

      Advert
      #335149
      doubletop
      Participant
        @doubletop

        I'm not an Arduino person but I've read through this and think you are missing a trick. When you use these modules, you should get hold of the manufacturers documentation and find out what is lurking in the box, rather than hope somebody has done something in a library to make your life easier. Once you know what the device can do then find the library routine that does it for you. (DS3231 data sheet)

        Next thing is determine how interrupts can work for you rather than continually polling the device and checking “Are we there yet”. As you are using an RTC that has a 1sec pulse output this should be used as an interrupt then your code is in sync with the RTC.

        On every second tick all the registers can be read and a decision made what to do.

        The DS3231 registers contain binary coded decimal (BCD) data packed into a number of 16 bit registers

        Here is some C code that gets all the BCD data from the RTC into separate decimal variables to be used in you code

        void rtc_gettime(){

        //get time from RTC in BCD

        rtc_rd_page(0,RTC_Data,8);

        //convert to decimal

        _Year = (RTC_Data[6] >> 4)*10 + (RTC_Data[6] & 0x0f);

        _Month = (RTC_Data[5] >> 4)*10 + (RTC_Data[5] & 0x0f);

        _Date = (RTC_Data[4] >> 4)*10 + (RTC_Data[4] & 0x0f);

        _Hours = (RTC_Data[2] >> 4)*10 + (RTC_Data[2] & 0x0f);

        _Mins = (RTC_Data[1] >> 4)*10 + (RTC_Data[1] & 0x0f);

        _Secs = (RTC_Data[0] >> 4)*10 + (RTC_Data[0] & 0x0f);

         

        So

        If _Secs = 0 and _Mins=0 then “DoBongs” (number of bongs is the _Hours value.)

        If _Hours = 12 then “Do_hour_bongs” (or _Hours = 3 or 6 or 9 then Do_Quarter_Bongs)

        If _Day = 25 and _Month = 12 the Do_Christmas_Bongs

        If _Day = wifes_bday and _Month = wifes_bmonth the Do_birthday_Bongs.

        The options are endless.

        The question then becomes how to manage the bongs when they are going to be longer than the 1 sec interrupt period. Just set a flag in the ISR for the type required and let the main routine just do what it has been instructed.

        In the ISR

        Do_Bongs = true;

        Do_hour_bongs = false;

        Do_Quarter_Bongs = false;

        Do_Christmas_Bongs = false;

        Do_birthday_Bongs = false;

        (Of course you’ll need to ensure only one type is set true at any one time)

        In the main routine

        If Do_Bongs then ……..

        If Do_hour_bongs …

        If Do_Quarter_Bongs ….

        If Do_Christmas_Bongs ….

        If Do_birthday_Bongs ….

        When the bonging is complete clear the bongs flags to signal back to the ISR that you’ve done bonging and it can request another set of bongs.

        also as you now have a once second interrupt you could at "tick" "tocks"

        and of course you've got a minimum of 15 mins between bong requests from the ISR, long enough to annoy everybody and for them to ask you to "turn the bl…y thing off"

        Pete

        Edited By Doubletop on 03/01/2018 18:25:08

        Edited By Doubletop on 03/01/2018 18:31:32

        #335156
        doubletop
        Participant
          @doubletop

          A further thought to add to the annoyance factor.

          Use a 16 bit output port driving 16 solenoids and 16 bells and you'd have a Carillon. The tunes table could be held on an SD card using another module. Endless options there as well.

          ……..

          I've just been making whistles for my loco, so keeping to the ME theme, a boiler and 16 steam whistles selected by solenoids and a now a Calliope. Anybody who has been on the Natchez in New Orleans will know how annoyingly loud that is.

           

          Pete

          Edited By Doubletop on 03/01/2018 18:44:00

          Edited By Doubletop on 03/01/2018 18:44:42

          Edited By Doubletop on 03/01/2018 18:45:58

          #335169
          SillyOldDuffer
          Moderator
            @sillyoldduffer
            Posted by SillyOldDuffer on 03/01/2018 10:37:22:

            Last night in bed I had a flash of inspiration …

            Dave

            Turned out to be a flush of misperception. After an hour of fiddling this afternoon I can't get the idea to work reliably and the code's getting more and more complicated. I've started confusing myself!

            As programming problems go this one's more challenging that it looks. The solution is trivial if you're allowed to use the delay() function, but James has reasons for not wanting delay() in his program. Another twist is the need to control the mark space ratio – it's not 50:50.

            One way of doing the bongs is with the timer / interrupt solution I described earlier in the thread. Another is with a lookup table / state machine as outlined by Frances (I might try that later). It's also possible to do with time comparisons and flags as James tried in his Original Post. However, his difficulty and my two failed attempts are discouraging.

            Doubletop has fallen neatly into the trap of not answering the exam question! His suggestion is all good stuff until he concludes 'In the main routine If Do_Bongs then ……..'. Trouble is James wants to know 'How do you code Do_bongs?'

            Does an interest in this subject make us all Bongkers? It would explain a lot…smiley

            Dave

            #335186
            Frances IoM
            Participant
              @francesiom58905

              The key to this type of problem (IMO) is to run just a single clock driven interrupt that merely does the minimum of work (eg flipping a bit, reading an input value) then exits – the communication between it and a user level program can be via cyclic buffers (user controls write pointer, interrupt controls read pointer or vice-versa) – the delay function could be handled as a co-routine tho I thought this a bit too complicated for a brief forum answer but I once wrote a complete lighting control program for large open plan offices that took in signals from phones calling special numbers to switch on/off associated lights which ran entirely from a single 18.2ms interrupts on an 8086 in less than 64kBytes of C code using table driven state machines + co-routines to avoid any possible wait-for deadlocks

              Edited By Frances IoM on 03/01/2018 22:12:31

              #335190
              doubletop
              Participant
                @doubletop
                Posted by SillyOldDuffer on 03/01/2018 20:17:14:

                Posted by SillyOldDuffer on 03/01/2018 10:37:22:

                Doubletop has fallen neatly into the trap of not answering the exam question! His suggestion is all good stuff until he concludes 'In the main routine If Do_Bongs then ……..'. Trouble is James wants to know 'How do you code Do_bongs?'

                …..

                Dave

                So now we've got the RTC tied to an interrupt, have access to all the date/time info and have set a flag to tell the main code to "do_some _bongs" we need a generic routine that allows us to do bongs with different time intervals.

                I'm from the school that says delays are bad practice and only to be used when there's nothing else. Basically, short term delays of usec durations. If you've got a delay running the processor can’t do anything else apart from interrupts. So I'd approach this with a table of intervals of solenoid on/off. These times sequentially loaded into a timer that interrupts when it hits zero then the solenoid line is toggled and the timer reloaded with the next time from the table. If (say) the last time in the table is 0 then the process stops. That way different inter-strike periods can be used ( say) for doing the London chimes prior to striking the hour. Depending on the number of timers available more than on striking solenoids can be implemented.

                As I say I’m not an Arduino person, but all these functions will be supported by the chip you just need to work through the library layers to get to them. They’ll be in there somewhere. It's just electric lego.

                Pete

                Off course there is good reason not to have 50:50 mark space ratios. The PWM function could usefully be considered.

                 

                Edited By Doubletop on 03/01/2018 22:36:15

                #335196
                SillyOldDuffer
                Moderator
                  @sillyoldduffer
                  Posted by Frances IoM on 03/01/2018 22:11:29:
                  The key to this type of problem (IMO) is to run just a single clock driven interrupt that merely does the minimum of work (eg flipping a bit, reading an input value) then exits – the communication between it and a user level program can be via cyclic buffers (user controls write pointer, interrupt controls read pointer or vice-versa) – the delay function could be handled as a co-routine tho I thought this a bit too complicated for a brief forum answer but I once wrote a complete lighting control program for large open plan offices that took in signals from phones calling special numbers to switch on/off associated lights which ran entirely from a single 18.2ms interrupts on an 8086 in less than 64kBytes of C code using table driven state machines + co-routines to avoid any possible wait-for deadlocks

                  Edited By Frances IoM on 03/01/2018 22:12:31

                  That's a most impressive achievement Frances – most of my C/C++ experience involved system specials, very few of them event driven. No control programs whatever in my programming career so I'm pretty ignorant in that department.

                  Your mention of co-routines may have led to an easy to implement answer though. I've found there are a few co-routine libraries for the Arduino on the web and the first I looked at looks easy to use. (Some hopes!) I shall be having a play with it tomorrow. If it does what it says on the tin, the library will simplify another stalled project – an Arduino controlled car that, ahem, works properly most of the time.

                  Thanks,

                  Dave

                  #335225
                  James Alford
                  Participant
                    @jamesalford67616

                    Thank you for the additional suggestions, which I shall look at.

                    What I am finding personally frustrating is that some years ago, I designed, wrote, implemented and maintained a bespoke software programme for a major telephone company. The system was used across their call centres to gather call data, help to route the call, to read data directly from the screen and feed it back into the programme for later use, gather marketing data and generate tailored marketing materials for each call. All of the data was dumped and collated in a single point on a server; I also created the distribution and update process for the it all. I used Visual Basics.

                    The trouble is that it was back in the late 1990s and I am blowed if I can remember much at all about how I did it and have done very little like it since.

                    James.

                    #335227
                    Marcus Bowman
                    Participant
                      @marcusbowman28936

                      James,

                      Ah, but that was work…

                      I thought for a moment you were going to say you used to go to a gym and could bench press 500Kg, but then you stopped and haven't gone for years. Now you find you can only do a bit, and you have forgotten how.

                      Welcome back to mental gymnastics…?

                      Marcus

                      #335228
                      James Alford
                      Participant
                        @jamesalford67616
                        Posted by Marcus Bowman on 04/01/2018 07:45:04:

                        James,

                        Ah, but that was work…

                        Welcome back to mental gymnastics…?

                        Marcus

                        Marcus,

                        Fair point about work as I could spend all day, everyday working it all out.

                        Definitely mental gymnastics: not a bad thing, though as it saves vegetating.

                        James.

                        #335232
                        Marcus Bowman
                        Participant
                          @marcusbowman28936

                          Here’s a thought which interrupted my beauty sleep at 5AM.

                          It’s a bit broad-brush, but the application is at the end.

                          It is interesting to reflect that this problem has been solved quite effectively already, in a mechanical clock. As I am sure you know better than me, a clock has two distinct parts – time, and strike (or bong, as we are calling it). The time side does just what the name says. If we ignore, for the moment, the arrangements for ‘warning’ (i.e. the just-before-the-strike arrangements preparing for the first strike in a particular sequence to be delivered swiftly) at the appropriate moment (quarters or hours), the time side trips the strike sequence. While the strike sequence is doing its thing, the time side carries on. There is also no possibility that a second strike sequence can be triggered during striking. After the trigger event, the strike does its job independently, including using a rack or a count wheel to determine how many strikes of the bell take place. When the strike sequence has finished, everything is reset, and the strike side waits for the next trigger.

                          One clear demonstration of this kind of signalling by the time mechanism to an independent strike mechanism is in a musical clock with lots of bells. Generally speaking, the whole of the musical side can be removed independently, leaving the time side just doing its own thing.

                          So; in the Arduino system, the RTC provides the time, and the Arduino can work out what that is in seconds, minutes, hours and so on, using an interrupt.

                          Perhaps that same method can be used to control an independent electronic strike ‘mechanism’.

                          One way is to try to have the Arduino fetch the time, decide when to trigger the bongs by looking for an appropriate time, and control the timing within the bong sequence. That’s a combined effort, but the time and strike ‘mechanisms’ are separate functions. It is true they run using just one processor, but that’s a convenience allowed by software. It does lead to the kinds of problems you (and we) have been experiencing, because we humans have to work out how t interleave what are actually separate functions hanging off just one processor.

                          A second way would be for the Arduino to fetch the time, decide when to trigger the bongs by looking for an appropriate time, then signal the number of bongs to another device which will sound the bongs and deal with their timing. The Arduino takes nothing to do with that, and just carried on dealing with the time. That’s pretty similar to what a mechanical clock does. You may say that is inefficient, but in a nod to established mechanical solutions, it can be implemented at low cost. Add a Nano or something similar, to handle the strikes.

                          Then, the Arduino repeatedly reads the time from the RTC and decides when, and how many, bongs should sound. It makes available a sound_the_bongs flag, and a number_of_bongs.

                          The second device does a somewhat similar job to the Arduino, to deal with bong number and duration. It waits for an interrupt generated by the Arduino sound_the_bongs flag, reads the number_of_bongs, and deals with the timing of signals to relays etc.

                          So the time and strike ‘mechanisms’ are essentially separate, and function much as in a mechanical clock.

                          The elements of most of the code required has already appeared in earlier posts.

                          If you have an Arduino and it is connected to an LCD display, for example, the LCD display essentially handles turning data into visible characters. The Arduino doesn’t do that part. All the Arduino does is trigger an update and make data available to the chip on the display. It’s the same in most computer systems, with the CPU passing signals to a graphics or sound or network card.

                          In theory, cunning programming should allow a single Arduino to handle both time and strike functions (see earlier post commenting on co-processing). In practice, I wonder if it is not simpler to separate them and use two processors.

                          Alternatively, fetch the time using an interrupt, then control the timing of the bonging using an internal timer on the same Arduino. That makes it appear as though the Arduino is doing two things at once. The wonder of speedy execution and juggling of electrons. It’s a mixture of hardware interrupts and software timers.

                          Then I fell asleep again, until I was interrupted by the alarm.

                          Marcus

                          #335238
                          doubletop
                          Participant
                            @doubletop

                            What Marcus has described is what I have proposed.

                            The interrupt routine, is the clock and the main routine does the strike. However, the interrupt routine running every second only has to check the RTC data to confirm when a 'bong' event is required and instruct the main routine to do it.

                            The bong sequence can be up to 15 minutes long as the shortest inter-bong period is 15mins. While the main routine is dealing with the current bongs the interrupt routine is quietly minding its own business checking for the next bong event.

                            multiple processors will not be requred, most of the time the processor will be looping around doing nothing. The interrupt routine should take less than a millisecond, every second and the main routine may have, at the most, 10 seconds work every hour and even less on the quarters.

                            I’d have a go at getting some code together but I’ve got another software project underway using the DynoBox and Weighbridge hardware as a steam indicator for locos. What’s more its summer here and the temperatures are in the mid 20’s , so not a time to be sat indoors

                            Pete

                            Edited By Doubletop on 04/01/2018 09:20:24

                            #335292
                            Howi
                            Participant
                              @howi

                              Bong sequence of 15 minutes? I must have been doing it wrong all this time! surprise

                              Perhaps I need some interrupts or some longer inter-bong periods!

                              #335297
                              SillyOldDuffer
                              Moderator
                                @sillyoldduffer

                                Well this one works as well. It uses Renaud Bedard's coroutine library copied off github. You only need the file coroutines.h – copy it into the Arduino Project Folder alongside the .ino and #include "coroutines.h"

                                My example emits bongs from 1 to 12 with 10 second intervals between each series.

                                <code>

                                #include "coroutines.h"

                                const char LED_PIN = 13;   // Arduino has an LED on Pin 13
                                const int period = 10000;  // 10 seconds
                                const int ON_TIME_ms = 100;  // Length of the ON pulse
                                const int OFF_TIME_ms = 500; // Length of the OFF pulse

                                Coroutines<1> cr;   // Create a co-routine object to handle one co-routine only.

                                long previousTime;     // Used to demonstrate
                                int  numberOfBongs = 0;

                                void setup() {
                                  // put your setup code here, to run once:
                                  pinMode( LED_PIN, OUTPUT );    // Initialise the LED output
                                  digitalWrite( LED_PIN, LOW );
                                  previousTime = millis();
                                }

                                void loop() {
                                  // put your main code here, to run repeatedly:
                                  cr.update();

                                  if ( millis() – previousTime > period )
                                  {
                                    numberOfBongs++;
                                    if ( numberOfBongs > 12 ) numberOfBongs = 0;
                                    cr.start(bongs);
                                    previousTime = millis();
                                  }
                                }

                                // Flashes the number of times set in bongCount
                                void bongs(COROUTINE_CONTEXT(coroutine))
                                {
                                    COROUTINE_LOCAL( int, n );  
                                    BEGIN_COROUTINE;
                                    n = numberOfBongs;
                                    
                                    while ( n– > 0 )
                                    {
                                      digitalWrite( LED_PIN, HIGH );
                                      coroutine.wait( ON_TIME_ms );
                                      COROUTINE_YIELD;

                                      digitalWrite( LED_PIN, LOW );
                                      coroutine.wait( OFF_TIME_ms );
                                      COROUTINE_YIELD;      
                                    }
                                    END_COROUTINE;
                                }

                                 

                                </code>

                                The Arduino Library Manager lists a coroutine library called CPPtasks. I've haven't investigated it.

                                Dave

                                Edited By SillyOldDuffer on 04/01/2018 14:03:08

                                #335298
                                SillyOldDuffer
                                Moderator
                                  @sillyoldduffer
                                  Posted by James Alford on 04/01/2018 07:21:34:

                                  What I am finding personally frustrating is that some years ago, I … and I am blowed if I can remember much at all about how I did it and have done very little like it since.

                                  James.

                                  Me too! Nowadays I spend a fair amount of time looking up stuff that was once at my fingertips. I know it's a case of 'use it or lose it' but it's really annoying to find hard learned details have slipped away. The odd thing is that the memory's not really gone at all – given the right reminders back it comes. Eventually!

                                  I try not to get permanently cross with myself. Storming off in a rage is allowed, abject surrender isn't!

                                  Dave

                                  #335350
                                  doubletop
                                  Participant
                                    @doubletop
                                    Posted by Howi on 04/01/2018 13:18:22:

                                    Bong sequence of 15 minutes? I must have been doing it wrong all this time! surprise

                                    Perhaps I need some interrupts or some longer inter-bong periods!

                                    Howi

                                    You missed the the point that the minimum is 15 secs of activity every hour. The rest is just sleeping. If you want to do more you have 15mins max before being interupted.

                                    Pete

                                    #335393
                                    James Alford
                                    Participant
                                      @jamesalford67616

                                      I thought that it might be useful to give a little more detail of my plans and code so far.

                                      Mechanics

                                      I plan for the finished device to use solenoids to operate separate displays for the seconds, minutes, hours, day of the week and day or night. Each display will be independently driven and not linked as in a conventional clock.

                                      There will be a bell of some sort to sound the quarters and another to sound each hour.

                                      I like the type of eccentric devices dreamt up Emmett and Heath Robinson and am thinking along those sort of lines for the completed clock. Hence, the seemingly unnecessary number of solenoids.

                                      Arduino

                                      I currently have the the Uno wired up to drive a number of LEDs to simulate the solenoids and a LCD clock display to allow me to set the time and check the operation of the LEDs.

                                      The LED takes its time directly from the RTC.

                                      The seconds currently use "millis" and a count of elapsed millis to flash the LED: I might change this in light of the suggestions made so far.

                                      The minutes and hours take their time directly from the relevant part of the RTC output.

                                      Day, night and the day of the week will probably be worked out by the Uno, taking the hour of the day as a starting point.

                                      The quarter strike currently works using the RTC to determine the time at which to strike. Variables, flags and elapsed millis control the number and duration of strikes.

                                      Although I could use the same basic structure for the hourly strikes, it would be unacceptably complicated and cumbersome, hence this thread.

                                      I am working on the ideas given so far to write a more effective hourly strike and shall quite possibly redo the quarter strike using the same principles.

                                      Regards,

                                      James.

                                      Edited By James Alford on 05/01/2018 07:19:24

                                      Edited By James Alford on 05/01/2018 07:19:56

                                      Edited By James Alford on 05/01/2018 07:20:37

                                      Edited By James Alford on 05/01/2018 07:21:30

                                      Edited By James Alford on 05/01/2018 07:22:21

                                      #335397
                                      doubletop
                                      Participant
                                        @doubletop
                                        Posted by James Alford on 05/01/2018 07:17:44:

                                        The LED takes its time directly from the RTC.

                                        The seconds currently use "millis" and a count of elapsed millis to flash the LED: I might change this in light of the suggestions made so far.

                                        The minutes and hours take their time directly from the relevant part of the RTC output.

                                        Day, night and the day of the week will probably be worked out by the Uno, taking the hour of the day as a starting point.

                                        James

                                        Check page 11 of the DS3231 data sheet **LINK**

                                        Day of the week is in there as address 03 value 1-7

                                        I'm not sure if where millis are derived but if it the Uno they will have no relationship to the RTC time. if you don’t want to use the 1 sec interrupt you could connect the 1sec pulse to an input and poll it changing state but that’s a horribly clumsy way of doing it.

                                        Anyway what you are proposing sounds very interesting. Standby now for an endless list of 'feature' ideas, for a start how about a cuckoo on a stepper motor drive?

                                        Pete

                                        #335407
                                        I.M. OUTAHERE
                                        Participant
                                          @i-m-outahere
                                          Posted by Geoff Theasby on 02/01/2018 09:53:45:

                                          "Debonging" what a wonderful word!

                                          Dem bongs, dem bongs, dem debongs,

                                          etc.,

                                          De mainspring is connected to the geat wheel,

                                          the great wheel is connected to the fusee,

                                          the fusee is connected to the pinion,

                                          the pinion is connected to the 'scapement,

                                          now hear de word of de bong!

                                          Geoff

                                          Wasn't that a Bob Marley song ?

                                          I heard he liked bongs too !

                                          Ian .

                                          #335421
                                          SillyOldDuffer
                                          Moderator
                                            @sillyoldduffer

                                            Like it James!

                                            The design seems sound to me. You have an accurate clock in the RTC and are only using an Arduino to drive the mechanicals. millis() is plenty accurate enough to do jingles.

                                            The Arduino Uno uses a 16MHz crystal to generate clock pulses. At first glance it has the potential to be an accurate clock on it's own. Unfortunately, there are several causes of error, such as:

                                            • On the circuit board there's no way to trim the crystal to exact frequency.
                                            • The crystal oscillator has no temperature compensation.
                                            • The crystal oscillator has a low component count – it isn't designed to optimise frequency stability.
                                            • There will be a period of jitter each time the Arduino is started.
                                            • millis() is implemented using one of the Arduino's built-in hardware timers. When the timer fires, a function is called to increment a counter. So, although the oscillator and timer have good accuracy, the time taken to update the counter, and the time taken to query it are all a little wobbly. For example, if the Arduino happens to be busy processing an interrupt when you call millis(), a slight extra delay will be added.
                                            • On top of that are the delays introduced by your processing. Not good if you're programming the Arduino to be an accurate clock

                                            Although the errors are individually tiny they accumulate to as much as 20 seconds per year. A proportion of the error amounts to a constant drift that could be compensated out in software, but you would have to spend months measuring it first. The remaining error is more-or-less random and can't be compensated.

                                            Bottom line is that a naked Arduino (or any other computer) can be used for short accurate time measurements but not for very long ones. This is such a common problem that there are many solutions to it. One of the easiest is to synchronise the Arduino to an external time reference. Mains frequency can be used, but a Real Time Clock module is better. Being purpose built as a time reference, it has none of the Arduino's timekeeping flaws. A further improvement would be to synchronise the RTC with an Internet time server, which is what PCs do. Probably the very best time could be achieved with a GPS module; these get their time from satellites fitted with atomic clocks that are in turn synchronised to high-end time references on earth.

                                            James is on the right track I think. The display time comes from an RTC which is accurate. RTC time could be improved by using interrupts but I don't think it's worth the effort in this case. The main cause of error in Jame's clock will be the solenoids because they take tens of milliseconds to activate. millis() is far more accurate than that.

                                            Please publish progress James – it's a good project with interesting challenges.

                                            Dave

                                            #335524
                                            doubletop
                                            Participant
                                              @doubletop
                                              Posted by James Alford on 05/01/2018 07:17:44:

                                              Mechanics

                                              I plan for the finished device to use solenoids to operate separate displays for the seconds, minutes, hours, day of the week and day or night. Each display will be independently driven and not linked as in a conventional clock.

                                              There will be a bell of some sort to sound the quarters and another to sound each hour.

                                              I like the type of eccentric devices dreamt up Emmett and Heath Robinson and am thinking along those sort of lines for the completed clock. Hence, the seemingly unnecessary number of solenoids.

                                              James

                                              At risk of your project being designed by committee, something for your consideration.

                                              You will have outputs driving solenoids for seconds, minutes, hours, day of the week and day or night. Have you considered how you initialise these rather than have to pre-set them by hand on start up?

                                              When a value is sent to a screen or display device it is absolute and has no relationship to the previous value. With your setup each pulse to change the display will be relative to the previous value. Can I suggest (say) a microswitch on the each of the display units at the zero or one base value and an input to the Arduino for each. On start-up pulses are sent to each display unit and the input read until the base value is reached. The RTC is then read and the correct number of pulses sent to set the displays to set the current value for seconds, minutes, hours, day of the week and day or night.

                                              In addition to this when running and any of these baseline values reached the input can be checked to see if the display is matching. If not, you just do the reset of the relevant display unit. You’ll then be able to leave the thing running and not have to manually deal with an missed pulses or temporary solenoid malfunctions

                                              I'm quite looking forward to seeing this all up and running, and more for the mechanicals rather than the electronics

                                              Pete

                                              #335561
                                              Marcus Bowman
                                              Participant
                                                @marcusbowman28936

                                                So is that a bit like what happens in a radio controlled clock, where the hands run to 1200 on startup and wait for a first time signal, then go to the appropriate time? In that kind of clock, loss of signal can result in constant cycling, so the ability to do a check, as DoubleTop suggests, is a good idea. Re-usable points of reference are always good, I think.

                                                I, too, am keen to see what evolves from this project. Sounds a lot of fun.

                                                Marcus

                                                #335585
                                                James Alford
                                                Participant
                                                  @jamesalford67616

                                                  Marcus,

                                                  Thank you for the suggestion about setting the device at start up. I had only thought along the lines of setting it manually, like a conventional clock. I shall have a mull over of your idea.

                                                  I shall happily post details of the actual build when I get to it. I have a current project, a sculpture of a dragon in copper, that I am determined to complete before embarking upon anything else: I have started and not finished too many things in the past. It is taking for ever as each scale takes up to ten minutes to attach and there are over five hundred scales on it so far and probably as many to go….

                                                  Please excuse the expired lump of BMW engine in the corner and second one under the blue tarpaulin: my son's debris.

                                                  dragon front.jpg

                                                  tail.jpg

                                                   

                                                  Edited By James Alford on 06/01/2018 10:46:48

                                                  Edited By James Alford on 06/01/2018 10:48:00

                                                  #335587
                                                  John Haine
                                                  Participant
                                                    @johnhaine32865

                                                    I believe, based on a dim memory of a student's project, that lightweight Arduino code is available to implement an NTP client. That would allow you to make occasional time updates by querying a remote NTP server such as operated by NPL. You would of course need an internet connection.

                                                    #335666
                                                    James Alford
                                                    Participant
                                                      @jamesalford67616

                                                      Good morning.

                                                      A quick update: thank you for all of the help so far with my coding questions. I have now managed to get an LED to pulse on briefly, pause for a longer period and then repeat each hour, the number of pulses matching the hour of day. I have also set it so that it only starts once the quarters have finished chiming and disabled both the quarter chimes and hourly chimes overnight.

                                                      Next stage: programme an output for the days.

                                                      Regards,

                                                      James.

                                                    Viewing 25 posts - 26 through 50 (of 86 total)
                                                    • Please log in to reply to this topic. Registering is free and easy using the links on the menu at the top of this page.

                                                    Advert

                                                    Latest Replies

                                                    Viewing 25 topics - 1 through 25 (of 25 total)
                                                    Viewing 25 topics - 1 through 25 (of 25 total)

                                                    View full reply list.

                                                    Advert

                                                    Newsletter Sign-up