Showing posts with label GLCD. Show all posts
Showing posts with label GLCD. Show all posts

Sunday, 10 February 2013

Air rifle chronograph

Latest project update for 2026 here


For some time now I've had an old Diana air rifle in the garage gathering dust and it's been a long time since I used it but I recently got interested again and even bought myself an air pistol.


As usual I like to have a tinker with anything I can, including my air guns.

One important tool you need when tinkering with airguns is a chronograph, this lets you check the power of the gun to make sure you don't go over the legal limit allowed for the maximum energy.

To buy a small clip on chronograph was going to cost me £49..... "hang on" I thought, I've got all the parts I need to make my own chronograph using the Jeenode.

So, the basic idea is to put two IR beams about 100mm apart in a tube and use the jeenode to time the duration between the first and second beams being broken by the pellet.

If you know the weight of the pellet, the speed and distance travelled then you can calculate the energy used to fire the pellet.

Some googling had come across a few projects form other people and given me a few good tips and even some basic code to start with.

Where my chronograph would be different was that I was going to use the RFM12B to transmit the timing information to a remote receiving station using my "alternate jeenode" and displaying the information on the GLCD.

I chose IR sensors that had a buffered logic output, this would give a clean square trigger signal.  They're also quite fast at 25nS rise/fall times.


OPTEK TECHNOLOGY - OPL550A - PHOTO SENSOR

I Chose the matching IR LED to go with the sensor, OPTEK TECHNOLOGY - OP240A. - IR EMITTING DIODE

So, I started the prototyping whilst waiting for the IR sensors to arrive, to test the code I used a couple of switches to simulate the trigger sensors.

And used an oscilloscope to get an idea of what the real timing was and sorted out the code until it matched the oscilloscope measurements.

Cursors placed on the leading edges on channels A (trigger 1) and B (trigger 2)

When the sensors arrived I used some plastic waste tube I found in the garage to mock up the triggers at 4 inches apart.

I tried out the sensors by dropping some objects down the tube and reading the results via the serial link to my PC, all seemed well and the times were in the ball park when compared to some calculations I'd done earlier.

..... Next steps, write the receiver code for a 4x20 LCD and also the GLCD and maybe look at a VB programme to receive the data on a PC and display the results.



Saturday, 29 September 2012

My Alternate Jeenode

The Processor board for my shields arrived this morning and I've finished assembling the parts and tested the GLCD, RFM12B and the SD Card socket.

One of the main reasons behind this PCB is so I can have a driver for the Jeelabs GLCD that is physically smaller than the GLCD PCB and will be easier to mount in an enclosure but now all sorts of ideas are now springing forth!

This is the first time I've used a few SMD components, I'm using the 1206 size because I can just about manage them without too much eye strain.

So far I've tested the GLCD, RFM12B and SD card reader and all seems OK so far.

Eagle Files for PCB are here.

Top view
Bottom View

Screen grab of SD card info sketch.

So far so good, all going to plan.


Monday, 24 September 2012

My own Arduino Shields

Having spent a while playing with the some of the different options available in the world Arduino open hardware and software and discovering a very reasonably priced source of PCB manufacture I've spent more time designing the hardware than I have the software side of things, I have a few plans for final applications but keep getting side tracked by new ideas of what to do with the hardware.

Anyway my latest idea was to create my own PCB to plug on the back of the GLCD hardware from Jeelabs, one that was a similar size and shape to the GLCD.

Whilst doing that I was also thinking about producing a CAN interface PCB for the new layout that could be sandwiched between the processor PCB and the GLCD PCB and I wanted a method to allow me to validate the PCBs within a 3D environment.  After a quick Google I found that there were scripts written which would allow the PCB in Ealge (Circuit layout and PCB design software) to be exported in a format that would allow Google SketchUp (Free 3D design software) to import the PCB with holes, vias, silk text and tracks, this made it a lot easier to visualise the PCBs and hopefully spot any errors prior to ordering the PCBs.

Within Google  SketchUp  there is access to the 3D Warehouse where people generate models for all sorts of things and make them available for other people to use and there are quite a few electronic components in there, including Arduino boards.

I also had to model a few parts myself, like the Jeelabs GLCD and PCB assembly, Sparkfun's Basic FDTI board.  If you want to use the models just search for GLCD in the 3D warehouse and you should find them.

