V7 Chapter 50

Its a blog - Read from the bottom up


296. State Machine - 2013-08-16

This organization works correctly. The pixel will run continuously and will restart the shield when it fails to read the navigation messages or an event within a specific time period. It also recovers when it cannot post the event to the server within a certain time period.

The Dead Man time (below) did work but was found to be unnecessary after inclusion of the Time Out timer in states 2,3 and 4.

295. Arduino Dead Man Timer - 2013-08-14

The ERGO Project is using a variation of the standard Arduino Mega as the base machine for the pixel. This little computer must run on its own through power outages, internet breakdowns, software glitches, and hardware failures of all kinds. Tall order - yes it is. I just wish I could write code that was as smart as is needed for that kind of reliability. I can't. But I can do that next best thing - find ways to restart the whole system when things go wrong. That is the job of a Dead Man Timer.

The timer will run without disturbing the operation of the EtherMega during normal operation. The only thing it needs is a 'pump up' once in a while to let it know that the Arduino code is running along and thinking fondly of it. If the Dead Man misses a pump up for more than 2 minutes it will give up and reset the Arduino from scratch. A do over.

This is the current version of the hardware:


  1. On the left side the input to the inverter is connected to any available digital I/O pin on the Arduino. I use I/O pin 29 on the EtherMega

  2. A positive pulse is generated in software by toggling this digital pin. This is the 'pump up' signal to keep the timer running

  3. The invert of this pulse causes Q2 to dump any charge built up in C2 AND start a time out period running in IC1-1 (a 556 dual timer).

  4. Each pump up pulse discharges Q2 and retriggers the timer IC1-1.

  5. If the pump up pulse is delayed longer than the time constant of C2 and R2 the timer will time out and deliver a positive pulse to C5.

  6. The part of the pulse that makes it through C5 causes the second timer to produce a positive pulse of duration set by R6/C3. On the order of 300 msec.

  7. This pulse is inverted and applied to the reset pin of the Arduino.

294. Resetting Your Com Ports - 2013-08-06

Do you ever wonder why when you plug in a Serial/USB cable you get assigned Com16 or some other large number. It could be that your USB system has assigned but failed to release a large number of ports along the way. Want a Do Over? This is how.

Notice: Modifying your system registry is not for the faint of heart and may result in a dead operating system

  • Start RegEdit32

  • Find your way to: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\COM Name Arbiter

  • Notice the ComDB it shows all the com ports assigned. Read it left to right for the first eight ports, second set of eight, third set and so on. For example my current set up is: FC FF 01 00 00 ... 00. The FC is the first set of eight ports. Hex FC = 1111 1100 Which decodes (right to left) as Coms 3,4,5,6,7,8. Hex FF is Coms 9,10,11,12,13,14,15,16 and the Hex 01 is Com 17.

  • Your do over would be to reset it to Hex 03 Which would be Coms 1 & 2 only.

If you simply want to change the port number assigned to one of the serial port do this:

Control Panel > Device Manager > Ports (COM & LPT) >Right Click the port you want to change>Properties>Port Settings>Advanced>COM Port Number.

Change the drop down to what you would like. Ports marked (in use) can be cleared by the procedure above.

293. State Machine - 2013-08-01

This layout runs much smoother and seems faster as well. Notice that in state 4 the event wont fire unless there is a 3D fix. State 4 also allows the two NAV messages to update their parameters so that the event, when sent to the server, has the latest lat/lon & height as well as the rise time of the event.

The Arduino code is available on www.GITHub.com (Search for ERGO-Telescope).

292. State Machine - 2013-04-20

I was able to move the code that worked on the original Ethernet Arduino into the new EtherMega without a lot of drama and can connect to the secure server and send event data correctly. Now its time to go back over the code and rationalize it. A lot of it is a hack that needs work.

The first project is to get a state machine running in the code with fallback processes and error recovery as much as possible. Since there is no operating system there is no automatic exception handling or the ability to raise errors.

This is the first shot at it:

291. Board Selection - 2013-04-

After going through every known variation of Arduino (or so it seemed) and discarding them all for one reason or another I have finally settled on one version for the long run. This is the EtherMegafrom freetronics.

So the key for this project is:

  • Wiznet Ethernet - Compatible with the library of internet client/server software

  • Mega 2560 - 256 K of memory

  • Onboard SD card - Store pixel data

  • Arduino shield compatible headers - To connect the ERGO detector without fuss

It does require a change in the connection to the shield to use the EtherMega UART for SERIAL1