The purpose of the Process Duration Timer (PDT) is to provide a means to set up an experiment and time a process, whether it is the discharging of a battery, the discharging of a capacitor or some other process that one does not want to sit around and watch. The PDT allows the experimenter to set up the experiment and walk away. The PDT watches the voltages and pushes the button on the stop watch the second that the process voltage crosses the target goal.

 

In the last three blogs we have built the power supply, the clock circuit , and the interfaces have been designed and bread boarded. Today we will work with the Arduino.

 

All I need at this point to hook things together and test the PDT idea to see if it will work is a properly programmed Arduino. A couple years ago I built a multiple unit project using the Arduino Duemilanove and since I still have several of these boards, this will be the board that I will try to program. I say try to program as this is the part of this project that I am the least comfortable with.

 

I always begin a programming project with a flow chart that takes me on a step by step path through the logic of what I want to do. As you will see the logic needed for this project is very straight forward and even I should be able to program it.

 

Here is a list of the flow chart:

 

Initialize the Timer so that it resets to 00:00:00

Begin Program Loop

     Begin sub loop

          Read the analog pin for the Test Voltage

          Repeat this process 10 times

          Sum the individual readings

          Exit the sub loop

     Divide summed value of Test Voltage by 10 and Store

     Begin sub loop

          Read the analog pin for the Target Voltage

          Repeat this process 10 times

          Sum the individual readings

          Exit the sub loop

     Divide summed value of Target Voltage by 10 and Store

     Test to see if the Test Voltage is lower than the Target voltage

     If "No" start Main loop again

     If "Yes" do the following:

          Turn on the Clock suspend timing relay

          Begin a Sub loop with no logical exit.

 

I got out my arduino programming books, I booted up the Arduino website and got out my notes from previous efforts to program the Arduino. Because it was a very simple program it wasn't long before I had something put together. I also added the ability to print my analog pin readings to the computer monitor so that during the Proof of Concept test I would be able to watch the numbers that would be used by the Arduino to represent my voltage levels. Here is the program that I came up with:

 

/* Program to Zero a clock and then begin reading the voltage from a Test Voltage and comparing
it to a Target Voltage. If the Target Voltage exceeds the Test Voltage the Pin 12 is pulled 
which stops the clock */


const int CLOCK = 10;        // assign the Clock reset function to Pin 10
const int SUSP = 12;          // assign the Suspend function to Pin 12
const int TEST = 0;          // Assign TEST to Analog 0
const int TARGET = 1;        // Assign TARGET to Analog 1
int valtest = 0;
int valtarg = 0;
int vte = 0;
int vta = 0;                // initialize the variables


void setup()
{
  Serial.begin(9600);
  pinMode(CLOCK,OUTPUT);
  pinMode(SUSP, OUTPUT);
  digitalWrite(SUSP,LOW);
  digitalWrite(CLOCK,LOW);
  delay(2000);
  digitalWrite(CLOCK,HIGH);
}


void loop()
{
  vte = 0;
  for(int x=0; x<10; x++)
  {
    valtest=analogRead(TEST);
    vte=vte+valtest;
  }
  valtest = vte/10;
  
  vta = 0;
  for ( int x=0; x<10; x++)
  {
    valtarg = analogRead(TARGET);
    vta = vta + valtarg;
  }
  valtarg = vta/10 ;
  
  Serial.print("Test Voltage:   ");
  Serial.print(valtest);
  Serial.print("     Target Voltage:   ");
  Serial.println(valtarg);
  delay(2000);
  
  if (valtarg > valtest)
  {
    digitalWrite(SUSP,HIGH);
    while(valtarg = valtarg)
    {
      delay(1000);
    }
  }
}

 

This program works but it probably could use some polish. Ideas and suggestions are welcome. I have only improved my knowledge on this site thanks to the great ideas and suggestions for improvement offered to me by my fellow members.

 

Now that I had a programmed Arduino I used my bread boarded interface circuits to put together a working prototype that I could test to see if the Arduino would accept the voltages and make the correct decisions with respect to controlling the clock. Here is a short video of the proof of concept test.

 

 

 

Now that I have a working prototype the next project will be to build the interfaces onto a shield that will mount to the Arduino and then connect it up to the rest of the systems. In the mean time I have completed the mechanics of mounting the switches, Clock and input jacks to the project enclosure. Here are a few pictures of the progress to date:

 

IMG_1527.JPG

 

IMG_1531.JPG

 

IMG_1533.JPG

 

IMG_1538.JPG

As you may have noticed in the second picture above the strain relief I was using was on the mains cord was not conventional nor adequate. I have since rectified this problem with a more sturdy and conventional anchor.

 

In the next and final Blog the interface shield will be built and wired into the system. The wiring will be completed to the switches and controls and I will make a video of the unit in operation.

 

John

 

https://www.element14.com/community/people/jw0752/blog/2017/08/08/process-duration-timer-final-chapter-assembly-and-testing