Simple Arduino Pulse Rate Counter
-
gwgw
- Posts: 57
- Joined: 13 May 2019, 08:09
Re: Simple Arduino Pulse Rate Counter
I think you meant Svilen, not me, I didn't make a loop suggestion. I would make one different suggestion though, there is a potential issue in using millis() - which would not be a problem most of the time, but if this arduino sketch runs for about two months continuously, since millis() returns unsigned long, it would overflow and wrap to zero. When that happens, the check you do - if ( millis() > ((secondCounter + 1) * 1000) ) will never be true. If that is an issue (as in continuous environmental measurements maybe?), perhaps this should be reworked in a way to avoid that problem.
-
Sesselmann
- Posts: 1393
- Joined: 27 Apr 2015, 11:40
Re: Simple Arduino Pulse Rate Counter
Yes you are right, I should have addressed that to Svilen :p
Yes, you make a good point and I think this can easily be exchanged with: delay(1000);gwgw wrote: ↑20 Sep 2019, 06:45I would make one different suggestion though, there is a potential issue in using millis() - which would not be a problem most of the time, but if this arduino sketch runs for about two months continuously, since millis() returns unsigned long, it would overflow and wrap to zero. When that happens, the check you do - if ( millis() > ((secondCounter + 1) * 1000) ) will never be true. If that is an issue (as in continuous environmental measurements maybe?), perhaps this should be reworked in a way to avoid that problem.
I ordered some cheap Arduino's and a few different kinds of displays off eBay with the intention to develop a geiger counter module with cpm, uSv, total exposure etc.. should be a fun project.
Steven
-
gwgw
- Posts: 57
- Joined: 13 May 2019, 08:09
Re: Simple Arduino Pulse Rate Counter
Since it's mostly about software, some very useful features can be easily added such as averaged CPM over a custom period, customizable alarm settings and most importantly - ability to log data on a PC via UART. There is a great and very helpful guy from Lithuania on ebay that makes arduino-based geiger counters, he also has a supply of cheap USSR geiger tubes of different types. I've ordered two kits from him - one with a large SI22G tube for environmental monitoring and one with a SBT10A that I used for a portable alpha/beta/gamma counter, both worked great. Unfortunately though the SBT10A detector got broken recently :(
Anyway, he published some of his earlier arduino sketches and since you work on a similar project, perhaps you can borrow some ideas from there?
Anyway, he published some of his earlier arduino sketches and since you work on a similar project, perhaps you can borrow some ideas from there?
-
Svilen
- Posts: 185
- Joined: 23 Sep 2016, 04:25
Re: Simple Arduino Pulse Rate Counter
@ Steven: I just saw this optimization potential, but as I said, I'm not an expert, just learned a bit mainly from adapting programs for my needs. Here Milen can be of more help I guess. Didn't know about this issue thou.
-
Conor Whyte
- Posts: 126
- Joined: 28 Apr 2019, 15:06
Re: Simple Arduino Pulse Rate Counter
If using a teensy 3.6 or 4.0, one can use the FreqCount and FreqMeasure together for 0.01CPS - ~80MCPS (Standard without overclocking). Just use the libraries and add the appropriate math and signal acquisition times for both lib.h s to work in. Write the counts to a display with an averaging while dumping the same info to bluetooth serial.
IF deciding to take pulses from the gamma spectacular you'll need an amplifier stage before the input to bring the pulses into the measurable range of the teenys ADCs.
IF deciding to take pulses from the gamma spectacular you'll need an amplifier stage before the input to bring the pulses into the measurable range of the teenys ADCs.
-
Conor Whyte
- Posts: 126
- Joined: 28 Apr 2019, 15:06
Re: Simple Arduino Pulse Rate Counter
Here's one that is workable on several different boards. I have complied this on an uno and it seems able to count up to the maximum rate that the uno can count.
this one utilizes the Adafruit LCD serial display driver... you can change the driver to whatever you want by referencing the #include<library>
and then defining the Liquid crystal LCD pins...
You can even change the size of LCD screen by changing the size in lcd.begin(16, 2) to (20, 4)...
Code is meant to take pulses in from port 8 calculate the frequency 0.01Hz - 125Khz (~125,000CPS) or 7.5MCPM
Display the frequency as CPS on the first line and then a frequency*60 for CPM on the second line on an adafruit i2c LCD display.
this one utilizes the Adafruit LCD serial display driver... you can change the driver to whatever you want by referencing the #include<library>
and then defining the Liquid crystal LCD pins...
You can even change the size of LCD screen by changing the size in lcd.begin(16, 2) to (20, 4)...
Code is meant to take pulses in from port 8 calculate the frequency 0.01Hz - 125Khz (~125,000CPS) or 7.5MCPM
Display the frequency as CPS on the first line and then a frequency*60 for CPM on the second line on an adafruit i2c LCD display.
Code: Select all
#include <Wire.h>
#include <Adafruit_LiquidCrystal.h>
Adafruit_LiquidCrystal lcd(0);
const int pulsePin = 8; // Input signal connected to Pin 8 of Arduino
int pulseHigh; // Integer variable to capture High time of the incoming pulse
int pulseLow; // Integer variable to capture Low time of the incoming pulse
float pulseTotal; // Float variable to capture Total time of the incoming pulse
float frequency; // Calculated Frequency
void setup() {
pinMode(pulsePin, INPUT);
lcd.begin(16, 2);
Serial.begin(9600);
lcd.setCursor(0, 0);
lcd.print(“GSForums”);
lcd.setCursor(0, 1);
lcd.print(“Count-rate meter");
delay(5000);
}
void loop() {
lcd.setCursor(0, 0);
lcd.print(" ");
lcd.setCursor(0, 1);
lcd.print(" ");
pulseHigh = pulseIn(pulsePin, HIGH);
pulseLow = pulseIn(pulsePin, LOW);
pulseTotal = pulseHigh + pulseLow; // Time period of the pulse in microseconds
if (pulseTotal<=0) pulseTotal=1000000
lcd.setCursor(0, 1);
lcd.print(frequency);
lcd.print("CPS”);
delay(1000);
lcd.setCursor(0, 0);
lcd.print(frequency*60);
lcd.print("CPM”);
delay(1000);
}
Last edited by Conor Whyte on 05 Feb 2020, 17:40, edited 1 time in total.
-
Sesselmann
- Posts: 1393
- Joined: 27 Apr 2015, 11:40
Re: Simple Arduino Pulse Rate Counter
Conor,
Looks cool, I will give it a try next time I have the Arduino hooked up.
Steven
Looks cool, I will give it a try next time I have the Arduino hooked up.
Steven
-
Conor Whyte
- Posts: 126
- Joined: 28 Apr 2019, 15:06
Re: Simple Arduino Pulse Rate Counter
The code posted here didn't work as intended as was removed.
I'll post a scaler ratemeter for the Teensy 3.6 which utilizes ADC0 - and is sensitive to very small impulses without a need for an amplifier or signal conditioning.
I'll post a scaler ratemeter for the Teensy 3.6 which utilizes ADC0 - and is sensitive to very small impulses without a need for an amplifier or signal conditioning.
-
Meins321
- Posts: 2
- Joined: 27 Mar 2020, 00:25
Re: Simple Arduino Pulse Rate Counter
@Steven Sesselmann
Can you post your stl files for the case? I would like to use the counter as RPM Counter with my Bike.
If i attach a magnet and use a Hallsesnor it should work right.
If you look at this link:
https://github.com/Locoduino/DIO2/blob/ ... _arduino.h
At line 52 you will find:
// ===========================================================================
// Configuration
// ===========================================================================
// GPIO2_PREFER_SPEED - User can define this value before including arduino2.h
// or this default value is used.
// Set to 1 to make all digital I/O functions inline.
// This will make them work faster but the resulting code will be bigger.
// In general, you can start with 1 and if you are running out of program memory
// switch to 0.
//
#ifndef GPIO2_PREFER_SPEED
#define GPIO2_PREFER_SPEED 1
#endif
So it sets the priority like a read in is what i can conclude
Can you post your stl files for the case? I would like to use the counter as RPM Counter with my Bike.
If i attach a magnet and use a Hallsesnor it should work right.
If you look at this link:
https://github.com/Locoduino/DIO2/blob/ ... _arduino.h
At line 52 you will find:
// ===========================================================================
// Configuration
// ===========================================================================
// GPIO2_PREFER_SPEED - User can define this value before including arduino2.h
// or this default value is used.
// Set to 1 to make all digital I/O functions inline.
// This will make them work faster but the resulting code will be bigger.
// In general, you can start with 1 and if you are running out of program memory
// switch to 0.
//
#ifndef GPIO2_PREFER_SPEED
#define GPIO2_PREFER_SPEED 1
#endif
So it sets the priority like a read in is what i can conclude
-
Sesselmann
- Posts: 1393
- Joined: 27 Apr 2015, 11:40
Re: Simple Arduino Pulse Rate Counter
Sure, see stl files attached..
Steven
Steven
You do not have the required permissions to view the files attached to this post.