Tuesday, February 14, 2017

KK4HFJ HF Station is up and running!

I finally made the move from 2m EmComm's to HF work. I'm still working 2m off the local repeaters, but it's nice to be able to reach around the world. I installed a Kenwood TS-430 HF rig, a AT-250 Antenna Tuner, a MFJ G5RV dipole, and a dell server power supply to keep it all fed and quiet. You can find me most evenings on 40m, usually around 7.18 Mhz.

KK4HFJ Monitoring .....

Friday, January 27, 2017

STEMTera - Arduino in a LEGO Breadboard

Sparkfun is coming out with a new breadboard that includes a Arduino in a LEGO compatible base. All the ATmega328P and ATmega16U2’s I/O pins are broken out and available. The breadboard has shield compatible pinouts (yes, the weird offset is there). A bit more than you would pay for a Arduino UNO, but the convenience of having a breadboard and complete access to all the pins makes up for it. This is a perfect teaching tool!

https://www.sparkfun.com/products/14082


Tuesday, January 3, 2017

Model Railroad Crossing Lights

For the Charleston Area Model Railroad Club, We have combined our train detector circuit from the scale speedometer project with a LED Crossing Light to make it simple to indicate a train is coming to a crossing. The next step is to add a servo operated crossing bar, and bell sounds, but I'm getting ahead of myself.

The Circuit:
The detection circuit is the same as the scale speedometer. A TCRT5000 IR LED / Phototransistor pair, with two resistors, connected to an Arduino input (D8). You can lower the value of the Phototransistor pullup resistor to 10k-50k ohm (instead of 80k-100k ohm) to reduce it's sensitivity to ambient light. Increase the value of the IR LED resistor (68 Ohm) to reduce range. Never drop IR resistor below 68 Ohms.

The output is a off the shelf LED crossbuck with 2 red LED's and a common anode. I put a 300 ohm resistor on the common and connected to 5v, and connected the two cathodes directly to arduino outputs D11 and D12. Add a second LED Crossbuck (with resistor) to the same outputs for the other side of the crossing. See the video below the code.

The code checks to see if the phototransistor is lit (a 0 or LOW), and activates the lights (LOW is lit, HIGH is off)) as long as it is.


//int sensor1 = 1;


