Check out my music: https://soundcloud.com/playinmyblues

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, http://pcarc.ca/

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:
https://learn.adafruit.com/dht/overview

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:
[code]
/* 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);
  Serial.begin(9600);
}

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

  delay(1000);
}
[/code]

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.