Category Archives: Experimental

DIY ENEGIZER

#128 making a simple energizer

Since I’ve been living in a rural area for the past few years I’ve had to come up with some affordable solutions to problems unique to my situation. One of these problems is keeping animals out of certain areas with methods that wont cause permanent harm but will definitely be effective. So the logical solution was to use electricity in the form of electro shocks. I searched for commercial solutions and found a few but they were a bit overkill/overpriced and of course not very hacker friendly… so I decided to make my own which I can always scale up with microcontrollers/relays/monitoring and all those nice to have features but for this one I wanted it to be plain old dumb without any programming required.

So I did my research and came up with a suitable schematic found the correct parts and settled on the good old 555 timer. Designed a very small PCB and got it manufactured a voila the idea became a reality and after a few tests it works perfectly fine.

Now the shock is created by the collapsing fields of the ignition coil I used for the project. I got the most basic simple coil that is driven by a suitable N-FET at a frequency and strength that I can fine adjust via a potentiometer on the PCB. The whole system runs on a 12V battery and consumes very little current.

I took inspiration for this device and modified and created my own flavour. Like everything in life no one can do everything by themselves so I would like to credit the source which got me started here.

With that being said I had a lot of fun making this device and it’s been working well I was also able to adjust the voltage to a very humane jolt so smaller animals know not to enter the area but also don’t get fatally hurt.

DUAL BAND ANTENNA FIX

#127 Fixing a Faulty Handheld Antenna

A while ago I purchased a few hand held radio antennas from a reputable source. Unfortunately one of them had a great SWR for 2m but a terrible SWR for 70cm. So I began investigating this and started to take apart the antenna to find out more. Just as a side note: I would not recommend this for beginners or businesses (if you have a faulty product immediately contact the seller and get a replacement or refund)

So during my autopsy of the antenna I was able to determine a few things. Firstly the plastic connectors in the middle of the antenna is supposed to have a loaded coil but there was just a crimped thinner antenna wire. Second on opening up the base of the antenna I was surprised to find out that they had a metal enclosing case which was nice.

Then looking at the SMA connection to the antenna I was pleased to see a base tunning coil and capacitor, this is a good sign. potentially meaning the antenna is a “GOOD COPY” of whatever the original antenna was. the antenna has zero markings but we can take a guess that its a good copy of the Diamond RH951

Finally I found the culprit.. the capacitor on the coil seemed to be destroyed.. after de-soldering it and testing it turned out to be a faulty part. So in order to fix the antenna I soldered another cap with a close enough value.. (13pf instead of 12pf) and sure enough after putting everything back together a gluing it the antenna worked perfectly but did have a slight frequency shift when Compared to the others I had purchased.

still this is a mission success the antenna works perfectly in both bands and I’ve been using it for over a year with both bands and no issues.

ALLSTAR VOTER

#125 Creating a DIY VOTER

Unpopulated VOTER PCB from the factory

VOTER (Voice Observing Time Extension for Radio) 

For a while now I have been involved with some troubleshooting at my radio clubs repeater site closest to me.
we have had a few issues where our equipment gets damaged from lightning water and rats.

We’ve tried to mitigate these problems however the reality is that it more of a manage the symptoms situation rather than solve the problem situation.

With this in mind we have had some damaged RTCM devices, the RTCM (radio thin client module)
is connected to the internet and to the repeater. It has an IP address and forwards the voice data to other sites or nodes that have the Allstar system setup. It’s basically like a small VOIP system that can adjust squelch and do simulcasting but the repeater site can choose what settings to enable or disable.

In our case its just connecting the Voice data to the internet so that club members can chat with other repeater/node users over a greater distance through the internet.

E.G: talking to someone in Durban is not possible using VHF at the altitude where I am situated, due to the terrain, large mountains and a hefty over 100Km+ distance away VHF will have a really hard time. Also with all the solar whether these days… I would expect diminishing results.

But… with an RTCM connected to a repeater or a Node, I can now communicate over that distance using Analog VHF radio to the RTCM over the internet and then through the repeater or node on the other side in this case in Durban.

Checking and adding components to the PCB

So now the big issue I had was that RTCM devices will be just under 10K south African ZAR from America for 1 with shipping and all the tax applied it’s very expensive and I wish money was no object but the truth is our club is not super financially inclined due to many reasons a lot of them out of our control.

