Saving PIC Microcontrollers With DIY Programmer

When working on a project, plenty of us will reach for an Atmel microcontroller because of the widespread prevalence of the Arduino platform. A few hackers would opt for a bit more modern part like an ESP32. But these Arduino-compatible platforms are far from the only microcontrollers available. The flash-based PIC family of microcontrollers is another popular choice. Since they aren’t quite as beginner or user-friendly, setting up a programmer for them is not as straightforward. [Tahmid] needed to program some old PIC microcontrollers and found the Pi Pico to be an ideal programmer.

The reason for reaching for the Pico in the first place was that [Tahmid] had rediscovered these decade-old microcontrollers in a parts bin but couldn’t find the original programmer. Thanks to advances in technology in the last ten years, including the advent of micropython, the Pico turned out to be the ideal programmer. Micropython also enables a fairly simple drag-and-drop way of sending the .hex file to the PIC, so the only thing the software has to do is detect the PIC, erase it, and flash the .hex file. The only physical limitation is that the voltages needed for the PIC are much higher than the Pico can offer, but this problem is easily solved with a boost converter (controlled by the Pico) and a level shifter.

[Tahmid] notes that there’s plenty of room for speed and performance optimization, since this project optimized development time instead. He also notes that since the software side is relatively simple, it could be used for other microcontrollers as well. To this end, he made the code available on his GitHub page. Even if you’re more familiar with the Arduino platform, though, there’s more than one way to program a microcontroller like this project which uses the Scratch language to program an ESP32.

TMS 1000 Microcontroller - By Antonio Martí Campoy - Own work, CC BY-SA 4.0

The Early History Of The Microcontroller: It Came From Texas

Ti’s presentation of the rapid integration of calculator chips.
Ti’s presentation of the rapid integration of calculator chips.

Although for most generations alive today the era of microcontrollers (MCU) feels like it starts somewhere with the Intel 8051 and AVR MCUs, the history of these self-contained computing marvels that are now found just about anywhere begins long before those were even conceptualized. In a recent article titled Tiny Computers From Texas, [Babbage] goes through this early history of what would ultimately become such an integral part of daily life.

An MCU is defined as a small, self-contained computer, which requires few to no external components to function. This contrasted with the more traditional MPUs, or microprocessor units, where a computer was assembled out of one or more MPUs, I/O chips, memory SRAM and so on. It’s perhaps little surprise that the drive towards MCUs was the result of primarily the calculator market, where competing firms were trying to upstage each other with higher levels of integration into as few chips as possible, while driving down costs and power usage.

Ultimately, the Texas Instruments TMS 1000 was the first true MCU that got produced in large volumes after its release in 1974. Moving beyond calculators, the TMS 1000 found its way into toys, including the Speak & Spell – which uses another Ti chip (TMS 5100) for the voice synthesis – so that today any toy can be interactive in exciting and often noisy ways.

Back in 2020 we took our own affectionate look at this chip.

Wio Terminal Makes Passable Oscilloscope

There was a time when getting a good oscilloscope not only involved a large outlay of capital, but also required substantial real estate on a workbench. The situation has improved considerably for the hobbyist, but a “real” scope can still cost more than what a beginner is looking to spend. Luckily, plenty of modern microcontrollers are capable of acting as a basic oscilloscope in a pinch, provided there’s a display available to interface with it. Combined with the right software, the Wio Terminal looks like a promising option.

The Wio Terminal is a platform gaining some popularity due to its fairly capable SAMD51 microcontroller and also its integration with a display and a number of input buttons. On the hardware side, [mircemk] mounted the Terminal in a convenient vertical orientation and broke out a pair of connectors for the inputs.

But it’s the software that really makes this project work. [Play With Microcontroller] originally developed the firmware for the PIC24 back in 2017, but ported the code over to the Wio Terminal a couple years back. Noting that the microcontroller is not particularly fast, the project doesn’t exactly match the specifications or capabilities of a commercial unit. But still, it does an impressive job of recreating the experience of using a modern digital scope

The Wio Terminal is a device we’ve seen around here for a few unique projects, among them a device for preventing repetitive strain injuries while using a computer mouse and another that is a guide for game development in MicroPython. And if you’re just itching to port oscilloscope software to accessible but under-powered microcontrollers, be sure to check out [mircemk]’s other oscilloscope projects like this one built around the STM32 microcontroller.

Continue reading “Wio Terminal Makes Passable Oscilloscope”

Two-Channel Guitar Stomp Box Makes Momentary Switches Latching

When we first saw [Maarten Tromp]’s article about a “momentary latching switch” for guitar effects pedals, we have to admit to being a bit confused. When it comes to push-button switches, “momentary” and “latching” seem to be at odds with each other, with different mechanisms inside the switch to turn one into the other. What gives?

As it turns out, [Maarten]’s build makes perfect sense when you consider the demands of a musical performance. Guitar effects pedals, or “stomp boxes,” are often added to the output of electric guitars and other instruments to change the signals in some musically interesting way. The trouble is, sometimes you only need an effect for a few bars, and the push-on, push-off switches on many effects pedals make that awkward.

[Maarten]’s idea was to build a stomp box with momentary switches that act as inputs to an ATtiny2313 microcontroller rather than directly controlling the effect. That way, a bit of code can determine how long the switch is tapped, and activate a relay to do the actual switching accordingly. A short tap of the button tells the microcontroller to latch the relay closed until another tap comes along; a long press means that the relay is held open only as long as the button is held down.

