Electronic Counter Screens, Options, and Connectors

(article continued from previous page)

The electronic counter can count analog or digital pulses on one or two sensors, display the running total on a screen, and automatically start or stop a DC motor based on a user-configurable count. The counter was designed for versatility because the desired sensor types and test apparatus were unknown in advance.

If the operation of this specific device is not of interest to you, skip to the next page to learn about how a rotary encoder works.

Front view of the BroMatic 2000 electronic counter showing the pushbuttons and dial.

Front view of the BroMatic 2000 electronic counter showing the pushbuttons and dial.

The front of the device contains:

Because the functions of the Adjust Button and Adjust Dial change from screen to screen, the OLED display usually has text to indicate what the controls affect in the current context.

Welcome Screen

Counter v1.0. January 18, 2008.

Counter v1.0. January 18, 2008.

At startup, the welcome screen shows the version number and last revision date. Pressing the “Next Screen” button goes to the main counter screen.

The display is a gorgeous 16-character by 2-line organic light emitting diode (OLED) module manufactured by Winstar. It operates on 5 V and uses the standard LCD 14-pin interface and protocol. However, unlike an LCD, this display does not need a backlight since each pixel is a tiny LED.

The 16x2 OLED display module was purchased on eBay for about $25 with shipping. A 20x2 OLED display module is also available, but would be too long to fit in the project box with a button and dial on the ends.

Counter Screen

Counter: 100010. AutoStop: 100000.

Counter: 100010. AutoStop: 100000.

This is the main counter screen. The first line displays the current count. It can go up to almost 10 million (9,999,999).

If the Motor Control Switch is in the “Off” or “On” positions, the AutoStop value is ignored. However, if the Motor Control Switch is in the “Auto” position, and the Counter is less than AutoStop, the motor will be turned on. If the Counter is greater than or equal to AutoStop, the motor will be turned off.

Here’s the coolest part of the Counter and AutoStop features: they operate regardless of what screen you’re viewing. So, you can switch to other screens and the counter will continue to keep track of the count, and AutoStop will stop the motor as instructed.

By default at power up, the Counter is set to AutoStop+10 to prevent the motor from turning on unexpectedly. I tried setting it to AutoStop+0 at power up, but sometimes an encoder is balanced between two values (sometimes falling backwards), which would cause the motor to kick in suddenly. I felt +10 was an adequate safety margin.

Pressing the red Adjust Button clears the counter. If the Motor Switch is in the “Auto” position and the AutoStop value is greater than 0, the motor turns on. The count increments based on the motor sensors, until, at some point, the Counter value exceeds AutoStop and the motor is turned off. In this way, an Adjust Button press can start each automatic cycle.

Due to momentum, the motor continues to spin a bit after AutoStop disconnects power from it. Of course, a moderately loaded motor is unlikely to spin very far. In any case, the AutoStop value should be set below the final desired count.

On this screen, the Adjust Dial increments or decrements the value of the counter, depending on the direction that the Adjust Dial is turned. This allows the user to tweak the value of the counter, if desired.

AutoStop Screen

<-+-1000 Adj->. AutoStop: 100000

←±1000 Adj→. AutoStop: 100000

This screen is the first chance I had to electronically label the functions of the Adjust Button and Adjust Dial. The arrows and the plus-minus symbol did not come with the built-in character set. But, the LCD allows 4 or 8 custom characters to be defined in display RAM.

This screen is where the AutoStop value can be adjusted using the Adjust Dial. Holding down the red Adjust Button while turning the Adjust Dial will increment/decrement by 1000. Otherwise, it would take too long to crank on the Adjust Dial to change by a large value.

The AutoStop value is saved to the EEPROM to preserve the number after the device’s power is turned off. However, the EEPROM is not written until 30 seconds after the last change. Otherwise, each flick of the dial would write to the EEPROM -- eventually wearing it out.

Motor Control Screen

Auto (off) Adj->. Motor Speed: 100%

