Friday, December 19, 2014

'State' Programming

An interesting thing thing happened to me. I viewed a description of a system which had a 'state machine' description. To be clear this is description of a system which remains in a particular 'state' until specific 'inputs' or conditions occur.

This happened to be a description of transitions between states of MODEM transmissions.

But it inspired in me the vision that a state machine, not a continuous system, could be viewed as a 'current state' then 'what is required to transition to the next state'  logic situation.

What does using the 'state machine' design philosophy mean in a real-world situation? Of course you enumerate the output devices and the input devices for the system. But then we will temporarily forget them.

Let's say at one point in the operation a section is extended by operating a solenoid until a switch is made. For this 'state' write down 'Extend part A until it is fully extended'. Name this statement 'Extending part A'. You have these parts: the name of the state, an action which is taking place, the condition to end the state and begin doing something else. Continue writing down the states required to perform your process without referring to specific input or output devices.

Other sections of your 'state' descriptions are those required from a power-up start and those required to perform an orderly shutdown.

If you find that a 'state' has multiple things happening the you probably haven't broken it down far enough. It is possible to have multiple states operating at the same time - in parallel. These states may refer to each other for their ending conditions.

We have a machine with multiple sections operating on parts. Each of these section have states working through their operations. When all the section have reached the 'end' state then another series of states is triggered to transfer each part to its next section. Some states during this transfer provide operations on the parts. When it is done the individual section beginning 'states' are again triggered.

I encountered this in the next employment situation.

Because of the then current high cost of PLC systems they had designed their own single-board control systems.

This was based on the 6800 Motorola processor. I reviewed the instruction set available to this processor and the I/O structure they had designed. I was able to find a failure in a system due to an uninitialized variable. I was assigned a job repairing controller boards. But these soon became less competitive due to the dropping prices of PLCs.

Using Allen Bradley PLCs I was able to implement the 'state machine' philosophy of control. But the company needed a yet more cost effective control system. I was able to recommend that the the company change to the PLCs made by AutomationDirect. They provided a more direct method of implementing the 'state machine' design using their RLL Plus version of 'Stage' programming.

Friday, November 28, 2014

A Different PLC !!!

I'm taking a break from the historical narrative. One reason is that I am still working for the company I moved to as mentioned at the end of the previous post (over 30 years now) and feel that I would unfairly edit my posts. But I'm near retirement, so the updates won't be long in coming And I will try to update more often.

