Saturday, 17 February 2018

Pre-Meeting, February 17, 2018 - Arduino Shift Register Control of R-2R 8-bit DAC to Astable Multi-vibrator (1/2 556 Timer)

Hi Y'all!
We hope to see y'all tomorrow at the RPUG Meeting at the library. I have been working on getting a shift register to control the frequency played by an astable 555 timer. Two shift registers are connected to LEDs at this point so it is pretty close. I am building the astable multi-vibrator right now.
The idea is to test the breadboarded device with one shift register. That will give it 8 bits to work with: 5V / 255 = 19.6 mV per bit.
Once I get that running, I will expand the DAC to more than 8 bits, giving more resolution to the frequency. Blah, blah, blah, until you realize that with more bits, you get greater control over the tones you can play. One of the interesting possibilities of using shift registers to control R-2R DACs is that you control the bit resolution. You can pick and choose how many bits are used to control each device. A web search on R-2R DACs will give you the idea that I am talking about. I can take 4 bits from one shift register to add to the first shift register and then use the remaining 4 bits to control something else.
An Arduino Nano is the brains at the moment but it should work with any other Arduino, even a 3V one, such as an Arduino Due. A 3V signal still registers with 5V logic ICs as a high signal so all that stuff will work. Watch out trying to go the other way, sending 5V signals to a 3V device. Many 3V devices will be damaged by 5V signals.
See you tomorrow!

Look for the next post with schematics and equations for all that technical stuff.

Wednesday, 20 December 2017

Raspberry Pi User Group Meeting - November 19, 2017

We have a few core people who show to our meetings at the New Glasgow Library. This meeting was no different that way.

What was new was the free Stepped Tone Generator / APC kit we have to offer. The Stepped Tone Generator is actually a circuit taken from "Engineer's Mini Notebook, Vol.1 - Timer, Op Amp & Optoelectronic Circuits & Projects," by Forrest Mims III. APC or Atari Punk Console is the name that was given to the circuit by some electronics designer who made it their own. The circuit's sound is pretty lo-fi so imagine something that might come from an old 80's video game, thus the APC name. The circuit's central component is the 555 timer. I am writing another post with this circuit so you can also reference that post as well.

We built one of the kits that I had to make sure all the components worked and they did. I also had another circuit of the same that I had made before and had taken to the meeting. We tried to get it to work but found it did not. Well, ... time to troubleshoot.

Stepped Tone Generator / APC Schematic:


Anytime something does not work in your electronics projects is an opportunity to learn and to practice. Now, it had been sometime since I had to troubleshoot anything past something like a misplaced power supply lead to one of my circuits. It took a little time to figure out what was wrong. Even then, it was only after we had fixed the circuit had I realized what must have been wrong.

We started out checking all the wires to see if any were missing or misplaced. Then we started using the DMM (digital multi-meter). We swapped speakers and even IC's. While using the DMM it was seen that the voltage level on the middle lead one of the pots was not as it should be.

We are using the square blue trimpots for the kits because they are 1) more convenient to use in solderless breadboards and 2) they cost a lot less per item. To use a metal potentiometer would require at least leads soldered on to the lugs and then, if it were not mounted on something, it would hang free, useable but subject to disconnecting easily. Below are some examples of trimpots. Note that one is on its side and how that relates to the problem I found as described below.

The point is that little blue trimpots can look like they are correctly inserted into a solderless breadboard when they are not. Without really realizing what was wrong with the pot, it was removed, reinserted into an unused portion of the solderless breadboard and leads inserted into appropriate holes to allow DMM leads to take measurements. The pot was fine. It was reinserted into the circuit and presto, the circuit worked.

After the meeting, I realized that yes, the problem was with the potentiometer. It must have been inserted sideways so that two of the leads were connected and the third lead connected to the rest of the circuit to follow. However, the lead that was supposed to be connected to the power rail was not. So no power was supplied to the variable voltage divider found on the left side of the schematic.

Wednesday, 13 December 2017

A Beginner's Journey into DIY Synthesis

Hi. If you have found this blog, surprise! You have stumbled upon a pretty new blog on DIY synthesis, for music, not for another field of electronics such as Ham Radio.

