PSoC4 MCU Back in Action
In a previous project, Aubrey began crafting a device to improve the accuracy of an antique clock. But that project remained inconclusive because he didn’t have access to the clock in person. Now, with an antique Bulle clock acquired, he resumes his efforts, once again putting the PSoC4 MCU to work.
Acouple years ago, I wrote about my initial attempt to improve the accuracy of some antique electrical clocks—”Modernizing the Accuracy of an Antique Clock” (Circuit Cellar 358, May 2020) . Briefly, my clock-collector friend, Nigel, challenged me to come up with a system to make Eureka and Bulle antique clocks more accurate. I described my initial work and how I intended to approach the problem. Let me paraphrase the poet Robbie Burns: The best laid plans of mice and men often go awry. Am I a mouse or a man? I will let you decide as I squeak about my progress.
Based on my initial work, I designed a PCB, using the process to learn about KiCad. I had the board manufactured, populated it, and then proceeded to prove its operation with the usual blinky LEDs, a DVM and an oscilloscope. As I mentioned in my last article, Nigel (and his clocks) resides in England, while I inconveniently reside in Canada. I had no real clock with which to try out my ideas. And then I made a colossal error, or at least it felt that way for quite some time.
In every online auction I had seen for Bulle and Eureka clocks, the bids remained static until a few minutes before the closing, and then escalated rapidly. I came across a Bulle clock on an auction site and was taken by its simple and modern appearance, compared to the more elaborate models with which I was acquainted. I placed a bid £10 above the base price, expecting a price escalation that would allow me to simply dismiss it as a bit of fun. I was the only bidder, and thus became the unexpected owner of a “working” Bulle clock (Figure 1). As it turned out, “working” was a vague description. I challenged the seller and he made conciliatory noises, but never actually walked the talk.
I was left trying to understand how the clock ticks (sorry!) and how to turn my acquisition into a working timepiece. Surprisingly, quite a few spare parts are available for Bulle clock repairs, and I replaced several, but I won’t bore you with the details.
THE BULLE CLOCK
Early in the 20th century, quite a few inventors were trying to make an electric clock. The mechanism used in the Bulle clock was developed by Professor Marcel Andre-Moulin just before 1914. During the first World War (1914-1918), Maurice Favre-Bulle worked on a similar design , and the two Frenchmen joined forces at the end of the war, establishing the Bulle Company in France to commercialize their concepts. Production began in 1920 and continued until 1952, producing about 300,000 clocks of evolving design.
The Bulle pendulum includes a solenoid that moves along an arc of an armature which, in fact, is a 3-pole magnet. Three-pole is hard to believe, I know, but it does exist. Let’s take it as a given for the moment, as I explain the operation of the clock. Providing a voltage to the solenoid coil enclosed in the pendulum bob creates an electromagnet, which causes the pendulum to move. The design and movements of a Bulle clock are shown and discussed in detail in the video, “Bulle Clocks: Magnet Marvels from a Century Ago” .
Figure 2 shows a side view of the clock. The purpose of the front and rear rods is to carry the current from and to the solenoid coil. The forward rod is suspended from the clock tower by a hinge (made of silk fabric), which allows the pendulum to oscillate. The battery’s negative terminal is connected to the clock tower, and since the hinge isolates the forward rod, there is a filament that allows electrical continuity from the negative terminal to the front rod. The front rod is connected to one side of the solenoid coil internal to the pendulum bob. The other side of the pendulum coil is connected to the rear rod.
The face of the clock is isolated from the tower and is connected to the positive terminal of the battery. It is periodically connected to the silver pin through that pin’s contact with the fork, and then via the pin assembly to the rear rod. This process of momentary connection of the pin with the fork is the pulse that keeps the pendulum oscillating. The pin assembly and fork are complex mechanical parts, which I will attempt to describe in a moment.
In normal operation, an isochronism spring connected between the pendulum and the clock frame limits the pendulum travel, because the pendulum’s motion is closer to simple harmonic behavior when the range of travel is small. For the moment, ignore the external contact shown in Figure 2.
The pin assembly is a brass cylinder with a silver pin soldered to one end-face. There are two transverse holes for the front and rear rods, and an axial hole drilled from the rear face through to the second hole, which will house the front rod. The axial hole is tapped to the first hole, which houses the rear rod, and a matching bolt is screwed into it. A small metal cylinder resides in the passage between the two holes. The forward rod has a layer of insulator wrapped around it in the region of the cylinder, and there is a metal T-piece inserted as well.
As the bolt is tightened, it compresses the rear rod (which is connected to the positive side of the solenoid coil) against the side of the rear hole, establishing electrical contact to the cylinder and the silver pin. The rod also pushes against the small metal cylinder installed in the linking passage between the two holes. This small cylinder presses, in turn, on the T-piece, which distributes the load and protects the insulator of the front rod. The insulated front rod is subsequently compressed against the brass cylinder.
This arrangement serves several purposes. It electrically connects the positive side of the solenoid coil to the silver pin. It holds the pin assembly in position on the front rod. The rear rod is not mechanically attached to the solenoid assembly, and is held suspended by the pin assembly. This is fairly complex arrangement that can be viewed in Figure 3. For the moment, again please ignore the indicated external contact.
The “fork” is made from a flat metal plate with two tines. One tine has a silver contact riveted to it, and the other has an insulator affixed in a similar fashion. Electrically, the fork is connected to the battery’s positive terminal via its mounting on the frame of the clock face. The fork pivots forward and back on a shaft as the silver pin of the pin assembly contacts the fork’s tines and then moves the fork first in one direction and then the other.
One function of this arrangement is that the motion of the fork drives the escapement controlling the clock’s gears. The second function is to energize the solenoid. As the pendulum swings to the right (as viewed from the front of the clock) the silver pin on the pin assembly connects to the silver contact on the right tine of the fork and completes the circuit across the solenoid coil. The contact is maintained as the pendulum continues to swing to the right. With the return of the pendulum, the silver pin breaks the circuit and moves to the left tine, which is electrically isolated from the fork by the insulator. The contact with the insulator is maintained for the full return swing, and then the process repeats with a period of 1 second.
In all honesty, I have difficulty understanding how the magnetics of the clock work in its original configuration. The 3-pole magnet consists of a cobalt steel (some say tungsten) permanent bar magnet formed into an arc. This serves as the armature for the solenoid coil. The bar has been magnetized with a south pole at each end and a north pole in the center (hence, 3-pole). The pole at the center is equivalent to two regular magnets with the north poles forced together.
A very strong resultant magnetic field is orthogonal to the magnet at the center of the bar. The pendulum is motivated by a pulse when the silver pin contacts the fork, just as the pendulum is beginning to cross the center of the magnet arc (and the north pole). The arc of the swing is determined by a combination of the voltage of the pulse and the time of the pulse.
Early on in its existence, the Bulle Company released a manual  with some explanation of the magnetic operation. Apparently, the magnetic armature serves to reduce the current draw from the battery, but I cannot understand why this is the case, and the patent  doesn’t enlighten the situation. Other explanations in the public domain discuss magnetic attraction and repulsion, but seem to have errors in the logic, and so I have dismissed them all.
Even if we reduce Maxwell’s equations into Fleming’s rules, we have simple harmonic motion, the Left-Hand Rule, the Right-Hand Rule and a 3-pole magnet. It is like an electromagnetics final exam set by a vindictive professor. The current in the solenoid coil creates a force, and the pendulum gathers speed. The 3-pole magnet induces a current in the solenoid, opposing the initial current, and is present even when the driving pulse is removed. I would dearly love to hear a plausible explanation, and if you have one or can identify the grouchy professor, please let me know.
The location of the silver pin relative to the contact point of the fork is a critical and time-consuming adjustment; it is linked to the arc subtended by the pin assembly mounted on the pendulum rods. If the fork rotates too far, the escapement can overdrive the gear, causing the clock to gain time. Conversely, if the fork does not rotate enough, the escapement doesn’t drive the gear far enough, and the clock loses time.
The Bulle clock reportedly does not keep time every well. On forums and in literature, the problems with accuracy are ascribed to variations in the battery voltage as it decays over time, the degradation of the fork contacts over time, the gradual demagnetization of the 3-pole magnet, temperature variations and an imperfect simple harmonic oscillator.
Because I ran into one problem after another, I despaired of ever making the clock operate, only later coming up with an idea that allowed some progress. But when I discovered that the insulator on the fork was so worn that the solenoid coil would be energized on both the to and fro of the pendulum, I decided that my watchmaker skills were no longer sufficient. It reinforced my opinion that I had wasted my money on the clock.
From the start of the project, Nigel had said he had read that if a pendulum were forced to oscillate by a periodic external force, it would synchronize to that force. A logical extension that he suggested was to drive a coil directly. As I wallowed in my disappointment, his idea came back to me. I disconnected the supply positive to the clock face, and added a wire in a suitable location on the rear rod, bypassing the switching arrangement on the fork.
I then supplied a regular voltage pulse from the electronic board that I had produced. At first glance, this attempt proved Nigel right. The connection, using the most flexible wire I could find, is the one marked “external connection” in Figure 2 and Figure 3. Horology purists will have a conniption with this modification, but it is easily removed, restoring the clock to its unmodified and inaccurate splendor.
PSOC4 MCU TO THE RESCUE
The beauty of the PSoC4 microcontroller (MCU) from Infineon Technologies (formerly Cypress) is the configurability of its internal peripherals. The final design shown in Figure 4 is significantly simpler than the original design shown in my 2020 article , but the changes are all in software. It took several attempts for me to understand the sensitivity of the timing. To have an accurate time base (bypassing the MCU’s internal clock) and to reduce current consumption, I used an external oscillator as the system clock. I must admit my naïveté in the assumptions and selections I made, and I paid dearly in time spent, as I sought to get my Bulle clock working accurately.
In principle, I was going to take a frequency and divide it down to generate 1-second pulses. I added an external 4MHz oscillator to avoid the vagaries of the MCU’s internal oscillator. A secondary purpose was to run the MCU at a lower speed to reduce current consumption. I originally tried generating the 1-second pulse with 16-bit counter using a 10KHz signal (reduced from 4MHz by a prescaler internal to the PSoC4). It turned out that the granularity of 100µs was too coarse. I had to refine the design to work with 1MHz, using a 24-bit counter with a resolution of 1µs. I also reverted to running the MCU on its own internal clock. The oscillator I used for the external 4MHz also proved problematic and deserving of further discussion, which I will get to later.
The “uSecCounter” (in Figure 4) is configured as a 24-bit Up Counter with an adjustable compare value. The divisor (I denote as “T”) of nominally 1,000,000 gives a period of 1 second. The compare output of the counter defines the length of the pulse applied to the solenoid and is timed in microseconds. I denote this confusingly as “P” with a default value of 250,000, that is, 250ms.
One of the limitations of the PSoC4 is that its digital-to-analog converter (DAC) only has a current output and has to be converted to a voltage by an external resistor, R11 in the schematic (Figure 5). There are two modes of operation, determined by the “ModeSel” (in Figure 4) register under software control. When the register is set, the current at the output is constant, so that the derived output voltage can be measured. When it is cleared, the output current pulse is driven by the PWM pulse, which is the normal operation of the Bulle. The two modes are selected in software by a setting on the DIP switch (SW1 in Figure 5).
To reduce current consumption, the PSoC4 is kept in a continuous sleep state, unless there is communication on the serial port. The switch between states is initiated by pressing hardware “buttonB” (S2 in Figure 5) for communication and “buttonC” (S1) for sleep. The transition between states is handled in software. In the sleep state, only the hardware peripherals operate, and the processor pauses at the instruction after the sleep command code. The processor wakes up on any interrupt. Only the two interrupts are active.
Something that tripped me up was that the processor starts executing the next few instructions after the sleep instruction before the interrupt service commences. In the communication state, an external LED, D2 (LED_B in Figure 5) illuminates when the PWM output is active. The external RS232 converter chip (U8) is powered up in software by clearing the pin RS232_ON, which drives the transistor Q1.
My original mandate was to get the PCB to run on a battery. Initial calculations of current draw for the processor, alone, gave a result of about 0.8mA. Being old-school, I wanted to run the circuit with 5VDC. If I were to use a buck switch-mode power supply (U3) with a 9V battery, the current draw from the battery would be about 0.3mA with 100% conversion efficiency. A 9V battery has a life of 500mAhours, and with two connected via diodes, it could reach several months.
In reality, however, the full circuit drew 4mA in sleep state and 14mA in communication state (even more in the current version). Back in my youth in Africa, we had hefty 9V batteries, but they seem few and far between nowadays, and so I opted for a linear power supply (U1) derived from a USB power supply with a battery backup for power failures. As a result, I reduced the supply voltage to 3.3VDC.
The voltage developed from the processor’s DAC is buffered by U6 and fed directly to the Bulle’s positive connection (via J2/1). The negative of the Bulle coil is returned (via J2/2) to a low value resistor R15, and the resulting voltage is amplified and drives an LED, D6, to indicate a current flowing in the solenoid coil. And yes, this LED is also a source of current consumption—which should be switched to reduce the current budget. Next time!
In my earlier article , I had planned to use an LCD display connected to the RS232 port to change the parameters. There are only three parameters now, and I decided it would be simpler and more widely accessible to communicate via a terminal software program running on a PC, along with a USB-to-RS232 converter. I used TeraTerm (open-source software that emulates different types of computer terminals), but any similar program will do.
I quickly determined that the pendulum appeared to align (synchronize is perhaps a little too strong a word) with the electric pulse at the beginning of the swing, and that the experiment showed some promise of success. I made some measurements to understand the effect of the 3-pole magnet, but I could find no significant influence on the pendulum motion, and I shelved any further attempts to analyze the relationship.
The three parameters I introduced were: Voltage (V), the Time divisor (T) and the Pulse for the solenoid (P). I started with T at 1,000,000, presuming that it would provide a pulse every second. After messing around (and this is a huge understatement), I managed to find a suitable voltage and pulse-width combination that reliably advanced the time. But to my surprise, the clock was losing a disheartening 2 minutes in 24 hours. A quick calculation showed that this was only a 0.13% error. I was confronted with the error of my ways.
As mentioned earlier, I added an external oscillator to the PSoC4 MCU. In my desire keep current consumption to a minimum, I happened upon a delightful oscillator made by Maxim Integrated (now part of Analog Devices)—the MAX7375 (U9), which, in my mind, was a crystal. I was seduced by the 5V operating voltage, low current consumption, and small footprint. The specifications seemed good to my unquestioning mind, but in fact, they were the cause of much despair, which took me many measurements to understand.
At this point, the only way I could judge the accuracy was to compare the time on the Bulle face to that of an accurate clock. This was complicated by the fact that the minute divisions on the Bulle clock face are not equidistant. Accordingly, the measurement had to be at the same spot on the dial, that is, every hour. I found it difficult to consistently relate divisor to time loss, and I could never get the clock to gain time.
After many months of trial and error, I decided to measure the frequency at point TP2 (see Figure 4). Imagine my surprise when I found the frequency had a jitter spread of about 120Hz. At first, I blamed my 43-year-old, cheap frequency counter, but confirmed it again with a borrowed 20-year-old frequency counter that was also uncalibrated. I averaged the observed value extremes as a seed for my divisor setting, but the results were still unpredictable; the Bulle only lost time to a lesser or greater extent.
All through the development, I had never managed to prove that pendulum swing synchronized to the electric pulse, though visually they certainly seemed to align, never appearing to miss a beat. I discussed this with others, and came to the same conclusion espoused by Scotty on Star Trek: “You can’na change the laws of physics.” I assumed that the pendulum had a fixed oscillation, and no external pulse was going to be able to change its period of oscillation.
I concluded that I had to change the pulse frequency to match that of the pendulum, and the pendulum’s natural frequency was the best that I could achieve. I adjusted the pendulum weight and played around with the divider setting, until I thought the settings were optimized, but I found that it was losing about 12 seconds in a 24-hour period. I decided to abandon the project for the third time, but overnight I wondered if, in fact, the time loss was due to a mechanical problem with the escapement.
To prove my theory, I first decided to count the electronic pulses compared to the swings of the pendulum, and ordered a simple pulse counter and another pulse counter with an optical sensor. The former arrived well before the latter, and I set about counting the pulses in a 24-hour period. Imagine my surprise when I discovered it was 12 pulses short of the expected 86,400 over 24 hours. The problem had to be coming from my electronics!
I toyed around with the divisor, until I managed to get a zero-error count over 8 hours. That divisor was well outside the frequency range I had measured earlier, something that was rather puzzling. But I chose not to investigate the enigma, because I had noticed another problem. The circuit would generate the correct number of pulses for an 8-hour period, but would gain 12 pulses for the remaining 16 hours, and it seemed related to the times of day.
Back to the Maxim MAX7375 oscillator’s datasheet . It claimed, “very low jitter: 160ps.” Using a thumbnail calculation, this would easily explain the frequency variation that I measured. And then there is a “±50ppm/°C temperature drift.” My home temperature varies by about 4°C overnight, and so another error was explained.
I decided to see if I could find a more suitable oscillator. I jury-rigged a Microchip Technology DSC1001 (±10ppm) on the PCB and measured the frequency at TP2. It was a stable 999,997Hz. I used that as a divisor, and just like that, my 2-year Sisyphean effort appeared to have ended.
My Bulle clock has been keeping perfect time ever since. Perhaps, as Scotty said, “You can’na change the laws of physics,” but if you try sometimes, you just might find… you can bend them just a little (with apologies to the Rolling Stones). I do know that I can advance and retard time on the Bulle by 1 second in 24 hours. Even if the pulse and the pendulum swings are not truly synchronized, as long as there is a single swing for each pulse, the clock will keep accurate time.
As I sit here with a smirk of satisfaction on my face, mesmerized by the pendulum swing, I rationalize that my auction miscalculation was perhaps not such a catastrophe. You may recall that my original challenge included the significantly more expensive Eureka clock. It’s going to be some time before I can get my hands on one of those, and if I do, I can assure you, it won’t be by another auction misstep! CC
For detailed article references and additional resources go to:
References  through  as marked in the article can be found there.
Infineon Technologies | www.infineon.com
Maxim Integrated | www.maximintegrated.com
Microchip Technology | www.microchip.com
Tera Term Project | https://ttssh2.osdn.jp
PUBLISHED IN CIRCUIT CELLAR MAGAZINE • APRIL 2022 #381 – Get a PDF of the issueSponsor this Article
Aubrey Kagan has worked in electronics for more years than he cares to remember. He is currently Engineering Manager at Emphatec, an industrial electronics design house in Markham, Ontario. He has written many articles for Circuit Cellar over the past 25 years as well as a book Excel by Example based on three of those articles. Aubrey was one of the “notable contributors” interviewed in Circuit Cellar’s 25th Anniversary issue. He has also published several design ideas as well as numerous blogs covering many aspects of electronic design. You can find a list and links to more of his publications on the Circuit Cellar article materials webpage. He can be contacted at email@example.com.