Over my career using PLCs (and I must say, I didn't PLAN it, it just kind of fell in to place) I have dealt with many different manufacturer's PLCs. The first major shock to any PLC programmer is not the learning of the first PLC but, when confronted with the next PLC realizing that they are DIFFERENT!

So let's discuss items which appear common to PLCs:

They accept 'Inputs', which is data from an outside source. This may be 'discrete' (On/Off) or 'analog' (a value within a range of numbers which reflects the level of a continuous measurement). The 'analog' or numeric information may also represent 'text' or other information. 'Analog' will be used to refer to any information represented by more than one 'bit'. The information may come from local hardware or from remote hardware via some sort of communication.

The 'Inputs' are referred to by a variety of names and stored in various formats. The important thing is, while you must understand how the current PLC references or stores this information, you must not get obsessed that this must be the ONLY way that this information can be referenced or stored.

In like manner 'Outputs' is data sent to an outside location. Again this can be discrete or analog information. It may be sent to local or remote locations. Remember the same warning about being obsessed over the naming or storage.

Next there is information stored 'Locally'. This, again, may be discrete or analog. This is information stored from current or previous states in the PLC. It is useful, when combined with future 'inputs' to generate useful 'outputs'. As in the case of the other two categories, do not develop an extreme affection for one particular nomenclature or method of storage.

Next there is the programming 'language'. In general the programming language provides a structure for transforming current 'Inputs' and 'Local' information into new 'Local' information and/or 'Outputs'. Prepare to be open to different languages.

In conjunction with the 'language' are the available 'instructions'. These are the individual operations which may be performed to implement the 'transformation' I mentioned in the previous paragraph.

You may wonder why I didn't include 'Timers' and 'Counters' in the 'Local' information. In the PLCs I've used most of the 'Counters' and 'Timers' are instructions which interact with stored data to provide their function.

In a very few instances there are separate hardware timing or counting functions which operate external to the particular language or instructions. These are typically more accurate and provide a more precise function than the 'instruction type' timers and counters. These must be dealt with on a PLC-by-PLC basis. Learn how to read manuals.

Why am I being so general in my descriptions? As a programmer you MUST remain flexible. When confronted with a new PLC you need to identify the various areas I have outlined. You must review the language and the instructions. Read about EVERY instruction, even if you don't think it will be needed for the current project. Review any 'help' information including that provided by the PLC manufacturer's web site.

Please, don't be one of those who can ONLY learn with videos (I see more of them claiming to have this limitation all the time.) You must be open to all forms of information about a new PLC. You must use your imagination and THINK !!

In the meantime look for "BeBop To The Boolean Boogie". I kid you not. This is an excellent reference (both in hardware and in general computer thought processes for the PLC programmer.

More on adapting to new PLCs in the next post. (Thanksgiving weekend - 2014)

Saturday, September 1, 2012

Electronics Developments

During college and my time in the Air Force I was aware of developments but just barely. I did not subscribe to the electronics magazines. The applicable world of consumer electronics appeared to be stereo audio, television and Citizen's Band radios.

But late in my enlistment a new development was taking place which I was in danger of totally missing. New large scale integrated circuits were making possible small computers. I saw some information about them but, like many others, thought 'why would you need a computer'?

A fellow instructor was dabbling in them and had received a kit ... putting his own computer together! I almost gave a patronizing laugh. But I was intrigued a little and bought a book on Microprocessors just to get a small taste of the field.

My enlistment in the Air Force ended and I move back to my hometown, not sure what I was going to do but it seemed that continuing in Electronics was the logical thing to do. While I was still searching for a job and had answered many newspaper solicitations I received a letter from a recruiter for General Dynamics in Fort Worth, Texas. It seemed that he had been in the Seattle area interviewing applicants and had thought, in response to one of my applications, he could just drive to Yakima, thinking it was a Seattle suburb, for the interview. But seeing it was a couple hours and a mountain pass away he had decided to just follow up with a letter, so I called him. They made arrangements for airline tickets to Fort Worth so that I could interview at the plant.

I flew to Fort Worth. They had almost a production line to deal with finalizing applications and doing interviews. My experience in the Air Force was almost exactly what they were looking for and the interviewer was becoming excited. The job would be teaching the use of test equipment for the new F-16 aircraft. This was nearly a copy of my teaching in the Systems School for the F-111 aircraft.

'Almost' ... 'nearly'. Then he asked the question, what background did I have in computers? The test stations I had taught in the Air Force had manual settings or at best paper tape controlled setups. There were no computerized test stations. I mentioned that a fellow instructor had been using a home built one. The interviewer said that doing that would have been a perfect background. If I had done that I would have been hired on the spot. I was disappointed but I was taken for a tour of the F-16 plant, an incredible time. But on my flight back home I realized what I was missing out on. You don't have to hit me twice between the eyes to get my attention.

Radio Shack was bringing out a small home computer, the TRS80. I bought one and was on my way learning BASIC, Assembly Language and Pascal, three programming 'languages' available for this computer. While BASIC and Pascal were higher level languages, Assembly Language required a more in-depth knowledge of the actual microprocessor (the central computing chip), the electronic schematic of the complete computer and an understanding of the supplied operating system program. I delved into manuals and printouts of programs. I modified the circuitry of the TRS80 to provide additional capabilities.

While my first job for an electronics distributor didn't involve computers, either large or small, I learned more about the organization of the business of consumer electronics. Part of the time I was in "shipping - receiving". But all the time I was studying my small computer at home. (I had married and my wife didn't think too much about "that damn box" but she learned that it was important to be so she lived with it.)

My second job was with a machine builder. While I was primarily doing wiring and troubleshooting I also got to help with the small electronic process controllers the company built from small - though not microprocessor - chips. I learned a lot about signal timing and the flow of information. I helped when a change was needed to the circuitry. I determined that it could be solved, temporarily until a new circuit board could be designed, by another chip being soldered on top of a similar chip, though with some of its pins being wired differently.

We were also using a "5TI Sequencer" from Texas Instruments, basically a fairly large (physically) PLC. I was allowed to read - but not touch - the program. At that point the program was hand drawn like other electronic diagrams (no Autocad yet) and a new program (or modifications) were entered, one step at a time, with a 'large calculator looking' device with a keyboard and flashing LEDs. We did have a tape backup unit which was used to load a program when it was an identical copy of a previous one saving a lot of time.

After marveling at the 'ladder diagram' which documented the logic of the program I asked what all the 'capacitors' were for, since the logical symbols used in the 'ladder diagram' resembled the electronic symbols for capacitors. That generated a great laugh from everyone but me wondering what I had said. Finally, on a field trip to a plant I had the temerity to call back and suggest a modification to the program, just one contact, which I thought might help. I was allowed to perform the modification and the synchronization between two sections of the machine became much better. I was hooked.

The company was developing plans for a new computerized controller for the machine but I was to have no part in its development or use. I was on the road about 50 percent of the time while my family was growing up without me. It was time for a move.

Thursday, February 23, 2012

Systems School

I had just (it seemed) been through this school and now I was re-joining it as an instructor. I had been taught about forms of voice radio (VHF and UHF frequencies). navigation (TACAN and Inertial Navigation) approach control (ILS), and radar identification (IFF). Now I was to teach these subjects.

My first assignments were to reacquaint myself with the materials to get ready to teach these subjects. I thought back to the remark by my fellow students that I would never succeed because I had no 'war stories' to tell.
I was among instructors who had years invested in teaching this material but it seemed, without anything against them, that they were mostly just presenting the same old information. I had been through this and I didn't get any enthusiasm for the subjects. Now this is fairly hard to imagine in these dry electronic subjects but it seemed that enthusiasm is just what was missing.

I had already introduced, in Fundamental Electronics, a glimpse of my instructor style. I had presented the 'Mary Circuit'. A particular circuit in digital electronics (named the Exclusive-OR or XOR circuit) which receives two inputs, each of which can be ON or OFF. The output of this circuit is ON only if ONE, and only ONE of the two inputs is ON.

So I had introduced the 'Mary Circuit' - Mary has accepted an invitation to the prom. In fact she had accepted invitations from two different boys, Joe and Tom. Now it is 'Prom Night' and Mary is up in her room. Does she go down to the front door if no one is there? No. Does she go down to the door if just Joe is there? Sure. Does she go down to the front door if just Tom is there? Sure. Does she go down if both Joe AND Tom are there? Noooo!!! Thus the Mary Circuit.

So I received inquiries in Systems School about this 'Mary Circuit'. They were very literal and not very receptive of innovations. This would change.

The navigational signal presented by a TACAN (Tactical Air Navigation) antenna was very complex. It provided, in one signal, both direction and distance information to any aircraft which utilized its signal. The signal presented one indication when its rotating signal pointed East, with additional signals which indicated how far from East it had moved. Simultaneously it presented information to an aircraft how far away from the antenna the aircraft was. Obviously this was a very complex signal.

But this signal was to be taught with a few diagrams in a workbook. This was unacceptable. I, instead, had students in front of the class, spinning with an flashlight pointing out toward the class, another flashlight pointing upward and emitting 'beep' sounds when pointing in a particular direction. The students, after many hilarious minutes, came to understand how they could determine their relative bearing from the antenna (student wielding the flashlights) by listening to the beeps and watching the rotating flashlight. Similarly they could determine their distance from the antenna/student by listening to the pattern of other beeps.

The understanding of this signal was allowed, in the official teaching guide, a full day for presentation. In one hour my students could not only identify the different components of the signal but their importance in providing the information intended. In fact other classes, composed of cross-training older students, asked specifically for me to present the class. 'Students' older than me ended the presentation in laughter but also with full understanding of the subject matter.

Some of the components of teaching - engagement of the students, the importance of humor in attracting attention - which I had learned in my college classes - came to full use in these classes.

At some future time I may relate my use of the 'Official Invisible Air Force Bowling Ball' in teaching the principles of inertial navigation.

Sunday, March 20, 2011


Fundamental Electronics ('Funsies' as we sometime referred to it), as I noted before, is a "Modular, Self-Paced" teaching environment. But it looks a lot different from an instructor's side than from the student side.

A new class is typically made up of students just out of high school. There were usually ten or twelve students. Most were only about four years younger than me. I was a E-2 rank. I had one whole stripe on my sleeve. The rank's name is 'Airman'. But the Air Force, to encourage longer enlistments, was granting to those who signed up for 6 years a rank of E-3 (two stripes - 'Airman First Class') right out of Basic Training. So some some of  the young students already out-ranked me.

The highest ranked student in each class became the 'class leader' and performed various leadership duties. Occasionally higher ranking Air Force members would 'cross-train' from their current job into another, beginning their instruction at the Fundamental level. I had one class where a 5 stripe sergeant was a student and was therefore the 'class leader'. In this particular class one of the young 'Airman First Class' was attempting to exert what they perceived as a rank advantage over me, the instructor. To say the least I wasn't very proficient at exerting my own authority at this early point.

The 'class leader' came to me and suggested that I might want to go get a coffee for a few minutes. I thanked him and stepped out but only far enough that I could still hear what went on. The sergeant then proceeded to make it very clear - in a surprisingly normal tone of voice - that 'that badge' (he was referring to the 'Instructor' badge I wore) made me the highest rank in the class and if the 'Airman First Class' had a problem with that they could discuss it outside. When I came back from my 'coffee break' I stepped into a very calm class. I gave the 'class leader' a discreet thankful nod. I had a lot to learn myself.

The students would receive a study manual which had text, pictures, study questions, practical equipment exercises and quizzes based on the hardware exercises. As they mastered the work in the manual they would take a proficiency test, in a separate testing area, then progress to the next manual.

The 'instructor' in Fundamentals managed the paperwork for each student, kept class statistics and helped each student as they progressed, answering questions and helping with misunderstandings. In the early few days of a class most of the students were on the same manuals so it wasn't too difficult to keep things straight. But as better student finished more rapidly and surged ahead in their manuals the class would become fragmented in what they were studying. There was less opportunity to address class problems as a whole.

This became even worse as the students advanced past very basic electronics. The students were preparing for different specialties. These would require different sets of knowledge at the basic level. If a specialty did not require knowledge of a subject - for example “lasers” - they would not receive that manual but would receive others that they needed. So a class became even more fragmented and the instructor was answering an even wider variety of questions. It was like a rapid-fire version of Jeopardy with ten subjects at the same time.

It had been found that, relying on the aptitude tests given before enlistment, the 'Reading Ability' pre-test came out ahead as a predictor of success in learning Electronics over scores on the the 'Electronics' test. But even with preliminary testing the predicted ability didn't always show itself. We had one student who, by pure memorization, finished each of the tests with barely a passing score. He was 'progressing' but it was increasingly apparent that he lacked actual understanding of the subject and was becoming more and more despondent over this situation. He did not give up but he had to work twice as hard as the other students just to achieve this level.

He had been with a few different instructors so we got together and discussed him and his progress. We then took the matter up with our supervisors. Even though he was 'technically' passing we urged that something be done to help him. There was no way he would be happy or productive in the Electronics field. Our supervisor called him in and talked about his progress listening to his level of enjoyment for the course. He was then reassigned to another skill field, with no negative mark whatsoever. We later received a letter from him expressing his delight in his new assignment (something very different than Electronics.) We couldn't be happier for a student who couldn't make it through our classes. We felt that we had properly applied another aspect of being an 'instructor'.

Being an Air Force Electronics instructor was more-or-less an eight hour a day, five day a week job (more on this later). At times we would be relieved of one class, which had fragmented in their studies enough to be grouped together in other classes with students in similar areas of instruction. A number of students had also failed to make the grade (even though their 'Electronics' pre-tests had predicted great aptitude). So at times we were between classes. We were given duties such as reviewing training materials and tests for updating and special instruction for students having specific problems. (I mentioned this near the end of my Instructor Training post.)

While I was 'between classes' my supervisor, a Master Sergeant, said to me at the end of a Friday “See you Tuesday”. I was confused. Was there a holiday on Monday I didn't know about? But luckily another instructor grabbed me. He said that that was my supervisor's method of giving an 'extra day off'. He said that my supervisor knew exactly what he had said, there was no holiday and if I go back in to ask he will correct it to “See you Monday” thus losing that day off. Interesting times.

After one and one half years of teaching in the Fundamental Electronics school I was re-assigned to the Systems School.

Saturday, March 5, 2011

Instructor School

I began my career as an Electronics Instructor by sitting in on the same 'Fundamental Electronics' classes that I had graduated from some months before. But this time I would have to be proficient in all the materials taught in the Fundamental Electronics School, not just the areas I had taken as a student. So about one third of the classes were totally new. I did this until the Basic Instructor Course opened up. So I sat in with students, doing the practical exercises, reading the same training materials and taking the same tests (except as an Instructor I had to take all the various forms of the tests which had different questions). I had to pass the tests with a 'missing only one at most' score. Obviously an Instructor should have a grasp of the material that they can easily pass all the tests.

I was excited when the Basic Instructor Course opened up. I reported to the training building and found that I was the lowest ranking individual in the class. There were even officers there each taking the same course Basic Instruction. There were also civilians who would be teaching Air Force courses (primarily in the Accounting and Procurement areas). My trepidation at being with OFFICERS was quickly lessened as we each introduced ourselves. Since the class was being lead by an upper-ranking sergeant it was like a buffer between our ranks. We always addressed each other with the proper rank (or 'Mr' or 'Mrs' for the civilian students). There were only about ten students in the class so at times it became somewhat informal but we were always careful not to cross lines.

In college, one of my Psychology courses was 'Psychology of Instruction' which covered methods of preparation and presentation of materials in different situations. It also covered various forms of measurement of progress and ranking of students. I had liked that course.

So here I was in the Air Force learning its methods of preparation and presentation of instruction and it turned out to follow the techniques I had learned in college. We learned about the basic concept of instruction - 'You are not a mind reader!'. The desired outcome of instruction was always in terms of directly observable behavior. There was none of the 'the student should understand ...' stuff. The final result had to be in terms of behavior we would observe. 'What does the student actually do that makes you satisfied that they have mastered the subject?'

As part of 'teaching a physical skill' I gave a presentation on changing a broken string on a guitar. I had sat in my apartment working out EXACTLY the steps and checks on changing a string. Before my presentation I had placed an old string on my guitar and started the presentation with the opening ... "You are at Carnegie Hall preparing to give the performance of your life when ..." (and I pulled on the string breaking it - I had worried that it would whip back and cut me but that didn't happen.) The presentation went well.

In another presentation which was to be a pure lecture format it had been emphasized that we had to take into account the background of our audience/students. I began with a fairly complex presentation when, as expected, it appeared that the students (my fellow instructor students) were not following. I gave a feigned frustrated sigh and ripped up my notes. I got an audible 'gasp' from the others then launched into the simpler presentation I had prepared which followed the format that we were expected to give.

After my presentation, which went over well, the instructor asked why I had done what I did. I noted that, following the background of the audience, I knew I would capture the best attention if it appeared, at first, that I was utterly failing in my presentation. He remarked that no one had done that before. I grinned.
The final test of the Basic Instructor School was to give actual face-to-face instruction to real students. But, as I had mentioned in an earlier posting, the presentation in the Fundamental Electronics Course was of individual student learning from training materials, often with many in the class on totally different areas. The only face-to-face instruction was with students who had worked through a subject area but had failed the test for that area. They then had to take 'Remedial Instruction' which often took place in any old empty classroom.

The students, who could be from a very wide assortment of the training areas, brought their training manuals. It was up to the 'Remedial Instructor' to determine individually what area each student had been studying and which concepts in that area they had failed to grasp. The 'Remedial Instructor' had to instantly give a presentation for each student clarifying the areas they missed. I did this over the course of one hour for three students.

After the 'Remedial Instruction' class I met with teaching instructor. He was amazed. The usual class preparation which should take hours had been compressed into mere minutes. And even though he had not studied the area of Electronics I had presented he said that he understood it very well from my quick instruction. I grinned again. I was an Air Force Electronics Instructor.

Sunday, January 2, 2011

Systems Training

Once done with the Fundamentals of Electronics, and my leave to visit home, I entered into the 'Systems' part of my training. My training was in the area (as designated at the time) '326X1B'. The 'X' in the code was replaced by a numeral relating to the level of advancement in the area.

The training specifically was titled "Integrated Avionics Component Specialist". The training was on Communication, Navigation and Identification systems on the FB-111 aircraft referred to as the 'Aardvark'. It was a sweep-wing fighter-bomber. There is a Wikipedia entry if you are curious. Even as I was undergoing training, there were those who could cite all the various differences between the many variants of this aircraft. In short, I didn't know and unless it was relevant, I didn't care.

The 'Systems' training used the fundamentals we had learned to build an understanding of the various units on the aircraft we were to maintain. There were voice communications which had various ways of establishing frequencies and operations. There were navigation units, one which sampled various air pressures to result in readouts for true airspeed and other calculations. Another which received transmissions from radio stations to establish the position and speed of the aircraft. Finally identifications units (ominously named 'Identify Friend or Foe') which responded to radar sweeps with information coded in numbers which identified the aircraft.

These were very interesting classes as they ranged from pure analog (the 'air data computer' using chains, gears, and 3D cams to calculate its results) to purely digital (the derivation of the codes sent back by the identification equipment). The digital electronics were of mid-1960's technology (I was receiving this training in 1973). The digital logic was in 'flat packs' incorporating multiple AND and OR gates.

Again I was surprised that the training was so logically built on previous instruction that the concepts came easily. I had no problem with these classes. The best part was the mid instruction break each day. The Airman's Club was right next door and we could get a good cup of coffee and doughnuts to pick up our mornings.

Near the end of instruction a curious request was made of us (in a military service most 'requests' are 'orders' but this wasn't.) As far as I understand there were many Electronics instructors who were rapidly approaching retirement or end of enlistment and insufficient preparation had been made for their replacements. The request was of those who were placed highest in their classes to become 'Instructors'. We were informed by classmates that this could never work because, as opposed to instructors who had come from years of line operations, we would have no 'war stories' to tell to fill odd moments of our instruction. I said 'yes'.