If the Eagle export setup is configured correctly and the models are available in the correct folder the export will also include the components on the PCB as well.

The the setup tutorial and link to the software download can be found here.

Here are some of the exports I made from Eagle, these have also been rendered by a  SketchUp  plugin called Maxwell.
The three PCBs exploded view and rendered

CAN Interface PCB with most of the components

GLCD board plugged into the processor board

All three stacked together

Wednesday, 29 August 2012

All in one Prototyping PCB assembly

The assembly of the PCBs finally got started over the weekend and so far I'm pretty pleased with them, I've spotted a couple of minor issues so far but nothing that can't be fixed with a sharp knife some wire and a soldering iron.

Eagle files can be found here, they are version 2 with the power supply fixed and an added higher power 5V regulator.

So far I've only tried the ATMega 328p and it's peripherals, the ATtiny84 can wait until next weekend.


Firstly I added all the resistors, they need to be quite small resistor, physically that is, as I only used a 5mm lead pitch package.  I then added the voltage regulators so I could check that power appeared correctly at all the places it should do and at the right level.

This is where I spotted my first error, originally I'd planned to feed the 3.3V regulator from the output of the 5V regulator but then for some strange reason I changed it so both regulator inputs were tied together, unfortunately this meant that when the USB to serial (FTDI) was connected it wouldn't supply the 3.3V regulator and therefore the processor wouldn't be powered.

I cut the track from the supply to the input of the 3.3V regulator and wired it to the output of the 5V regulator. this meant that the FTDI 5V was fed into the 3.3V regulator and supplied the processor.


One of the first things I tried when I got the boards was to plug in the GLCD from Jeelabs as I use this quite a lot, luckily it fit perfectly and it even works.


Today the RTC chip arrived with a clock crystal and was soldered in place, not as difficult as I thought it would be.
Added a CR2032, loaded the RTC sketch and used my RTC time setting app for the PC to set the time and it worked fine.

So far so good.....

Wednesday, 1 August 2012

All in one Arduino Prototyping solution

I've been interested in the open HW/SW platform "Arduino" for some time now, it has re-ignited my interest in electronics, which hasn't been at the forefront of my hobbies for some time.
My main interest lay in the area of computers and software but with the discovery of the Arduino platform I was able to merge the two together.

I've bought a few pieces of hardware from various sources and  had a dabble at making my own hardware (mainly copied  based from what others have already done).

Anyway I decided I needed a project of my own to get my teeth into, I wanted to learn how to use the Eagle schematic capture and PCB layout software and after discovering Seeedstudio and their very keenly priced PCB manufacture, I decided to make a general purpose PCB that would allow me to tinker with both the ATMega 328 and the ATtiny84 processors along with various extras.

This board isn't aimed at a final solution but more an electronics breadboard much like the old Tandy electronics kits I used to play with many, many years ago.

Basic Features

  • Independent ATMega328p and ATtiny84 on the board
  • Each having its own RFM12B and ISP programming connector.
  • Twin power supplies, 5V and 3.3V with the option of using a CR2032.
  • A series resistor option for measuring supply current, jumpered out if not required.
  • A prototyping area.
  • A 4 port layout like the Jeenode (so I can plug in my GLCD).
  • A RTC (DS1307 3.3V)
  • Two I2C ports connected to the 328P with 5V and 3.3V (should work with Jeelabs plugs)
  • FTDI connector (328p)
I've not ordered the PCBs yet as I'm fine tuning the board still but should be doing it in the next week or so.

PCB
Comments welcome.

Tuesday, 15 May 2012

Remote temp. sensing with GLCD and Jeenodes

It's been a while since I purchased the Jeenodes, the original intention was to get them talking to each other using the wireless tranceivers and the graphics display board to dosplay the received temperatures.
Anyway, life happens and I got distracted and they were put in a drawer .... time went by and I got interested again.
So I've now managed to get the Graphical LCD (GLCD) working and displaying the temperatures and other data from the remote transmitter.
The plan is to have a Jeenode mounted in a waterproof box outside, monitoring the outside temperature and also, using a magnetic reed switch, monitoring the status of the side gate.
So far I've managed to get a Jeenode sending the data from two DS18B20 digital temperature transmitters once every second, then I was able to get the GLCD from Jeelabs to display the temperatures in a normal font.