Yes, he could have used a 555, a fact which [Maarten] readily acknowledges, but with some loss of flexibility; he currently has the threshold set at 250 milliseconds, which works for his performance style. Changing it would be a snap in code, as would toggling the latching logic. A microcontroller also makes expansion from the two-channel setup shown here easier.

Looking for more effects pedal action? We’ve got a bunch — a tube-amp tremolo, an Arduino Mega multipedal, a digital delay line. Take your pick!

Adding Temperature Sensor Functionality To The CH32V003 MCU

As cheap as the WCH CH32V003 MCU is, its approximately $0.10 price tag looks far less attractive when you need to start adding on external ICs for missing basic features, such as temperature measurement. This is a feature that’s commonly found on even basic STM32 MCUs. Fear not though, as [eeucalyptus] shows, you can improvise a working solution by finding alternative sources that can act as a thermometer.

Plot of the temperature measurement using the improvised CH32V003 -based temperature sensor. (Credit: eeucalyptus)
Plot of the temperature measurement using the improvised CH32V003 -based temperature sensor. (Credit: eeucalyptus)

The CH32V003 is a low-end, 32-bit RISC-V-based MCU by the China-based Nanjing Qinheng Microelectronics, commonly known abbreviated as ‘WCH’, and featured on Hackaday previously. Although it features a single-core, 48 MHz CPU, its selection of peripherals is fairly basic:

So how do you create an internal temperature sensor using just this? [eeucalyptus] figured that all that’s needed is to measure the drift between two internal clocks – such as the LSI and HSI – as temperatures change and use this to calibrate a temperature graph.

Unfortunately, the LSI isn’t readily accessible, even through the Timer peripheral. This left the AWU (automatic wake-up unit) which also uses the LSI as a clock source. By letting it go to sleep and wake up after N LSI cycles, the AWU enabled indirect access to the LSI.

Internal diagram of the CH32V003 MCU. (Credit: WCH)
Internal diagram of the CH32V003 MCU. (Credit: WCH)

After calibrating against room temperature (~22 °C) and ice water (0 °C), a temperature plot was obtained, which could conceivably be somewhat accurate. As [eeucalyptus] warns, this is a kind of calibration that likely differs per MCU, and no attempt to quantify the absolute accuracy of this method has been made yet. Even so, as a crude temperature measurement, it might just be good enough.

Teensy Stands In For The Motorola 68k

While it might not seem like it today, there was a time in the not-too-distant past where Motorola was the processor manufacturer. They made chips for everything, but the most popular was arguably the 68000 or 68k. It’s still has a considerable following today, largely among retrocomputing enthusiasts or those maintaining legacy hardware. For those wanting to dip their toes into this world, this Motorola 68000 emulator created by [Ted Fried] may be the thing needed to discover the magic of these once-ubiquitous chips.

The emulator itself runs on a Teensy 4.1, a 32-bit ARM microcontroller running at 600 MHz — giving it enough computing power to act as a cycle-accurate emulator not only for the 68000 CPU but also the local bus interface, in this case for a Mac 512K. This capability also makes it a drop-in replacement for the 68000 in these older Macs and the original hardware in these computers won’t notice much of a difference. A few tricks are needed to get it fully operational though, notably using a set of latches to make up for the fact that the Teensy doesn’t have the required number of output pins to interface one-to-one with the original hardware.

While the emulator may currently be able to replace the hardware and boot the computer, there is still ongoing development to get every part of the operating system up and working. The source code is available on the project’s GitHub page though so any updates made in the future can be found there. And if you have a Mac 128k and still haven’t upgraded to the 512k yet, grab one of these memory switching modules for the upgrade too.

Continue reading “Teensy Stands In For The Motorola 68k”

African man hunched over a small robot car chassis

The Dar Es Salaam Hacker Scene And Gamut Detection

We’re on a sort of vacation in Tanzania at the moment and staying in a modest hotel away from the tourist and government district. It’s a district of small shops selling the same things and guys repairing washing machines out on the sidewalk. The guys repairing washing machines are more than happy to talk. Everybody’s amazingly friendly here, the hotel guy grilled us for an hour about our home state. But I really didn’t expect to end up in a conversation about computer vision.

In search of some yogurt and maybe something cooler to wear, we went on a little walk away from the hotel. With incredible luck we found a robotics shop a few blocks away. Mecktonix is a shop about two meters each way, stuffed full of Arduinos, robots, electronics components, servos, and random computer gear, overseen by [Yohanna “Joe” Harembo]. Nearby is another space with a laser engraver and 3D printer. The tiny space doesn’t stop them from being busy. A constant stream of automotive tech students from the nearby National Institute of Transport shuffle in for advice and parts for class assigned projects.

In between students, Joe demos an autonomous car he’s working on. In classic hacker fashion, he first has to reattach the motor driver board and various sensors, but then he demos the car and its problem –  the video frame rate is very slow. We dive in with him and try to get some profiling using time.monotonic_ns(). He’s never done profiling before, so this is a big eye opener. He’s only processing one video frame every 4.3 seconds, using YOLO on a Pi 3, and yup, that’s the problem.  I suggest he change to gamut detection or a Pi 4. Continue reading “The Dar Es Salaam Hacker Scene And Gamut Detection”