Hi,
I would like to use the K8055 as a datalogger for my solarpanels.
The KWh-meter gives a pulse every Watt, I would like to use the counter and read and reset it every let’s say 5 minutes.
I wrote a test program but found out when I read the counter to an int and reset I miss a couple of pulses. (used a digital output connected to the input of the counter and compared the pulses given by the program and the pulses counted.)
Already tried to use threading because I thought writing to the database was holding up the thread but this changed nothing.
Here is part of my code:
[code] private void timer1_Tick(object sender, EventArgs e)
{
Thread m_Thread = new Thread(new ThreadStart(LogCounter));
m_Thread.Name = "Write to Logging";
m_Thread.Start();
label1.Text = string.Format("{0:N} Watt", tblSolarLogTableAdapter.Totaal());
label4.Text = api.ReadCounter(2).ToString();
}
private void LogCounter()
{
int Counter = api.ReadCounter(1);
api.ResetCounter(1);
DomoticaDataSet ds = new DomoticaDataSet();
DomoticaDataSetTableAdapters.tblSolarLogTableAdapter ta = new DomoticaDataSetTableAdapters.tblSolarLogTableAdapter();
ta.Insert(DateTime.Now, Counter, Convert.ToInt32(label3.Text));
ta.Dispose();
}
private void timer2_Tick(object sender, EventArgs e)
{
Thread m_Thread = new Thread(new ThreadStart(TestOutput));
m_Thread.Name = "Output";
m_Thread.Start();
label3.Text = Convert.ToString(1 + Convert.ToInt32(label3.Text));
}
private void TestOutput()
{
api.SetDigitalChannel(1);
Thread.Sleep(110);
api.ClearDigitalChannel(1);
}
[/code]
Anybody familiar with this problem?
PS: Sorry for cross-posting but this part of the board seems more active then the pre build one.