Forum: I can't find a functioning YUN Freq Counter example that runs. Some code will compile and make the PWM outputs, but I can't get a digital input to count a varying frequency as applied to the designated pin. Is there an Arduino better suited for this application? The water flow sensors output a 5V negative going pulse of varying width, so an edge detector is needed. They came with cheap RO controllers that mate to the sensors, and those work fine. ~4400 pulses is a liter, more or less. The Controllers display volume to 10,000 liters and measure flow rate as well. Did a lot reading on http://openenergymonitor.org/ for background, but the Yun doesn't seem to be a favorite.
I started my Yun projects about a month ago, with the idea I could learn to record water flow and keep statistics. In the reconstructed PEX pipes in our house plumbing I have 3 hall effect flow sensors installed. I meter the main line water volume, irrigation flow, and the waste-water to flush the filtration components. Those sensors and water pressure would be metered with one Yun. Plan to use a second Yun to monitor, with proper signal conditioning and scaling, our electrical use. None of these measurements or functions are life-critical but upon successful completion, the project would be duplicated and expanded perhaps to monitor the health of our community well system. It has multiple pumps on 3PH 208 and 240VAC. Monitoring the level of a 20,000 US Gal reservoir, flow meters, air pressure on the service tank and a myriad of ambient conditions would be included to show system health. The intent is to monitor only, and get use statistics, in particular to see if some power savings can be achieved and to get advance notice of maintenance issues via text or web service.
I worked in an Aerospace engineering environment before retirement, so electronics doesn't baffle me, but I'm lacking in coding skill. The rudimentary C++ is beginning to make sense, but beyond VEE, VBA and a little linux I'm dumb. Some of the YUN documentation has errors or omissions. I have been pretty good about getting .ino/pde examples to work, so that's behind me. e.i. I got the WiFi Blue LED (dead out of the box) to function as I thought it should, and the USB LED too, in the advanced configuration panel.
I have successfully managed to hack together a DC voltmeter, DHT11 temp, humidity, and light level and display them on the monitor. A RTC 3231 has been wired up , set up, enabled the 32KHz oscillator and the SQW output. Keeps time. I use a TEK 2465A DV scope for waveforms. I am grateful to the community for the arduino code and examples but for the Yun, I've had to learn to code properly for successful WiFi loading and find that the Yun is pretty short on physical resources, as so many pins have duplicate/triplicate functions. SO I'm probably going to have to choose a different flavor when going for the BIG time.
So to get to the point. I cannot find what I believe is a functioning example of A YUN frequency counter. This is essential to logging water flow and use. The several 'hard-coded" examples do nothing on the monitor or output what the PWM is generating, maybe. Because the pins/functions of the YUN are not serviced the same, or the timers (e.g. TIMER1) can't be accessed if I am using I2C; Frustrated right now. If I can't do it I'd like to know. I 'd like to read and accumulate continuously the pulses from multiple flow sensors at or above 1 KHz. The sensors are three wire, +/-/signal TTL. I have a 1 KHz SQW generator that is suitable for simulations.
I may be faced with an external hardware solution, or hacking the cheap RO controllers that mate to the sensors. That looms as a possibility. Is there an Arduino better suited for this application?
So for now I am about to try to build on an ADS1015 12-Bit ADC - 4 Channel as my next interface while I sort through the Freq Counter issues.
I'd put in a code example that loads and works WiFi. but my Freq Counter efforts are badly broken. So far even the USB (serial) loads haven't worked. And it seems FreqCounter.h includes a file I can't find.
This uses TImer1 - not available on YUN
Frequency Counter Arduino Sketch
by: Jim Lindblom
SparkFun Electronics
License: Beerware
(that's all I am pasting here)
This is Odd file <avr/interrupt.h>
/*
FreqCounter.h - Library for a Frequency Counter c.
Created by Martin Nawrath, KHM Lab3, Dec. 2008
Released into the public domain.
*/
#ifndef FreqCounter_h
#define FreqCounter_h
#include <avr/interrupt.h>
//#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
//#else
//#include "WProgram.h"
//#endif
namespace FreqCounter {
extern unsigned long f_freq;
extern volatile unsigned char f_ready;
extern volatile unsigned char f_mlt;
extern volatile unsigned int f_tics;
extern volatile unsigned int f_period;
extern volatile unsigned int f_comp;
void start(int ms);
}
#endif