This prompted me to investigate on an alternative and I found a few but I chose the original 2011 VOTER PCB which allows us to do the same thing basically just on the prototype board.

Of course this rises some concerns like:

  • THT components used
  • Parts are all PDIP and most have to be substituted
  • No case provided
  • A larger size
Back of the PCB while I was populating it

But… in my case weighing up the pros and cons there’s no major issue using this VOTER version.

So I got a few professionally made, read the datasheets for all the IC’s and purchased the available parts.
I also substituted the parts no longer available and integrated them with some small modifications.
(I will create my own PCB based on this in the future for better availability and usability)

Overall It took me around 3 month just to read all the datasheet and to get familiar with they systems bootloader and firmware of the VOTER PCB not to mention learn about the Allstar system as I had not really been educated on it. Though it was worth it and the research paid off in the end.

I was able to learn fast and I can say that I was happy with this project and the VOTER boards turned out great!!

Front of PCB while I was populating it.

CUSTOM UPDI PCB

#124 Making a Custom Programmer

Fake CH340N IC on the left real on the right

While looking for a good example PCB project I decided upon a simple UPDI programmer PCB for the well known new ATtiny ICs.
I had a few prerequisites I wanted to satisfy for the project.

  • Design must work but also have room for improvement
  • small SMD PCB design
  • BOM list and prices
  • simple schematic using KiCad
  • 1206 component size sop-8 IC size
  • USB-C
  • 2 sided PCB
  • all standard sizes for PCB manufacture
  • PCB panel example
Front
Back

I wanted the project to cover many of the basic and intermediate PCB manufacturing practices of course the IC is not very sophisticated and there is no impedance matching or equal length traces etc. However it shows how designing, quick and affordable manufacturing can be achieved in South Africa. Designing for manufacturing, thinking of the capabilities of the manufacturer and keeping best practices in mind at least to the best of my knowledge at that specific time.

In the project I keep things as standard as I can using metric measurements and easy milling panel design for the panel (no fancy curved edges or designs) although many interesting looking designs can be made surprisingly simple, it takes experience plus CAD artistic intuition. That being said I wanted this to be a simple and practical example I could use for teaching references later.

Getting to the component choices for a small UPDI programmer I chose the CH340N IC. It needs very little external components and has an internal crystal. Small and lightweight and perfect for my UPDI project. It is missing other pins like the reset pin but in my case this was not an issue. Always double check your IC datasheets and capabilities.

KiCad modal front
KiCad modal back

On that note I did receive some FAKE CH340N ICs and I tested them. They only worked on lower baud rates and adding LED indicator resistors to the TX and RX made them unstable. Unfortunately in this day and age fake ICs are very common you need to recognize them and weigh the balance between using them or not. Sometimes there’s a “good fake” so as a maker I may use this test projects or make throwaway projects but the characteristics of the IC are now different so any calculations are incorrect… so it’s a balancing act that no-one can escape. For production always use IC’s from the original manufacturer the stores are easily found online and it’s worth it in the end.

Simple schematic

All other components are very basic 1206 (easy to solder) SMD capacitors, resistors, TX/RX LEDs, power indication led, a diode 16-pin USB-c connector with 5k1 sense resistors keep the PCB copper balanced on both sides also saves etching chemicals for the manufacturer I also added some example fiducials and the copper stops 1mm from the edge of the PCB creating a small protection layer all around.

Since there is a USB-C connector I chose not to include any ESD or fuse but I would add these components to a commercial variant.

Also this v1.0 has the TX/RX LEDs on the wrong indication pins. I would change them to the USB side instead.

Overall I think it’s a good introductory example showing a simple design including some errors and fixes.

Panel front
Panel back
KiCad panel back

IO EXPANDERS

#123 Looking at some common IO expanders

What to do when you are using n 8-pin MCU to to the job of a 16pin ore even a 20pin MCU? Well it depends.. but if all you are doing is using IO’s to switch for example relays or similar tasks where the amount of IO’s is important, and not the capabilities of the IOs then you may be able so save costs by purchasing an IO expander instead of an abundantly pin gifted MCU.

These come in all shapes and package sizes and don’t increase the project size too much. Also I tend to use I2C much more then SPI but IO expanders can support both these packages.