void setup() {
  Serial.begin(9600);
  pinMode(8, INPUT);
  pinMode(12, OUTPUT);
  pinMode(11, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(11, HIGH);
  digitalWrite(12, HIGH);

  int sensor1 = digitalRead(8);
  Serial.println(sensor1);
  if (sensor1 == LOW){
    digitalWrite(12, HIGH);
    digitalWrite(11, LOW);
    delay(1000);            
    digitalWrite(12, LOW);
    digitalWrite(11, HIGH);
    delay(1000);
  }
           
}


Finished board for two track sensors and 2 crossing lights.



Monday, January 2, 2017

Model Railroad Turnout Control - Arduino MOSFET

One of the projects we are working on is Turnout Control. Most home layouts are using Atlas or Bachmann track with solenoid type turnouts like the one shown here. More professional layouts use slow moving motors like the Tortoise. Our goal is to make these turnouts controllable with an arduino, so that future projects using train detectors and DCC can allow more automation. So here is the beginning of our project. This one uses the above Bachmann turnout (arduino servo control article coming soon), a arduino nano, two IRL520 MOSFETS, two resistors, and two diodes. The schematic is as follows:


The diodes protect the MOSFET from inductive spikes when the solenoid coils fire. The two MOSFETS engage the solenoid coils to move the turnout. the two resistors keep the MOSFET from randomly conducting when there's no input signal, by pulling the gate to ground (off). This uses two digital outputs on the arduino called straight and turn. The next article will show the board layout and wiring of the arduino, turnout and power supply. For more projects based on MOSFETS, see http://arduinotronics.blogspot.com/search?q=mosfet

Saturday, December 31, 2016

Arduino Cousins Rejoined in 1.8.0

The two forks of the Arduino IDE have been rejoined into one. No longer are there separate IDE's from Arduino.cc and Arduino.org. Boards from both companies and new additions from Adafruit are supported. This is great news for the Arduino Community. Requires Java 8 to run, but well worth the upgrade!


Arduino IDE 1.8.0 works out of the box with AVR boards, like the Uno, Mega, Yun, and Micro, among the most popular. Additionally, it supports the Leonardo Ethernet, Yun Mini, Industrial 101, and Uno WiFi.

The updated SAMD core will provide support for the M0 and M0 PRO, completing the product line that includes the Zero, MKR1000, and the newly-launched Primo and MKRZero.

Wednesday, December 28, 2016

The Pixel OS Controversy

There's been a lot of "news" about the Raspberry Pi Foundations new Pixel OS. Lets dig in and take a look at what the hubbub is all about.

First of all, contrary to much of the misinformation by the BBC, Guardian, and others, it's not an OS.

It's an alternative DE (Desktop Environment), much like gnome, LXDE, and others, that sits on top of a linux OS. That's it, nothing more.

As a DE, it's lightweight (needed for limited resource machines like the Raspberry Pi), and very pretty. It's fully available for the Raspberry Pi, or you You can download an image bundled with debian and try it in preview mode on a intel based pc. Preview mode? Yes, you cannot install it on your computer, as it's a "developmental beta", not an installable DE.

The good news? Eventually it will be a usable option not only on the Raspberry Pi, but other platforms like Intel based pc's. Eventually.

Monday, December 12, 2016

Arduino Model Railroad Animation

As part of my journey looking for new projects for the club layout, I just finished a book called Arduino Model Railroad Animation. It covers using servos to operate semaphores, water tank, cranes and other trackside accessories. This is a good practical guide to electro-mechanical automation using an Arduino as the brain. The authors (Paul and David Bradt) have a few other Arduino books as well that are equally good. We are working on a project using servos to actuate turnouts and microswitches.

Arduino Model Railroad Animation

Arduino Model Railroad Signals

Arduino Force, Pressure, Friction and Acceleration Science Fair Projects

Arduino Heat Transfer Science Fair Projects

Saturday, November 26, 2016

Arduino Model Railroad Scale Speedometer - Finished

We finally finished the Scale Speedometer Project, and are heading off to the Charleston Area Model Railroad Club to install it. We used the Adafruit I2C 7 Segment backpack, a Arduino Nano clone, and two IR transceivers, for  total project cost of around $20. The code below is fully functional, all you need to do is adjust your scale, and distance between the sensors. Make sure your sensors do not extend above the height of the rails, or couplers could catch on them. I used a dremel to route out the holes, and superglue to fix them in place, but superglue leaves a white residue, so you may want to try a different adhesive. Watch the video!

Arduino Nano Clone
7 Segment BackPack
IR sensors

Use the Adafruit Tutorial to assemble and connect your 7 segment backpack. Use the IR Sensor Tutorial to connect the IR sensors.

Update: Decreasing the resistance of the IR LED resistor (we finally used 100 Ohm) or increasing the resistance of the pullup resistor on the photo-transistor (we finally used 100k) can make the circuit more sensitive (up to 15mm depending on reflectance of car bottom), especially for larger scales with larger gaps. Do not burn out the IR LED with too low of a resistance (no less than 68 Ohm, 1/2w at 5v input).

#include  "Wire.h"
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"

Adafruit_7segment matrix = Adafruit_7segment();

//user variables
float distance = 24; //inches between sensors
int scale=87;

int sensor1 = 4;
int sensor2 = 5;
bool s1Covered;
bool s2Covered;
float start, finish, elapsed, miles, hours, mph, scaleMPH;

int started=0, finished=0;
int scale=87;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(sensor1, INPUT);
  pinMode(sensor2, INPUT);
  matrix.begin(0x70);

}

void loop() {
  // put your main code here, to run repeatedly:
  //Serial.println("Ready ....");
  matrix.print(0.0);
  matrix.writeDisplay();
    //finished=0;
    s1Covered=digitalRead(sensor1);
    if (s1Covered==0 && started==0){
      start=millis();
      started=1;
      Serial.println("Started");
   
    }
    s2Covered=digitalRead(sensor2);

    if (s2Covered==0 && started==1){
      finish=millis();
      finished=1;
      Serial.println("Finished");
   
  elapsed = finish-start; // millis

  elapsed = elapsed /1000; // seconds
  Serial.print("Seconds: ");
  Serial.println(elapsed);
  miles = distance / 63360; // miles
  hours = elapsed / 3600; // hours
  mph = miles / hours;
  scaleMPH = mph * scale;
  Serial.print("Scale MPH: ");
  Serial.println(scaleMPH);
 
  // print a floating point
  matrix.print(scaleMPH);
  matrix.writeDisplay();
  delay(25000);

  started=0;
  finished=0;
    }
  }