I decided that the fonts need to be a bit bigger, so it could be easily read from a short distance, this wasn't as easy as I thought it would be, it requires a lot of thought about how many pixels are required to display the temperature.  One disadvantage, albeit a small one, I found with the new library that allowed large fonts was that it didn't clear unused pixels when a new character was drawn over the top of the old one.

A quick visit to the Jeelabs help forum soon pointed me in the right direction, you have to draw a white rectangle over the characters just prior to writing the new ones to the screen, I thought this was a bit of a pain but in reality it's quite simple to add that line prior to any text you send to the display and it isn't noticeable as flicker.  The tricky bit is counting the pixels used in the width across the characters to ensure the rectangle only covers the temp and nothing around it and choosing the font was a bit of trial and error picking the various ones available as I couldn't find a printout of what all the fonts would look like and there are a lot of fonts.
Now I've just got to find a suitable box to put it in, sort out a battery and read up on getting the sketch to consume as little power as possible, I'm waiting for the single AA power board to arrive from Jeelabs.

Friday, 27 May 2011

First project with the Jeenode and GLCD

 Having had my Jeenodes for a while now and eventually got some code to actually work, reading DS18B20s and displaying the results on a 16x2 line display, I fancied getting to grips with the GLCD, also from Jeelabs.
This is just a project to help me learn about the hardware and software, it may be useful in to someone out there.  I've tried to put plenty of comments in the code, mainly so I remember what I did when I look at it in two weeks time.

My target project is to create a portable (small) display that I can control the central heating from, i.e. room temp., heating on/off and hot water temp. control.  This project is the prototype phase.

At first it was a bit of a slog trying to understand the glcd library and how to send float variables to the screen (C++ is a new language for me), after that came the RTC coding to get the time on the screen, especially with leading zeros.

What I eventually came up with was a display showing the time, with leading zeros (thanks to 'sprintf'), two temperature inputs and a trend line showing just over two hours history for the current temperature.

The temperatures are derived from two DS18B20s connected to port2, adding extra sensors should be easy enough.  Each sensor has a Max. and a Min. point displayed.

The trend line is generated by sampling the temp. every minute, based on the now.minute() value from the RTC and then plotted between rows 40 to 60 using the glcd.setpixel command and the map function to map from 10 to 30 degrees C.  This time could be altered to be shorter or longer, as desired.

The hardware is basically a Jeenode V6, GLCD PCB and display, RTC plug (Port 3) and a DS18B20 soldered to a small prototyping board plugged into port 2.
DS18B20 on the Left and the RTC plug on the Right
 
On the DS81B20 PCB there is also a three pin right angle connector for the exernal DS18B20 probe, bought from Ebay.

The sofware is based on the Jeelabs demo sketches from Jeelabs rtcplug and the GLCD demo sketches.

The temperatures are also sent out over the serial link to the PC, formatted as they are seen on the GLCD. 

There are still some issues and some improvements to be made:-
  • The DS18B20 disconnected detection doesn't seem to work.
  • If the DS18B20 is disconnected and then, when reconnected, the Max temp. reads 85 Deg.
 Future improvements
  • To set the time I used another sketch but I plan to add the ability to set the time using my VB software from the PC.
  • Automatically alter the trend line scale based on the readings.
  • Round up the temp. for the pixel to the nearest degree.
  • Make the trend line update in seconds and put it in a variable. 

Next steps
  • Learn how to send/receive remote data from other Jeenode/Uno
  • Find out if I can use different size fonts on the GLCD (not the really big ones)
Sketch below: -
/* Based on Demo display for the Graphics Board and the rtcplug.pde from Jeelabs
 2010-11-14 <jcw@equi4.com> http://opensource.org/licenses/mit-license.php
 
 Added DS18B20 sensors and RTC plug
 Displays time, internal and external temp with min and max readings there is also a trend
 line drawn at the bottom of the LCD.  It samples the current temp. every minute, using RTC,
 and draws a pixel at a point between row 40 to 60, using the map command for temp's between
 10 and 30 degrees.  It takes 126 min's to draw the line then it clears the line and
 starts again.
*/
#include <GLCD_ST7565.h>
#include <Ports.h>
#include <RF12.h> // needed to avoid a linker error :(
#include <avr/pgmspace.h>
#include <OneWire.h>
#include "Wire.h"
#include <RTClib.h>
#include <DallasTemperature.h> //Version 3.6
#define ONE_WIRE_BUS 5  // DS18S20 Temperature chip i/o on pin 5 - Port 2