Examples like the PCF8574, MCP23017, 74LVC595 and the MCP23S17 which uses SPI if you want to use that instead. The expanders support interrupts but always double check the datasheet before purchasing!

Something similar but not an expander more of a multiplexer IC is the MC14051B Analog Multiplexer/Demultiplexer this is quite common and affordable at least in South Africa and allows analogue pins to be expanded instead of digital.

Some Links to shops in South Africa that sell these expanders:

PCF8574

MCP23017

74LVC595

  • not common in South Africa

MCP23S17

MAKING A DIY PIR SENSOR

#121 Making a DIY PIR sensor on protoboard

Front of PCB on proto board

A few years ago I wanted to use some type of sensor for security purposes in my workshop.
I just needed something to sense movement and send a radio signal to my Roboguard device.
An actual Roboguard beam was too expensive, too bulky and large and was not rechargeable… not to mention a bit overkill for my application.

So I decided to look for a low power and small sized PIR sensor. Eventually I was able to find an affordable and small PIR sensor that can operate at 3.3V. I found the MH-SR602 PIR sensor which offers an adjustable delay time with a detection distance of 0 – 3.5 Metres. it has a built in regulator with a range of 3.3 – 15VDC but adds a bit of extra current draw… since I was already using 3.3V for my IC and RF circuits I was able to de-solder the included regulator to save a bit of current. This would help me greatly especially since I was going to use deep sleep.

PCB inside the box I designed it for.
Lid closed only the PIR sensor is sticking out (Radar does not have this problem)

Now the main MCU is the ATTiny212 and the RF module used is the WL102-341… not sure on the authenticity of the module but it works range is good and the current draw is up to spec + the EN pin does disable the unnecessary current draw when pulled low. The LDO regulator I used is the classic HT7333-A.

After soldering everything and checking for shorts I was able to program the MCU and then power up the device with an recycled 550mAh vape battery. First thing I noticed the device would constantly trigger the PIR. Eventually after a long time of troubleshooting I replaced one of the ceramic capacitors used to stabilize the output of the HT7333-A and now everything worked… Now when looking at the capacitor I didn’t understand exactly why it was not working, there was no short only a really high resistance and the capacity was a bit higher than the specified uf.

Before hand I made sure the PCB would fit into a standard rectangular project box. I just needed to drill a hole for the PIR sensor to stick out. After drilling a hole for the micro USB charging port the project was complete and working.

While testing I was able to achieve a very low current draw in deep sleep mode. I did some basic calculations and the MCU should last more then a year without needing a charge. Later after leaving the device in my workshop I was able to confirm this with the device lasting over a year and a half with mild triggering whenever I was working in the workshop. making use of the ATtiny PIT for long sleep timing and interrupts for waking up the device after some code refactoring I was able to make things super efficient. I programmed everything in C. ASMM is a bit to much for low level stuff in my opinion though I would like to make time to learn it one day. Still I was able to create a program of 956 bytes using ram of 18 bytes. So under 1k was nice since the smallest ATtiny size is 2k so I’ve still got plenty of space.

Current when the MCU is in sleep mode (the PIR is always running) 121.9uA roundabouts
772.2uA of current when the MCU is running but RF is not TX’ing
13.1mA during TX

One thing I can say for sure is that this project really activated a habit in me to try make everything as small and as efficient as possible whenever I program 8-bit microcontrollers for my personal projects. I must say I was also able to save some money when buying IC’s by improving my code and what can I say it feels very good once a project is completed and as small and efficient as I could make it.

With that being said sometimes when using a microcontroller like the ESP8266 or ESP32 the resource abundance feels crazy but once I start populating all that space with HTML and bitmaps + other media I quickly realized that even that space can get used up very fast.

C.A Torino

Back of the protoboard

MPLABX VS ARDUINO IDE

#119 Differences and similarities between the two

Recently I wrote about the pros and cons etc. about different programmers used to program embedded devices. I mentioned a few examples like ST-Link, PicKit and standard DIY programmers. Now since programmers work hand in hand with the programming software on your PC I decided to talk a bit about the 2 IDEs I use often. (Although you can easily setup platform IO with a compiler for embedded devices I will be focusing mostly on full IDEs but will make mentions to using text editors)

