CircuitGizmos

Electronic Products for Creative Minds

  • Home
  • Gizmo Store/Products
  • Documentation/Datasheets
  • Projects/Libraries
  • GizmoBlog
  • Services/Contact
    • Design
    • Contact Gizmo!
  • Your Gizmo Cart
    • Your Account

February 17, 2009 by robert Leave a Comment

Using Excel as a U401 Data Logger

Excel can easily use the U401 (or the U421) for data logging using Excel’s VBA language. This example Excel file will log the time that any of the inputs on port A of the U401/U421 changes. A button starts and stops the logging.

Logging buttons

This example doesn’t have a whole lot of finesse. It bluntly grabs the first U401/U421 device that it finds, doesn’t have error checking, doesn’t allow for a change in logging rate, etc. These would be good to add, but this example stands as simple basic code.

Some of the source for the file is posted below, and the excel file itself can be downloaded from here.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<span style="color: #008000;">' Global variables
Dim stopitnow As Boolean
 
' Run the process
Private Sub StartButton_Click()
 
    ' Local variables
    Dim found As Boolean
    Dim sample As Long
    Dim uniquetime As Long
    Dim lastread As Byte
    Dim state As Byte
 
    stopit = False
    sample = 1
    uniquetime = Int(Timer)
 
    ' Look for USB device
    found = USBm_FindDevices
    USBm_InitPorts 0
    USBm_ReadA 0, state
    lastread = state
 
    If found = True Then
 
        UserForm1.StartButton.Caption = "Found device"
 
        While stopitnow = False
 
            USBm_ReadA 0, state
 
            If lastread &lt;&gt; state Then
                lastread = state
                Range("A1").Cells(sample, 1) = Time
                Range("A1").Cells(sample, 2) = state
                If state And &amp;H1 Then Range("A1").Cells(sample, 3)
                     = "Bit 0 on" Else Range("A1").Cells(sample, 3) = " "
                If state And &amp;H2 Then Range("A1").Cells(sample, 4)
                     = "Bit 1 on" Else Range("A1").Cells(sample, 4) = " "
                If state And &amp;H4 Then Range("A1").Cells(sample, 5)
                     = "Bit 2 on" Else Range("A1").Cells(sample, 5) = " "
                If state And &amp;H8 Then Range("A1").Cells(sample, 6)
                     = "Bit 3 on" Else Range("A1").Cells(sample, 6) = " "
                If state And &amp;H10 Then Range("A1").Cells(sample, 7)
                     = "Bit 4 on" Else Range("A1").Cells(sample, 7) = " "
                If state And &amp;H20 Then Range("A1").Cells(sample, 8)
                     = "Bit 5 on" Else Range("A1").Cells(sample, 8) = " "
                If state And &amp;H40 Then Range("A1").Cells(sample, 9)
                     = "Bit 6 on" Else Range("A1").Cells(sample, 9) = " "
                If state And &amp;H80 Then Range("A1").Cells(sample, 10)
                     = "Bit 7 on" Else Range("A1").Cells(sample, 10) = " "
                sample = sample + 1
            End If
 
            DoEvents
 
        Wend
 
    End If
 
End Sub
 
' Stop process
Private Sub StopButton_Click()
 
    stopitnow = True
 
End Sub</span>

Filed Under: Uncategorized Tagged With: Excel, programming, u401, u421

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

A Ton of Documentation

Open all | Close all

Projects made by Gizmo, Friends, and Members

open all | close all

Recent GizmoBlog Musings

  • Altair 8800 using a ColorMax!
  • Re-energizing the ColorMax, Pt. 3

Visit us!

  • Facebook

Electronic Products for Creative Minds

CircuitGizmos is your source for electronic products that help you create your embedded projects. Here at CircuitGizmos.com you will find a friendly store filled with creative products and all of the documentation that you need to use these gizmos.

We create devices that we believe make electronics fun, but we also know that our products are used for professional designs. For decades we have designed products for commercial, military, and medical industries. Our gizmos here are great for engineers and hobbyists alike.

Copyright © 2008+ CircuitGizmos, L.L.C. All rights reserved

Image already added

Recently Viewed Products

Copyright © 2021 · Generate Pro Theme on Genesis Framework · WordPress · Log in