GLCD_ST7565 glcd;

EMPTY_INTERRUPT(WDT_vect);

OneWire oneWire(ONE_WIRE_BUS);// Setup a oneWire instance to communicate with any OneWire devices
DallasTemperature sensors(&oneWire);// Pass our oneWire reference to Dallas Temperature. 
// Global variables
char outBuf [25];
int MaxTempIn=0; //hold max temp value
int MinTempIn=500; //hold min temp value, pre load with 500 because the first test is against the temp val * 10  
int MaxTempOut=0; //hold max temp value
int MinTempOut=500; //hold min temp value, pre load with 500 because the first test is against the temp val * 10 
int LastMin; //Hold last min value
int x=1; //counter for trend line
int Ypixel; // Y value for trend line
// Insert the ID of your temp sensor here, for the sketch, visit here
// http://www.hacktronics.com/Tutorials/arduino-1-wire-address-finder.html
DeviceAddress insideThermometer = { 0x28, 0x2F, 0x8A, 0xEE, 0x02, 0x00, 0x00, 0xE9 }; // none probe
DeviceAddress outsideThermometer = { 0x28, 0x60, 0x3A, 0x10, 0x03, 0x00, 0x00, 0x38 };
DeviceAddress WaterThermometer = { 0x28, 0xB3, 0x58, 0x18, 0x03, 0x00, 0x00, 0x2B };
class Sleepy;

// RTC based on the DS1307 chip connected via the Ports library
class RTC_Plug : public DeviceI2C {
    // shorthand
    static uint8_t bcd2bin (uint8_t val) { return RTC_DS1307::bcd2bin(val); }
    static uint8_t bin2bcd (uint8_t val) { return RTC_DS1307::bin2bcd(val); }
public:
    RTC_Plug (const PortI2C& port) : DeviceI2C (port, 0x68) {}

    void begin() {}
    
    void adjust(const DateTime& dt) {
        send();
        write(0);
        write(bin2bcd(dt.second()));
        write(bin2bcd(dt.minute()));
        write(bin2bcd(dt.hour()));
        write(bin2bcd(0));
        write(bin2bcd(dt.day()));
        write(bin2bcd(dt.month()));
        write(bin2bcd(dt.year() - 2000));
        write(0);
        stop();
    }

    DateTime now() {
       send();
       write(0); 
        stop();

        receive();
        uint8_t ss = bcd2bin(read(0));
        uint8_t mm = bcd2bin(read(0));
        uint8_t hh = bcd2bin(read(0));
        read(0);
        uint8_t d = bcd2bin(read(0));
        uint8_t m = bcd2bin(read(0));
        uint16_t y = bcd2bin(read(1)) + 2000;
    
        return DateTime (y, m, d, hh, mm, ss);
    }
};

PortI2C i2cBus (3); //RTC on port 3
RTC_Plug RTC (i2cBus);

void setup () {
DateTime now = RTC.now();
LastMin = now.minute(); //Store minute value for use in Draw Graph

// Set serial speed
  Serial.begin(57600);
  // Start RTC
 RTC.begin();
// Power down the Transceiver
    rf12_initialize(1, RF12_868MHZ);
    rf12_sleep(0);
// Start the temp sensors    
    sensors.begin();

// set the resolution to 12 bit
    sensors.setResolution(outsideThermometer, 12);
    sensors.setResolution(insideThermometer, 12);
 //sensors.setResolution(WaterThermometer, 12);
    Wire.begin();

 // Initialise the GLCD
    glcd.begin();
    glcd.backLight(255);
    glcd.drawString_P(0,  10, PSTR("       Now  Max  Min")); //Set the column titles
    //glcd.drawLine(0, 8, 120, 8, WHITE);
    glcd.drawRect(0, 8, 128, 56, WHITE);
    glcd.refresh(); // Update the display
}