So I’ll start with the Arduino IDE. it’s simple to install and to get started with. There’s many libraries and there’s a wide support on the internet. Note: at least in my experience in South Africa at the public school I went to there was basically no interest or effort to promote Arduino and similar platforms. Looking back this was very disappointing since I’m 99% sure I would have gotten into Arduino much earlier in life if certain educational departments had made an effort in promoting Science instead of supporting political nonsense like the “science must fall” movement but I digress.

That being said Arduino is not all fun and games, it’s a great learning introduction tool but can promote bad code practices and reliance on libraries for work. Arduino also heavily promotes using easy functions instead of port manipulation methods… even in advanced projects… this can be a bit annoying especially when you want to use a library in a project with a different MCU and also when you want to keep code small and efficient. This can really bloat your MCU code and as you can imagine there is really not much room “literally” when programming embedded devices. Macros for port manipulation can really help but relying on digitalwrite(pin1); to pull a pin high or low can really cause some confusion later on

There may be more pros and cons not mentioned above but really I just want to get into the stuff that I can mention off the top of my head for this article.

Now switching to the free MPLABX IDE. I can say that the learning curve is quite steep but easy to get into with repetitive use. Once you get familiar with the layout you can start seeing quite a few pros compared to Arduino. having the ability to view the entire file structure in the IDE helps a ton. Also AVR has been integrated into MPLABX for some years now so you can easily program Arduino style. The IDE promotes professional main.c files and avr-main.c files which is very cool (I’m not really into ASM programming at least for now there’s a very big learning curve but one day I’ll get into it I hope 🙂 ) MPLABX also supports a huge variety of ICs and you can easily download updates for these as well as some libraries. Another pro is the GUI MCC (MPLAB Code Configurator) ok, ok I’m not a huge fan because I always somehow bloat up my project and break things but I can totally see how it could help by providing a GUI for setting clocks and bits etc. Another cool feature is that there are options for dark mode in the ide and it uses NetBeans.

There are a few downsides to the MPLABX IDE for example when using a 4k screen the Nebeans part always has blurry visuals now you can adjust the DPI but then all the text is super small and when adjusting the text it becomes inconsistent in certain places. Like for example the IDE text is small but your code text is big. This has always been an issue for me but I guess I’m just suffering from a 4k screen 🙂 Another issue is that I have always had to use expensive dedicated programmers when using MPLABX non of my DIY CH340N etc. programmers will work with MPLABX. Also programming AVR requires an AVR programmer so you can’t just use a PicKit3 for everything. Another pro is that it’s easy to choose compilers in a list. You cans install multiple compilers without issue. Another great feature is that you can install the so called MPLABEXT extension using visual studio code so you don’t have to use the IDE but can keep compatibility. Another cool feature is the ability to read and program the fuses or (configuration bits for PIC). Once again there may be some pros and cons not mentioned but I’m just writing this off the top of my head.

An honourable mention goes to the text editor approach. This is very light weight and generally bloat free and offers a lot of flexibility which makes using visual studio code a great choice but of course it’s not really a dedicated IDE.

Now to close off I will include to code samples to show the differences between the Arduino IDE and MPLABX IDE I will be programming an AVR device the ATtiny826 in the comparison examples.

Arduino blink code example including a blink without delay and a fast blink sample I made :



MPLABX blink code example including a blink without delay and a fast blink sample I made :

DIY UPDI PROGRAMMER

#117 A DIY UPDI plug and play board

Making fast and crude but reliable programmers

When getting into the new ATtiny series (tinyAVR-0 tinyAVR-1 tinyAVR-2 IC’s) of microcontrollers a few years ago I noticed how easy it had become to program them with only a few extra components.

I started out with just a 4.7k resistor and a cheap CH340 programmer. Then 3 wire hook-ups later I could easily program my IC’s. The only downside was that I had to sacrifice the UPDI pin to the dedicated Pin gods.. so I couldn’t use that pin unless I wanted to make my life more difficult.

Well this was okey for me and ever since I always have the UPDI pin open only for programming. So all my designs incorporate this principal. If I really need more pins I would use an affordable IO expander IC.

Now with that being said it’s all good and well programming with a mini rats nest… but I wanted to create a simple plug and play DIY programmer with commonly available parts and plug and play compatibility.

