Hello
This is my first post and after reading some of the posts on this forum I feel out of place because I do not have any experience with writing software. I built the board 12 months ago and tested it with the demo software but now I have a reason to use the board but do not know where to start.
My aim is to use the board as a data logger for measuring battery current and voltage on the solar power system.
I feel confident to do all the electrical and hardware connections but I do not know how to get some software running on the computer to talk to the board. The demo software gives me a great form which allows me to test the device and all is running well.
Do I need a third party software package to program this and is there something on the market that could give me a way to control this board without getting too involved in the software writing.
I am probably missing some of the fundamentals in getting started and I wouldn’t blame you for having a good laugh
but I would appreciate any help.
It would be nice to store it in an Excel spreadsheet so I can quickly convert the data to a graph and a simple control console would be sufficient.
I only need to sample the data at 1 minute intervals and keep it running for about 1 month.
I don’t need anything fancy so a simple control panel would be good.
The form that came with the Demo software was a pretty flash control console but I would imagine that to program something like that would take a lot of time to write.
If I am wrong then a form or control console like the demo version which allowed me to connect to the card via a pushbutton ( like the demo version) and had a control which gave me the option of changing the sample rate to read the analog inputs.
Then a control which allowed me to write the data to a text fille or spreadsheet.
Because the demo version which was used to test the card was made for people with no programming skills I was able to run it without a problem. I do not know about things like source code eyc. and I tried writing somthing to a text file using the samples provided then changing the file extension to a dll file thinking that would run a program.
Yes you are probably shaking your head right now but that shows you how much I know about programming.
On the flip side I did manage to solder ther kit without a hitch.
I would be happy with any program that allowed me to connect to the card and read the analog inputs of the card at a sample rate of 1 minute and somehow write it to file. If this did not come in the shape of a form or control console then that would fine also but I would need some instructions on how install it on the computer. On the laptop I intend to use for this I am running windows XP.
[quote]It would be nice to store it in an Excel spreadsheet so I can quickly convert the data to a graph and a simple control console would be sufficient.
I only need to sample the data at 1 minute intervals and keep it running for about 1 month.[/quote]One possible solution is to use a VBA (Visual Basic for Applications) running as a macro in the Excel.
It can easily read the analog inputs of the K8055 and add the values to the Excel sheet.
If you think this is OK, I may write this kind of Excel macro for you…
Here is the macro:
You can find it by clicking Alt + F11.
If this source code is not visible on the screen:
Expand “Modules” (folder) on the left of the screen in the Project window under VBAProject and double click “Module1”.
[code]Private Declare Function SetTimer Lib “user32” ( _
ByVal HWnd As Long, ByVal nIDEvent As Long, _
ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Private Declare Function KillTimer Lib “user32” ( _
ByVal HWnd As Long, ByVal nIDEvent As Long) As Long
Private Declare Function OpenDevice Lib “k8055d.dll” (ByVal CardAddress As Long) As Long
Private Declare Function CloseDevice Lib “k8055d.dll” ()
Private Declare Function ReadAnalogChannel Lib “k8055d.dll” (ByVal Channel As Long) As Long
Dim i As Long
Dim Data As Long
Dim TimerID As Long
Dim TimerSeconds As Single
Sub Button1_Click()
Dim h As Long
h = OpenDevice(0)
If h = 0 Then
ActiveSheet.Cells(1, 4) = “Card connected”
TimerSeconds = 60 ’ the timer interval is now 60 sec.
TimerID = SetTimer(0&, 0&, TimerSeconds * 1000&, AddressOf TimerProc)
Else
ActiveSheet.Cells(1, 4) = “Card not found”
End If
End Sub
Sub Button2_Click()
On Error Resume Next
ActiveSheet.Cells(1, 4) = “Card closed”
CloseDevice
KillTimer 0&, TimerID
End Sub
Sub TimerProc(ByVal HWnd As Long, ByVal uMsg As Long, ByVal nIDEvent As Long, ByVal dwTimer As Long)
On Error Resume Next
i = i + 1
Data = ReadAnalogChannel(1)
ActiveSheet.Cells(i, 1) = Data
Data = ReadAnalogChannel(2)
ActiveSheet.Cells(i, 2) = Data
End Sub
Sub Button5_Click()
i = 0
Columns(“A:B”).Select
Selection.ClearContents
End Sub[/code]
Nice that you got this application working and it is what you like to have.
You can any time click the “Stop” button and save the Excel spreadsheet. Click the “Run” button to continue.
After a couple of weeks it may be good idea to save the spreadsheet (with new name) and click the “Clear & Reset” button.
The Excel spreadsheet application is limited to 32000 rows per sheet. This number of rows there will be in 22 days.
You can easily change the sampling interval by editing this line:
TimerSeconds = 60 ' the timer interval is now 60 sec.
Then click the “save button” to save the changed source file.
I am working on a little app. for this too, even when the Excel solusion is easy to get going, I would like to try and make my own and so far it is looking good!
Going to show a live chart over the logged info (currently testing it with a 10 ms timer and a random number function with no trouble at all (tested my i7 to generate 3 charts with each 1000 points in, in just 0.012 second)).
It will also have the option to save the chart as a png file, so it can be used on a website, or just to be stored.
Haven’t decided yet how I want to save the data, maybe just a simple txt file, and then save it in CSV format.
Just doubled it up, so now there are for both inputs. Also going to read about C#'s random function, it doesn’t seem random at all! Must clearly be based on time, because altering the timer makes the returned values jump alot more, but still with the same pattern.
[quote]Also going to read about C#'s random function, it doesn’t seem random at all! Must clearly be based on time, because altering the timer makes the returned values jump alot more, but still with the same pattern.[/quote]Indeed, seems to repeat same “random” sequence.
I made a simple test with this kind of function - looks quite random 20 results:
{
Random random = new Random();
int num;
listBox1.Items.Clear();
for (int i = 0; i < 20; i++)
{
num = random.Next(255);
listBox1.Items.Add (num.ToString ());
}
}
I think this C# random thing is a little out of the scope of the topic of this thread…
I think you do not need any random function when you get the K8055 connected to the software.
Absolutely not, only using it to fill the charts with values
Here is the program so far
Still going to add logging, so the charts and logging will be kept separated, so they can be set to the same and run synchronized, or set to two different, and it will then just save the values to the txt at another rate.
The program that bld created for me is running great and I am able to use the board for my project. Now I can see lots of possibilities for using the board for other applications so i would like to learn something about programming in visual basic or another windows based software. Can anyone recommend where i would start, recommend a book or a paticular software that would get an absolute novice started in writing programs.