Interfacing with Arduino Uno R3

Support forum for the mightyohm.com Geiger Counter.
http://mightyohm.com/geiger
bratan
Posts: 16
Joined: Fri Jan 04, 2013 4:02 pm

Interfacing with Arduino Uno R3

Postby bratan » Sat Jan 05, 2013 6:27 am

Any tips, advise or links on how to communicate with UNO R3 directly? :) I have one with SD Logger shield, would love to figure out how to log data from Geiger counter without computer.

User avatar
mightyohm
Site Admin
Posts: 1004
Joined: Fri Apr 03, 2009 10:29 pm
Location: Seattle, WA
Contact:

Re: Interfacing with Arduino Uno R3

Postby mightyohm » Sun Jan 06, 2013 1:00 pm

You can do this in two ways - one is to connect the PULSE output of the Geiger counter to the Arduno and count pulses on the Arduino. The other is to connect the serial port of the Geiger counter to the Arduino RX/TX lines (you actually only need RX since the Geiger counter doesn't listen for data!) In both cases you'll need a level shifter to bring the 2 to 3V levels of the Geiger counter up to the 5V levels of the Arduino. I've used TTL logic (CMOS family) to do this and it works great!

User avatar
mightyohm
Site Admin
Posts: 1004
Joined: Fri Apr 03, 2009 10:29 pm
Location: Seattle, WA
Contact:

Re: Interfacing with Arduino Uno R3

Postby mightyohm » Sun Jan 06, 2013 1:02 pm

Sorry, I meant 74LS family logic.

There is some more info here:
http://mightyohm.com/blog/2012/05/pics- ... ker-faire/

I've seen a few projects connecting the kit to an Arduino so there should be more info on the web, but I can't seem to find any schematics right now.

bratan
Posts: 16
Joined: Fri Jan 04, 2013 4:02 pm

Re: Interfacing with Arduino Uno R3

Postby bratan » Tue Jan 15, 2013 6:20 pm

Awesome, I'm sure I will figure it out! Thanks!

tonyc
Posts: 7
Joined: Tue Jan 15, 2013 1:11 pm

Re: Interfacing with Arduino Uno R3

Postby tonyc » Sat Jan 26, 2013 11:23 am

See this post, should get you going...

viewtopic.php?f=15&t=3437

-Tony

tonyc
Posts: 7
Joined: Tue Jan 15, 2013 1:11 pm

Re: Interfacing with Arduino Uno R3

Postby tonyc » Sun Jan 27, 2013 3:01 pm

This post will provide a good starting point for adding an LCD display (using Arduino Uno and a typical 16x2 LCD).

I have made a minor hardware mod to the Geiger Counter board, according to Jeff. This will allow the geiger board to operate on 5 volts instead of 3 volts, which will make the serial output of the geiger board compatible with the Arduino Uno. The mod is as follow:

1. Change R6 to 1K ohm
2. Change R11 to 330 Ohms

After you make the resistor changes above the next step is wiring the Arduino to both the LCD and the geiger board.

Power & Ground
1. Connect +5v from Arduino to Geiger PCB Pulse J6 pin 1.
2. Connect GND from Arduino to Geiger PCB Pulse J6 pin 3

Serial Data
1. Connect Arduino D10 to Geiger PCB Serial J7 pin 5

LCD
See the Attached Diagram, Note you will need a 10K pot for contrast control, wire the LCD as shown in the attachement image.

Arduino Sketch for displaying CPS, CPM, uSv/hr and Mode (S=Slow,F=Fast,I=INST). Note the mode will show up on the second line of the 16x2 LCD in the last position on the right as (S,F,I).

Code: Select all

#include <SoftwareSerial.h>
#include<LiquidCrystal.h>


SoftwareSerial mySerial(10, 11); // RX, TX
LiquidCrystal LCD(9,8,5,4,3,2);

char readBuffer[64];
String readString;
int commaLocations[6];

void setup() 
{
  Serial.begin(9600);
  mySerial.begin(9600);//Set up Software Serial Port
  LCD.begin(16,2);
  LCD.print("Geiger Counter");
  delay(1000);
  LCD.clear();
}

void loop() // run over and over
{
  if (mySerial.available())
  {
    mySerial.readBytesUntil('\n',readBuffer,64);
    readString = readBuffer;
    FindCommaLocations();
    PrintToLCD();
  }
}

void FindCommaLocations()
{
    commaLocations[0] = readString.indexOf(',');
    commaLocations[1] = readString.indexOf(',',commaLocations[0] + 1);
    commaLocations[2] = readString.indexOf(',',commaLocations[1] + 1);
    commaLocations[3] = readString.indexOf(',',commaLocations[2] + 1);
    commaLocations[4] = readString.indexOf(',',commaLocations[3] + 1);
    commaLocations[5] = readString.indexOf(',',commaLocations[4] + 1);
}

void PrintToLCD()
{
   String line1 = "CPS:";
   line1 += readString.substring(commaLocations[0] + 1,commaLocations[1]);
   line1 += " CPM:";
   line1 += readString.substring(commaLocations[2] + 1, commaLocations[3]);
   line1 += "    ";
   LCD.setCursor(0,0);
   LCD.print(line1);
   
   String line2 = "uSv/hr:";
   line2 += readString.substring(commaLocations[4] + 1, commaLocations[5]);
   line2 +=  "  " + readString.substring(commaLocations[5] + 1, commaLocations[5] + 3);
   LCD.setCursor(0,1);
   LCD.print(line2);
}



Good Luck,
Any questions let me know,
-Tony
Attachments
Arduino LCD_schem.png

bratan
Posts: 16
Joined: Fri Jan 04, 2013 4:02 pm

Re: Interfacing with Arduino Uno R3

Postby bratan » Wed Jan 30, 2013 9:16 am

Wow Tony, you are a legend!!! I didn't notice your post until now! Thanks so much, I'll try to get it working asap, just what I needed!

tonyc
Posts: 7
Joined: Tue Jan 15, 2013 1:11 pm

Re: Interfacing with Arduino Uno R3

Postby tonyc » Wed May 15, 2013 12:53 pm

FYI...Here is a 4 part video on an Arduino Geiger Counter Shield which can work with several types of Geiger tubes...
http://www.youtube.com/watch?v=haHRm7Uvi28

Regards,
Tony

thegrendel
Posts: 5
Joined: Sun Aug 18, 2013 4:33 pm

Re: Interfacing with Arduino Uno R3

Postby thegrendel » Mon Sep 16, 2013 1:24 pm

Thanks, tonyc, for the hookup schematic and for your sketch.
Inspired by that, I built a dual-power (5 v. and 3.3 v.) switchable
Hackduino. Running on 3.3 volt, I can directly wire it to the Mighty Ohm
GC and do a direct hookup of a Nokia 5110 display. Sure, at 3.3 volts the
ATMega 328 is running out of spec, well overclocked anyhow, but it seems
to work.

Herewith the modified sketch, and some pics, if I can manage to do this correctly.

Code: Select all


/* Original code courtesy of tonyc. (Thanks!) */
/* Modded for Nokia 5110 display by mc.       */

#include <SoftwareSerial.h>
#include <string.h>
#include "PCD8544.h"

/* Nokia display hookup
Ard.    Nokia Display
D7    - Serial clock out (SCLK)
D6    - Serial data out (DIN)
D5    - Data/Command select (D/C)
D4    - LCD chip select (CS)
D3    - LCD reset (RST)
+3.3v - Vcc
Gnd   - Gnd
Backlight (may be either +3.3v or Gnd, depends on the display)
*/


PCD8544 nokia = PCD8544(7, 6, 5, 4, 3); // This can be changed.

SoftwareSerial mySerial(10, 11);
/*
   Rx = D10
   Tx = D11
   Can be changed.
*/   

char readBuffer[64];
char line00[] = "GC: tonyc / mc";
char STRBUF[16];
String readString;
int commaLocations[6];

#define DELAY1 1000  // 1 second
#define DELAY2 2000  // 2 seconds

void setup() 
{
  Serial.begin(9600);
  mySerial.begin(9600); //Set up Software Serial Port.

  nokia.init();
  nokia.command(PCD8544_DISPLAYCONTROL | PCD8544_DISPLAYNORMAL);
  nokia.clear();
  nokia.drawstring(0, 0, line00 );
  nokia.display();

  delay(DELAY2);
  nokia.clear();
 
}


void loop() // run over and over
{
  if (mySerial.available())
  {
    mySerial.readBytesUntil('\n',readBuffer,64);
    readString = readBuffer;
    FindCommaLocations();
    PrintToDisplay();
  }
  /**** DEBUG *****
     PrintToDisplay();
  ****  DEBUG *****/
}

void FindCommaLocations()
{
    commaLocations[0] = readString.indexOf(',');
    commaLocations[1] = readString.indexOf(',',commaLocations[0] + 1);
    commaLocations[2] = readString.indexOf(',',commaLocations[1] + 1);
    commaLocations[3] = readString.indexOf(',',commaLocations[2] + 1);
    commaLocations[4] = readString.indexOf(',',commaLocations[3] + 1);
    commaLocations[5] = readString.indexOf(',',commaLocations[4] + 1);
}



void PrintToDisplay()
{

   String line1 = "CPS:";
   line1 += readString.substring(commaLocations[0] + 1,commaLocations[1]);
   
   line1.toCharArray( STRBUF, sizeof(STRBUF) );
   /* Stringx.toCharArray() is the tricky part. */
   nokia.drawstring(0, 2, STRBUF);
   
   String line2 = "CPM:";
   line2 += readString.substring(commaLocations[2] + 1, commaLocations[3]);
   line2 += "    ";
   
   line2.toCharArray( STRBUF, sizeof(STRBUF) );
   nokia.drawstring(0, 3, STRBUF);


   
   String line3 = "uSv/hr:";
   line3 += readString.substring(commaLocations[4] + 1, commaLocations[5]);
   line3 +=  "  " + readString.substring(commaLocations[5] + 1, commaLocations[5] + 3);


line3.toCharArray( STRBUF, sizeof(STRBUF) );
   nokia.drawstring(0, 4, STRBUF);
   nokia.display();

   delay(DELAY1); // Refresh display once per second.
   nokia.clear();

}




I had to do the pictures as links, because I couldn't figure out
how to attach images to a post.

http://bash.deta.in/pic.01.jpg

http://bash.deta.in/pic.02.jpg

http://bash.deta.in/pic.03.jpg

http://bash.deta.in/pic.04.jpg

http://bash.deta.in/pic.06.jpg

thegrendel
Posts: 5
Joined: Sun Aug 18, 2013 4:33 pm

Re: Interfacing with Arduino Uno R3

Postby thegrendel » Mon Sep 16, 2013 1:51 pm

Continuing the previous post . . .

As you can see from the pics,
I keep the Mighty Ohm GC board in a "cream cheese storage container"
($1 at Big Lots). It isn't nearly as pretty as the plexiglass case, but it keeps
it safe from the elements if I slap a strip of duct tape over the opening
when it threatens to rain. I might eventually put the GC board and the
Hackduino together in a larger plastic container for easier carrying about,
and power both from the same battery pack.

The Hackduino power switch has three positions:
center = off
left = 5v
right = 3.3v
I use a mini pc paddle switch --
http://www.allelectronics.com/make-a-store/item/MTS-71/ON-OFF-ON-PADDLE-SWITCH/1.html
This switches between the output of the 5v (7805) and the 3.3v (LM1117T-3.3) regulator ICs
in the power section of the Hackduino.


Why I chose a Nokia 5110 display? Because they're widely available,
on eBay and elsewhere, and just as cheap or even cheaper than
16x2 LCD displays. Also more text can be displayed at one time.
Beware, though. Some of the cheaper 5110 displays are defective.
The pinout on them varies, and sometimes the backlight needs
to be hooked up to Vcc and sometimes to ground. It's always an
adventure.