void loop () {
 DateTime now = RTC.now();
  sensors.requestTemperatures();// Trigger all the temp sensors to carry out a temp. conversion 
  Sleepy::loseSomeTime(2000); // Do nothing for n seconds, slow update OK
 
  printTemperature(insideThermometer); // Read in the temp. data from the inside sensor
  printTemperature(outsideThermometer); // Read in the temp. data from the outside sensor
  UpdateTime();
  //Trigger a pixel to be drawn on the history every minute
  if(now.minute() > LastMin) {
    DrwGraph();
    LastMin = now.minute();
  }
  if(LastMin > now.minute()) {
  LastMin=1; //reset to 1 as rollover to next hour.
  }
  glcd.refresh();
 }
 
void UpdateTime(){ 
 DateTime now = RTC.now();
 sprintf(outBuf, "Time %02d:%02d",now.hour(), now.minute()); //Format the time without seconds
 glcd.drawString(3, 0, outBuf); //Print to Screen RAM
 Serial.print(now.hour(), DEC);
    Serial.print(':');
    Serial.print(now.minute(), DEC);
    Serial.print(':');
    Serial.print(now.second(), DEC);
    Serial.print(" - ");
    Serial.print(now.day(), DEC);
    Serial.print('/');
    Serial.print(now.month(), DEC);
    Serial.print('/');
    Serial.print(now.year(), DEC);
    Serial.print("\n");
  }

void printTemperature(DeviceAddress deviceAddress) {
int temp2; // Create variable to hold the int value of the float without the decimal 
float tempC = sensors.getTempC(deviceAddress); // read the specific sensor called from loop.

if (deviceAddress == insideThermometer){ //Display Internal Temp

if (tempC == -127) {
      glcd.drawString(10,  20, PSTR("Error"));
} else {
  temp2 =tempC *10 + 0.5; // make now temp decimal value into an integer. remove decimal point
  Ypixel = temp2/10; // Store Y pixel value temp for trend line
  if (MaxTempIn < temp2){ //Set MaxTempIn to temp2 if higher than old MaxtempIn
    MaxTempIn=temp2;
}
if (MinTempIn > temp2) { //Set MinTempIn to temp2 if Lower than old MinTempIn
 MinTempIn = temp2;
}
  // Print Inside Temps, Now, Max and Min.
  //Format the integer back into integer and decimal 
  sprintf(outBuf, "In    %d.%d %d.%d %d.%d",temp2/10, temp2%10,MaxTempIn/10, MaxTempIn%10,MinTempIn/10, MinTempIn%10); 
  glcd.drawString(3, 20, outBuf); //Print to Screen RAM
  Serial.print("      Now  Max  Min");
  Serial.print("\n");
  Serial.print(outBuf); //send data to host 
  Serial.print("\n");
}
}v 
if (deviceAddress == outsideThermometer){ //Display Outside Temp
if (tempC == -127) {
      glcd.drawString(10,  30, PSTR("Error"));
} else {
  temp2 =tempC *10 + 0.5; // make now temp decimal value into an integer. remove decimal point
  if (MaxTempOut < temp2){ //Set Max temp2 if higher than old Maxtemp
    MaxTempOut=temp2;
}
if (MinTempOut > temp2) { //Set Min temp2 if Lower than old Mintemp
 MinTempOut = temp2;
}
// Print Outside Temps, Now, Max and Min.
//Format the integer back into integer and decimal 
  sprintf(outBuf, "Out   %d.%d %d.%d %d.%d",temp2/10, temp2%10,MaxTempOut/10, MaxTempOut%10,MinTempOut/10, MinTempOut%10);
  glcd.drawString(3, 30, outBuf); //Print to Screen RAM
  Serial.print(outBuf); //send data to host 
  Serial.print("\n");
}
}
}
void DrwGraph(){ //Plot next pixel of temp history
if (x < 126){ //Check if the end of the visible screen is reached
x++; //Increment x for next pixel
// draw pixel, Y value mapped from temp value to Y pixel range, reversed.
glcd.setPixel(x,map(Ypixel,10,30,60,40),WHITE); 
}
else{
glcd.fillRect(1,40,126,20, BLACK); //Draw rectangle in Black to erase previous line
x=1; // Start at left hand of visible screen again.
}
}

New Accessories for the AirChrony S3

With the increasing abilities of AI it has become so much easier to take an idea to a finished, working item in a really short time. I was t...

Popular Posts