My name is Bruce and I have been building occasional projects in electronics for a number of years. Lately, I would like to have a general focus on music. Music is another hobby of mine. I play guitars and have a Casio XW-G1 synthesizer. Patchblocks are another type of synthesizer that I have recently started exploring. The room to move with this platform is so great and not a bad way to learn about how synthesis modules are put together. Patchblocks software is free to try out. Just stick with learning the tutorials found in the IDE and you will make some interesting sounds. There are also a number of ready-to-go patches before you even learn how to program. Really cool stuff.

One thing I have found over the years is that after playing a musical instrument, I began appreciating other genres of music. Originally, I like rock, classic rock and alternative. Learning how to play harmonica (my first choice in musical instruments) and then guitar, really opened up my horizons. I started to listen to more country and folk music. I appreciate some electronic music, some bluegrass, a little more metal, more classical and some that I find hard to pin down.

To bring this rambling back to DIY synthesis, I will purport that one type or area of electronic synthesis is superior over another, at least not yet. I know that some synthesizers sound better than others and there are many that are classics. What is comes down to some of the time is that you buy, use, and make what you can afford. Budget it whatever way you like so if you really want to stick with only exploring analog circuits, save for a bit and buy what you need. I like to explore a lot of different areas of electronics so I have Arduino's, PIC IC's, Basic Stamp II's, LM324's, 555 and 556 Timer IC's, as well as a number of other components.

Books tend to be a great resource for me. I have some electronic engineering technician textbooks, some hobby electronics books that cover a wide range of topics and lots of other books. Programming languages are also great. I have experimented with C, Arduino C, C++, BASIC, and Python. Processing is another environment that I have dabbled in and think has great potential for me. Just look at the Processing Exhibition page and you see lots of different project ranging from physical interaction to data collection and representation.

In the blog entries to come, do not be surprised to see one area covered such as oscillators made from analog circuits and then others made from digital IC's. I hope to have some interested readers so drop a line if you like. Let me know what you think.

Sunday, 22 October 2017

Raspberry Pi User Group Meeting (RPUG) - October 15, 2017

Our last meeting at the New Glasgow Library was pretty low key. We are looking at putting together some workshops on basic and some not-so-basic topics.

I really want to make a simple project - a Four Op Amp Function Generator. Forrest Mims provides a schematic in his first Engineer's notebook. You can find all kinds of examples of schematics online. One of the nice things is that it can fit on a single solderless breadboard. There are even IC's that come in packages containing 4 op amps although any op amp should work. I plan on using an LM324. They are on order.

I have some other IC's of op amps, actually some NTE947's for which I used the pinout to redraw the schematic. One of the nice things of drawing schematics using IC's is that you can often just use the old schematic and change the pin numbers specified by the new IC. If you have ever tried to draw a schematic using the pinout of an IC, you will quickly realize that there is an art to the whole thing.

Look for a workshop coming soon.

... by the way, I am also taking a ham radio course with the local amateur radio club, Pictou County Amateur Radio Club.

Here is their link:
Pictou County Amateur Radio Club,

Saturday, 21 October 2017

ESP8266 / nodeMCU and DHT11

October 21, 2017

This will be a short post. This will have a date on it, I am sure. But, I am posting material that will likely become dated soon, so I want that in the text of the post as well.

The ESP8266 IC is a great boon to the electronics hobbyist. I have been using a nodeMCU version lately and have had some good amount of success although there has been a lot of digging to get things to work correctly.

While using information found on the Web is usually free, I still like books. So, I bought a book: "Internet of Things with ESP8266," by Marco Schwartz - in PDF.

After spending several hours on the small project of getting a DHT11 sensor to work with my nodeMCU, I finally figured out that my DHT libaries were out-of-date. The simple solution was to install Adafruit's DHT library and their Adafruit_Sensor library.

Here is the link to using a DHTXX sensor on Adafruit:

My setup is seen below:

The thing to realize, when you use an ESP8266 module of some sort. is that you need to know what pins are being used in the Arduino code. Here is a typical image of a nodeMCU layout:
A little hint: when you go to write your code in the Arduino IDE, make sure you use the correct pin. Looking at the layout above, D1 is GPIO5. In a typical DHT11 example program you will see digital pin 2 used to get data from the sensor. I changed that to 5, as was in the code in the book. The point is that nodeMCU pins will often not work with with Arduino board code and changes will be needed. Then you also have to make sure you are getting the correct numbers for whatever ESP8266 module you are using.