Friday, November 18, 2016

Functional TRS-80 Model 1 on Windows 10?


Ok, what does this have to do with Arduino or Raspberry Pi? Well, I am working on a couple of Pi emulating antique computer projects, and said, let's try this! I could use some financial help with a few projects we are working on, so use the "Donate" button found on this page, and I'll send you a zip file with a working TRS-80 Model 1 emulator (ROM included). Just unzip and run an old friend ....

Tuesday, November 15, 2016

Arduino Scale Speedometer Part 3 - Port Expander

The three 7 segment LED's from part 2 require 24 i/o pins on the Arduino. We can use port expanders to limit that to 2 pins, the I2c connections. Each MCP23017 chip supports 16 i/o pins, so two chips will do, and still only use the two lines on the Arduino, as they are addressable. In our previous two MCP23017 posts we show how to connect and address the MCP23017 chips and provide a link to the datasheet.

1st Digit - Chip 1 Port A Connections:
GPA7 -> A7
GPA6 -> B6
GPA5 -> C4
GPA4 -> D2
GPA3 -> E1
GPA2 -> F9
GPA1 -> G10
GPA0 -> DP5

2nd Digit - Chip 1 Port B Connections:
GPB7 -> A7
GPB6 -> B6
GPB5 -> C4
GPB4 -> D2
GPB3 -> E1
GPB2 -> F9
GPB1 -> G10
GPB0 -> DP5

3rd Digit - Chip 2 Port A Connections:
GPA7 -> A7
GPA6 -> B6
GPA5 -> C4
GPA4 -> D2
GPA3 -> E1
GPA2 -> F9
GPA1 -> G10
GPA0 -> DP5



To send the speed determined in part 1 to the 3 digit display, we need to break up the number into 3 separate numbers, the hundreds, tens, and ones position. This is done with a simple calculation:

first=number/100;
second=number%100/10;
third=number%10;

Then in a case statement you can send the correct code to each chip:

switch (var) {
    case 0:
      Wire.write(244); //11110100
      break;
    case 1:
      Wire.write(96); //01100000
      break;
    case 2:
      Wire.write(218); //11011010
      break;
    case 3:
      Wire.write(242); //11110010
      break;
    case 4:
      Wire.write(102); //01100110
      break;
    case 5:
      Wire.write(182); //10110110
      break;
    case 6:
      Wire.write(190); //10111110
      break;
    case 7:
      Wire.write(224); //11100000
      break;
    case 8:
      Wire.write(254); //11111110
      break;
    case 9:
      Wire.write(230); //11100110
      break;
    case DP:
      Wire.write(1); //00000001
      break;
    default:
      // if nothing else matches, do the default
      // default is optional
    break;
  }

Now, if all this seems very complicated, and the 24 wires from the 3 digits to the two MCP23017 chips seems like spaghetti, you are right, and we have chosen to go a different path. The Adafruit I2C 4 digit display. More on that tomorrow .....

Monday, November 14, 2016

Arduino Scale Speedometer Part 2 - 7 Segment LED's

In part two (see part 1 for the train detection circuit) we are addressing the three 7 segment displays. We are using Common Anode displays, so we send a low to each segment to light them up. Use whatever you have available, and use the data sheet for your displays and map accordingly.


 This image shows each segment, and assigns a letter to each, to help with the wiring.






The next image shows the pin numbers and positions looking at the face of the display.

Now we show which segment is assigned to which pin, and the polarity of the pins. Since we are using Common Anode, the LED symbols point down,or away from the common positive (5v) signal (pins 3 & 8). A LOW is sent to each pin to light up the associated segment. If you are using Common Cathode, then the diodes would point up, 3 & 8 would connect to ground, and a HIGH would be sent to each segment to light them.

As is the case with all LED's, a current limiting resistor is needed to prevent the LED from burning out. The one you pick is dependent upon your source voltage, and the LED. We are using 400 Ohm resistors for this project.