Auto (off) Adj→. Motor Speed: 100%

The top-left portion of the screen shows the current position of the Motor Control switch. The possible values are:

The bottom line on the screen shows the motor speed as controlled by PWM (pulse-width modulation). Using the Adjust Dial, this can be changed from 0% to100% in 0.39% steps (100/255). This non-integer step amount means multiple clicks of the Adjust Dial are sometimes needed to change the value (say from 99.61 to 98.83), even though the screen only has room to display the values of 99% and 98%.

The actual motor speed is not going to correlate linearly to the displayed value. For example, although a motor speed setting of 50% will certainly be slower than 100%, a speed of 10% may be so slow that cheaper or heavily-loaded motors won’t move at all.

The selected Motor Speed is saved to the EEPROM 30 seconds after the last change. Of course, if you power off before then, the old value in the EEPROM will be retained.

The frequency of the pulse-width modulator is 2250 Hz. This is pretty low and will cause some audible whining is some motors. However, higher frequencies may not be supported by cheaper motors.

Sensor Voltages

Sensors. A:5.00V B:5.00V

Sensors. A:5.00V B:5.00V

This screen shows the current voltages of both sensors regardless of whether the device is in analog or digital mode. This is useful for debugging and diagnosing whether the sensors are providing the expected voltage values for a particular condition.

Sensor Minimum and Maximum Voltages

<-Reset Min/Max. 5.00V to 5.00V

←Reset Min/Max. 5.00V to 5.00V

This photograph would have been slightly more meaningful if I had run some analog sensors for a while. Pretend it shows “0.40V to 4.78V".

The counter device keeps track of the lowest (down to 0V) and highest (up to 5V) voltage it has read from either sensor since power up or reset. This helps determine the actual voltage range of attached sensors.

The counter device only measures analog values when it is in analog mode or when an analog screen is shown. So, for example, these values won’t show historical ranges if the device has been running only on the main counter screen in digital mode. To determine the actual analog range:

  1. Navigate to this screen.
  2. Reset the recorded values by pressing the red Adjust Button.
  3. Then run the motor while this screen is showing.

Because both the Sensor A and Sensor B voltage ranges are combined on this screen, it can falsely report data if only one sensor is attached. If only one sensor is available, simply connect it to both Sensor A and Sensor B connectors.

Analog Minimum and Maximum Trip Voltages

<-Auto Sen Adj->. Trip Low: 1.66V

←Auto Sen Adj→. Trip Low: 1.66V



<-Auto Sen Adj->. Trip High: 3.33V

←Auto Sen Adj→. Trip High: 3.33V

These two screens allow the user to specify the analog voltage level that will be considered the low portion of a pulse wave, and the analog voltage level that will be considered the high portion of a pulse. For a pulse to be counted, the voltage level must dip below the low value and then above the high value.

The voltage levels are adjustable in approximately 0.02V increments by rotating the Adjust Dial.

Pressing the red Adjust Button on either screen will automatically calculate an appropriate voltage level based on the recorded minimum and maximum. So, this feature only works well if the minimum and maximum values are accurate.

Sensor and Motor Connections

The rear of the Counter device has a 4-connection terminal block with screws for sensor wires, and a 3-connection terminal block with screws for motor wires. These are single-row Molex-brand barrier terminal blocks with 0.375-inch spacing. They are available from Mouser Electronics (#538-38721-6703 $2.18, #538-38721-6704 $3.42).

Rear panel of the electronic counter with a motor control switch. sensor connectors, and motor connectors.

Rear panel of the electronic counter with a motor control switch. sensor connectors, and motor connectors.

The Encoder / Counter Sensor connections are:

The Motor connections are:

The Motor connections are all optional if you don’t want speed control and AutoStop. For example, if you want to use a 120AC motor then the motor power should come from an external device -- not the counter device.

Sample Setups:

Now let’s take an inside peek at the Adjust Dial to see how a rotary encoder works...