I will not bother posting the code as you can find it online in different places. Hopefully, it will be enough assistance to those with similar problems in keeping their libraries up-to-date. I guess that is my own lesson as well. If I come across more problems that I are worth posting, I will.

Friday, 6 October 2017

Raspberry Pi User Group Meeting, September 24, 2017

RPUG had its first meeting of the season Sunday, September 24, 2017, 2-5pm.

Where?       New Glasgow Library
                   182 Dalhousie Street
                   New Glasgow, NS

We will be meeting the 3rd Sunday of the month for the rest of the season. Easy to remember but here is the list of the dates:

October 15, 2 - 4:30pm
November 19, 2 - 4:30pm
December 17, 2 - 4:30pm
January 21, 2 - 4:30pm
February 18, 2 - 4:30pm
March 18, 2 - 4:30pm
April 15, 2 - 4:30pm

Once the library closes on Sundays for the season we will be considering whether or not to continue for a couple of months on Saturdays and then stop for the summer.

As I needed the photocells for another project this summer, I took the mounted ones from the robot. During the RPUG meeting we decided to figure out how the line sensor works. Here is a picture of the underside of the robot with the line sensor on the right:
We connected the line sensor to the Boarduino, wrote a quick sketch to test it, and started figuring it out. The nice thing about sensors connected to Arduinos is that many of them have three connections: power usually at 5V, a common or GND, and a signal. The signal tends to be an analog voltage. However, because Arduino often uses the PWM pins to simulate an analogue voltage, I will be checking the output signal of this line sensor with an oscilloscope. If it is truly an analogue output signal, the reading on the oscilloscope will be a steady level voltage. If uses PWM to simulate an analogue voltage, the output will be a rectangle wave with high side, the duty cycle varies with the higher the voltage.

What the ADC sees on the Arduino is that the voltage from the sensor signal actually takes time to fall to zero. If not, the ADC would have to provide numbers that reflected both high and low values of the signal. This topic can be searched on the Web if more is needed.