The next post will address using a I2C port expander to free up the 24 pins the display uses.

Sunday, November 6, 2016

Arduino Model Railroading - Scale Speedometer

The guys at the Model Railroad Club wanted a scale speedometer displaying the scale speed of the train as it passes a point on the layout. I'm using two IR transceivers connected to an arduino to detect the time it takes to pass between 2 points, and then displaying the scale speed.

Currently we are using the Serial Monitor, but Part 2 will be about the 3 seven segment display and I2C port expander used to drive them.



Wiring:
The circuit diagram is the same as the one we posted here, but just doubled.

Code:

int sensor1 = 4;
int sensor2 = 5;
bool s1Covered;
bool s2Covered;
float start, finish, elapsed, miles, hours, mph, scaleMPH;
float distance = 24; //inches between sensors
int started=0, finished=0;
int scale=87;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(sensor1, INPUT);
  pinMode(sensor2, INPUT);
}

void loop() {
  // put your main code here, to run repeatedly:

    //finished=0;
    s1Covered=digitalRead(sensor1);
    if (s1Covered==0 && started==0){
      start=millis();
      started=1;
      Serial.println("Started");
    }
    s2Covered=digitalRead(sensor2);

    if (s2Covered==0 && started==1){
      finish=millis();
      finished=1;
      Serial.println("Finished");
   
  elapsed = finish-start; // millis

  elapsed = elapsed /1000; // seconds
  Serial.print("Seconds: ");
  Serial.println(elapsed);
  miles = distance / 63360; // miles
  hours = elapsed / 3600; // hours
  mph = miles / hours;
  scaleMPH = mph * scale;
  Serial.print("Scale MPH: ");
  Serial.println(scaleMPH);
  started=0;
  finished=0;
    }
  }




Saturday, November 5, 2016

Arduino Model Railroading - Simulated Flickering Fire

Another cool exhibit on your model railroad is flickering firelight. Whether it's a hobo campfire, or a burning building, this adds to the layout's realism. A Arduino, 3 130 ohm resistors, two yellow LEDs, one red LED, and you have a fire. Add a locomotive smoke unit for additional realism. This project is provided by Mike McRoberts.


Just connect a wire from pin 9 to the resistor, from the resistor to the long leg (+) of your LED, and the short leg to Ground. Repeat for pins 10 & 11. We put the red LED on pin 10, and the 2 yellows on 9 & 11.
Code:

// LED Fire Effect

int ledPin1 = 10;
int ledPin2 = 9;
int ledPin3 = 11;

void setup()
{
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
}

void loop() {
analogWrite(ledPin1, random(120)+135);
analogWrite(ledPin2, random(120)+135);
analogWrite(ledPin3, random(120)+135);
delay(random(100));
}


Arduino Model Railroading - Arc Welder Flash

The guys at the Charleston Model Railroad Club asked for a simulated flash of an arc welder. A $4 (was $2.50, price went up since we purchased) arduino nano clone, a 130 ohm resistor, and a white LED later, they have their arc welder. This is a fun and inexpensive project that adds to the realism of your layout!

Project inspired by the work at http://mrrwa.org/wp-content/uploads/2011/07/ModelRailroadingWithArduino.pdf

Just connect a wire from pin 9 to the resistor, from the resistor to the long leg (+) of your LED, and the short leg to Ground.


Code:

int ledPin = 9; // LED connected to digital pin 9
int i;
int count;

void setup()
{
pinMode(ledPin, OUTPUT);
}

void loop()
{
count=random(10,60);
for (i=0;i{
digitalWrite(ledPin, HIGH); // set the LED on
delay(random(60));
digitalWrite(ledPin, LOW); // set the LED off
delay(random(200));
}
delay(random(800,2000)); // wait a random bit of time
}







Monday, October 3, 2016

New Book: The Citizen Scientist's Guide to using the Arduino & Raspberry Pi

Our new book is online, a chapter at a time. We have a dozen chapters in various stages of proofing and testing, and have the first 3 uploaded and available at http://arduinotronics.blogspot.com/p/citizen-science-book.html, so check them out, and leave us feedback on thoughts, problems, ideas, etc.

Posted chapters will be improved and added to and new chapters added, so keep coming back for more.