So I came up with a small circuit that’s easy to build on stripboard. I created a few versions over the years. Since I was the only one using this contraption I didn’t think of creating a professionally made PCB but that will come in future..

Front of the stripboard
Back of the stripboard

How do I use this?

Basically I solder the SMD package ATtiny to a suitable breakout PCB then I plug the ATtiny breakout PCB into my programmers female headers making sure the orientation is correct and presto all I need to do is upload my firmware. Then I can just remove the PCB and Plug it into my project

Simple and to the point… plus it’s been working for years.

30W LED DAYNIGHT REPAIR

#116 Repairing A 30W Day Night LED Light.

30W LED with added 2.2UF film capacitor in series with Live wire.

Over the past year I’ve had to replace multiple LED lights with Day Night switch sensors in them. after multiple failures I decided to open one up to take a closer look at the cause for failure. Usually the LEDs are running hot and driven very hard from the factory so it’s not uncommon to see many black spots indicating burnt out LEDs in the light.

One way of extending the life of the led light is to reduce the power burning out the LEDs. This can be done easily by inserting an AC film capacitor in series with the live wire before connecting it to the light. this works great for reducing power and thus reducing the brightness of the light but it did not solve my issue.

2.2uf film capacitor helps reduce the power and strain on the LEDs.

In this case my light fails to switch on. when I opened it… The LEDs were still ok now on looking at the day night sensor I determined that the circuitry had failed. Failed how?

Well I had to investigate for a bit but eventually determined that the capacitive dropper was not supplying enough current for the transistor to swich from day to night. Why?

Day night sensor in the 30W light.


Well because the capacitor value had decreased somehow.
seems that low quality film AC capacitors are used and their capacity drops maybe they deteriorate or loose electrolytic liquid I’m not exactly sure but when I replaced the capacitor with a new one everything worked again.

Faulty capacitor should be 220nf.
Replacement and faulty. Both questionable quality…

DIY LORA MODULE

#115 Making A DIY LoRa Module

2x DIY LoRa RFM95W modules with adapter boards.

When taking a closer look at the DIY aspect of lora I wanted to test LoRa peer to peer.. E.G multiple peers to one peer (NOT LoRa WAN) I noticed that the actual radio PCB is difficult to use when going the traditional through hole way… adapter boards do exist but are few and far between at least in SA. you can make your own for manufacture but then rather create your entire product PCB for manufacture.

Even with this drawback I was able to source old adapters for one of the very firs modules the: RFM95W. In South Africa we are mostly using 868Mhz although 433Mhz modules are around I don’t see them being super common in terms of LoRa modules.

The modules I used have a footprint for adding a female SMA connecter for easy antenna connecting.

Parts used:

  • 2x RFM95W 868Mhz LoRa module transceiver
  • 2x 3.3v active buzzer
  • 2x 1 pole dip switch
  • 2x TP4056 module with protection ICs
  • 2x ATtiny404 MCU
  • 2x NCV8163 3.3V LDO
  • 2x SSD1306 128×32 OLED
  • 2x 2pin 2.5mm JST battery connector
  • 2x Headers and jumpers
  • 2x 13400 3.7V 550mAh
  • 2x 10k resistors
  • 2x 220R resistors
  • 2x SOIC to DIP adapter PCB
  • 2x BC547 transistors
  • Some 0.9mm tin plated copper wire
  • Some 0.255mm PVC insulated wire
Soldering made slightly easier…

After checking the PCB I commenced with testing the devices. Unfortunately the test area has largely mountains terrain
the signal works really well and penetrates better through foliage on the mountains terrain but once there is a full on mountain in the way the signal stops. so in this retrospect the devices are better then a radio which was quite interesting but makes sense because data is being sent and uses less bandwidth then interpreting voice audio. Also the error checking for LoRa helps a lot.

Some more pros for the LoRa is that its a transceiver out of the box with RSSI functions included. Also for increased range and/or quality the spreading factor and signal bandwidth can be adjusted.

Although there’s many pros regarding LoRa I still tend to use simple 433.92 RF modules without issue at least in my situation with rural areas under about 3KM at and given point.

So it really becomes more of a cost factor than anything else. Although I’m happy selling a custom LoRa product for compatibility with LoRa WAN or some other requirement with a similar principal. Plain old generic RF is still cool in my book.

Back of one of the PCBs