Here is a simple sketch to test the line sensor:
/* program: robot_line_follow_2_blog.ino
 * This program is used to test the line sensor only.
int line_sensor = 0;  // variable to hold data from reading infrared sensor on A3

int analogPin3 = 3; // the line sensor is connected to this ADC

void setup() {
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);

void loop() {
  int drive_type;
  Serial.println("Inside loop");
  line_sensor = analogRead(analogPin3);
  Serial.print("line_sensor = ");


When the sensor is first tested, it could be that it is not adjusted properly. We figured that out without too much experimenting and without looking up a tutorial online. In the picture there is a trim pot with a white top that allows for a Phillips head screwdriver. With the sensor powered, turn the pot until the red LED turns on.

At that point, when the program runs, the red LED should shine and placing something black under the sensor will turn the red LED off and the readings will change from a low number (around 8 to 12 with no dark object) to a high number (around 800 to 920 with a dark object). When this happens, you know the line sensor works properly.

It might happen that your line sensor goes from on to off when you set the robot (or whatever your project is) down. Readjust the trim pot and set it down again. Keep adjusting the trim pot until the red LED stays lit. Test again.

What happened to us when we first tested it were ADC readings that varied from  800 (no black object under the sensor) to approximately 920 (with a black object under the sensor). You could operate your line sensor that way and write your program accordingly. This might even be useful if your line to follow might be some other colour than dark black. The red LED was not lit when the line sensor was used in this manner.

We also took some time to test the motors by using some arbitrary programming. The idea was to get the robot to turn one direction and then the other. It only turned left and periodically more sharply left than others, even when it was told to go right. Looking back it is, what was happening was the use of PWM on geared motors needs the motors to be signalled to completely stop or changed direction for a long enough period of time so the momentum does not carry the robot through its last turn.

Look for some general electronics tutorials in the future, especially to be provided at the RPUG Meetings. I am currently working on one involving 555 and 556 timers - Forrest Mims' Stepped Tone Generator (on the Web aka APC or Atari Punk Console). Another planned tutorial for the near future is a commonly found Four Op Amp Function Generator. However, my addition will be control of frequency using an Arduino to provide high resolution control with an R-2R Ladder Network DAC. It would be in the neighbourhood of 16-bit resolution with two 74HC595 shift registers. Of course, some of these will also look on putting an RPi spin on the topic.

Sunday, 18 June 2017

Raspberry Pi User Group, June 17, 2017

Happy Father's Day to all the fathers out there, and their families!

Today is also the day of the Johnny Miles marathon and we still have runners going by the house. Lots of the energy there!

Raspberry Pi User Group Meeting, June 17, 2017
Place: New Glasgow Library, New Glasgow, NS

Arduino / Python Serial Communications Using PySerial:

We had a Raspberry Pi User Group Meeting yesterday, June 17th. I was working on my robot yesterday. I am working through some tutorials on YouTube about Arduino and Python Serial Communications. I had looked up a number of tutorials online and worked through a couple of them. However, whenever I tried to do something that expanded on the ideas presented, it never worked. That is why I did some more searching and found the topic above.

Here is a link to the first video of a good set:

These videos are short and very relevant to how I want to use an Arduino and a Raspberry Pi Zero Wireless together on my robot. To make things really simple, I am using a USB cable to interface Arduino and Python. For testing and learning purposes, I am using a PC running Ubuntu with my Arduino. Using Linux and Arduino really cuts down on prototyping time as the programs compile and upload very quickly with such a system. It also works fairly quickly to actually develop on the Raspberry Pi Zero W but, there it time to go back and forth between the RPi and a PC to view any kind of web-based tutorials.

By the way, this topic uses PySerial and works with Python 2 and Python 3.

The Robot:

This is my robot in its current state:

This is a mess of wires! However, if you take the time to look through the wires,
you can see the USB Boarduino in the middle, the photocells are to the left setup as voltage dividers with the resistors in the breadboards. The new additions as of late are the H-bridge motor drivers on what is the front right and right side of the robot. I placed the RPi Zero W and a USB hub to give an idea of what is to be added. It looks like I will have to add another layer to the chassis to fit the other devices. I might also add a 16x2 LCD and some push buttons. Once I get it going, I will consider refactoring it by soldering together some permanent circuit boards for the H-bridge motor drivers and the photocell/resistor voltage dividers to free up the solderless breadboards.

Underneath are the geared motors with wheels, the battery pack with
rechargeable batteries, and the swivel caster wheel. The battery pack is held in place with two elastics. You can also see the IR sensor on the bottom that will allow the robot to be line-following. It is not hooked up yet as I have not made it light-following yet.
 The motors work and so do the photocells. I need to normalize the three photocell/resistor voltage dividers to allow for easy programming of signals going to the motor drivers. That way it will follow light uniformly for light shone on all three photocells.

PAW Server:

For a change in direction, and possible use on a robot at some point, we checked out running a web server on an old Android phone. I chose a tutorial on the PAW Web Server which is a simple app that runs on Android without having to root the device. It has some excellent features but keep in mind that a single-core 800 MHz, 512 MB RAM device will not run much at blazing fast speeds.

All the same, it is fun to use a webcam server, robot text-to-speech, and of course, serving up actual webpages. There is too much to describe but it looks very useful and the interface is very easy to use. Just search for tutorials on the PAW Server and you should find something to guide through orientation.

List of Topics To Date:

Here is an updated list of things we have worked on or covered in some way, to date:
  • Raspberry Pi radio - your own little FM broadcaster!
  • Command line music players and how to use them to edit music files
  • FlightRadar24 - watch airline data
  • How to set up your RPi the first time
  • Minecraft Pi workshop - programming in Python to make your own custom Minecraft game
  • How to make an LED turn on and off using Python and RPi General Purpose Input/Output (GPIO) pins
  • Free RPi material such as magazines and short books provided by "The MagPi" magazine
  •  Setting up your own private LAN (not Internet accessible). This is useful for places where organizations keep their own Internet Accessible LAN locked down. This means you cannot do simple things such as using SSH to login into your RPi. If you set up your own private LAN, you can connect both your PC and RPi and login remotely using SSH.
  • Run a servo motor using Python.
  • RPi 3 as desktop PC replacement - would do if that was all you had but, not really recommended.
  • RPi 3 - 3.5 inch touchsreen
  • Starting to explore Arduino/RPi Zero W USB communications (same as Arduino/Python Serial Commuinications)
  • Forward/Reverse Relay modules
If you would like to see something specific covered, drop me a line! You can also drop by the meetings once they resume again in September, 2017.