Test and Measurement Forum

VB6 Sample Project

Post your VB and VBA discussions here

VB6 Sample Project

Postby MHims » Tue Jul 24, 2007 3:03 pm

Hi,

This is the same problem as last time but figured I'd start a new thread so we can start fresh (you can forget the old thread I've included all the info in this one).

I use your ADC-16 onboard an underwater vehicle and have uploaded the settings file to my Website:

I'm trying to write a new interface for it but find that the values in the included VB6 sample project don't match up to the readings I get when I run my settings file. These are the values I get:

PicoLog Recorder reads:

Water alarm 2154mv
Heading 303 degrees
Pod Vacuum 1.02bar
Pod Vacuum 0.17bar
Pod Vacuum 1.02bar
24v Monitor 24.12 volts
Depth -0.0metres

Sample VB6 Program reads

Ch1 0.534065766384357
Ch2 2193.33180743114 *
Ch3 279.2401 *
Ch4 -0.1525902 *
Ch5 280.346379797055
Ch6 199.47356 *
Ch7 538.33829251545 *
Ch8 518.120088502327 *


The program has been modified to the same resolution as the settings file:

Code: Select all
      ok% = adc16_set_channel(port, 1, 13, 1, 10)
      ok% = adc16_set_channel(port, 2, 16, 1, 10)
      ok% = adc16_set_channel(port, 3, 13, 1, 10)
      ok% = adc16_set_channel(port, 4, 13, 1, 10)
      ok% = adc16_set_channel(port, 5, 13, 1, 10)
      ok% = adc16_set_channel(port, 6, 13, 1, 10)
      ok% = adc16_set_channel(port, 7, 14, 1, 10)
      ok% = adc16_set_channel(port, 8, 14, 1, 10)


and carries out the following calculation on the Timer event (not sure if I changed that:
Code: Select all
(value * 2500) / 65535



Now according to your last post I have to calculate the actual values using

Resolution |Maximum ADC value
8| 255
9| 511
10| 1023
11| 2047
12| 4095
13| 8191
14| 16383
15| 32767
16| 65535

(5 * raw value/max ADC value) -2.5


So I realise that the conversion formula I use is incorrect but - when I use that to calculate the Channel 1 value it read (I get a raw value of 13.9982760000001 ) and then put that through the correct formula:
(5 * raw value/8191) -2.5


I get -2.4915 which is completely off the 2154mv reading your software gave.

The installed software is version 5.16.2.

Cheers,

Michael
Last edited by MHims on Sat Jul 11, 2009 9:01 pm, edited 1 time in total.
MHims
Active User
Active User
 
Posts: 13
Joined: Tue May 08, 2007 6:39 pm

Postby markB » Thu Jul 26, 2007 3:43 pm

Hello Micheal

I'm afraid I cant work out what you have done here.

Firstly, I've no idea why are doing sum (value * 2500) / 65535 on every timer event. If you intend to convert to mv you should use the equation (5 * raw value/max ADC value) -2.5, as you say later on in your post.

Your equation, (5 * raw value/8191) -2.5, is correct for 13bit resoltion but your raw value appears to be wrong. The raw value should be in the range 0-8192. Working back from the PicoLog result, you should expect an ADC count of 7624 for a input voltage of 2.154V.

You seem to be applying too many equations to the data causing you these errors.

Thanks

Mark
Regards

Mark
markB
Site Admin
Site Admin
 
Posts: 83
Joined: Tue Mar 27, 2007 9:43 am
Location: Cambridgeshire,UK

Postby MHims » Tue Jul 31, 2007 6:35 pm

Hi,

I'm simplified the timer event code so it now reports back just the read value (no conversion to mV) and I now get:

Ch1 14 raw data
Ch2 57597 raw data
Ch3 7167 raw data
Ch4 -2 raw data
Ch5 7167 raw data
Ch6 5371 raw data
Ch7 14044 raw data
Ch8 13581 raw data

And the PicoLog Recorder reads:

Water Alarms 2144 mV
Heading 308 - 311 degrees
Pod Vacuum 1.00 Bar
Pod Vacuum 0.17 bar
Pod Vacuum 1.00 Bar
24v Monitor 24.16 Volts
Depth 0.0 Metres

Using the settings file as attached in my first post. (All except the first channels use equations)

If my Maths serves me right I should be reading a 3516396 value from Ch1.......

Michael
MHims
Active User
Active User
 
Posts: 13
Joined: Tue May 08, 2007 6:39 pm

Postby MHims » Wed Aug 08, 2007 12:40 pm

Hi,

Any news on this?

Cheers,

Michael
MHims
Active User
Active User
 
Posts: 13
Joined: Tue May 08, 2007 6:39 pm

Postby markB » Wed Aug 08, 2007 1:08 pm

I cant really help until I know how you convert from mV into temperature or pressure etc. Could you post your PLS or PLW file so that I can take a look at the settings.

Many thanks
Regards

Mark
markB
Site Admin
Site Admin
 
Posts: 83
Joined: Tue Mar 27, 2007 9:43 am
Location: Cambridgeshire,UK

Postby MHims » Wed Aug 08, 2007 1:55 pm

It's in my first post - I uploaded it to my site since it wasn't allowed here.

Michael
MHims
Active User
Active User
 
Posts: 13
Joined: Tue May 08, 2007 6:39 pm

Postby markB » Wed Aug 08, 2007 2:17 pm

I cant find it. Can you repost the link?
Regards

Mark
markB
Site Admin
Site Admin
 
Posts: 83
Joined: Tue Mar 27, 2007 9:43 am
Location: Cambridgeshire,UK

Postby MHims » Wed Aug 08, 2007 2:45 pm

MHims
Active User
Active User
 
Posts: 13
Joined: Tue May 08, 2007 6:39 pm

Postby markB » Wed Aug 08, 2007 3:42 pm

It looks like you have your channels muddled. From the pls file I can see the following ADC16 channels correspond the following paramters:

Ch Parameter
7 Water Alarms
6 Heading
5 Pod Vacuum
4 Pod Vacuum
3 Pod Vacuum
2 24v Monitor
1 Depth

Therefore your channel resolution code should be:
Code: Select all
      ok% = adc16_set_channel(port, 1, 14, 1, 10)
      ok% = adc16_set_channel(port, 2, 13, 1, 10)
      ok% = adc16_set_channel(port, 3, 13, 1, 10)
      ok% = adc16_set_channel(port, 4, 13, 1, 10)
      ok% = adc16_set_channel(port, 5, 13, 1, 10)
      ok% = adc16_set_channel(port, 6, 16, 1, 10)
      ok% = adc16_set_channel(port, 7, 13, 1, 10)


You can then convert this to mV using the equations that I described earlier and then use your parameter scaling to convert to your custom units.
Regards

Mark
markB
Site Admin
Site Admin
 
Posts: 83
Joined: Tue Mar 27, 2007 9:43 am
Location: Cambridgeshire,UK

Postby MHims » Wed Aug 08, 2007 10:01 pm

Ok I've changed it like you said....added on a few If statements to convert the raw data to mV using the appropriate value in the formula and then tried it:

I've uploaded the VB project here: http://www.mhims.co.uk/PicoUpload.zip

Pico:
Water Alarms 2146mv
Heading 308 degrees
Pod Vac 1.03 bar
Pod Vac 0.17 bar
Pod Vac 1.02 bar
24v Monitor 24.12
Depth 0.0m

Sample Project says:
Ch1 -2.4920649453702
Ch2 1.88835307044317
Ch3 1.96465633011842
Ch4 -2.50183127823221
Ch5 2.01043828592357
Ch6 0.61284046692607
Ch7 1.79984128921988
Ch8 1.64576084966123

Any ideas? I realise I haven't applied the formulas but the Water Alarms don't use a formula.

Cheers,

Michael
MHims
Active User
Active User
 
Posts: 13
Joined: Tue May 08, 2007 6:39 pm

Postby markB » Thu Aug 09, 2007 10:38 am

Hi
Firstly, I've no idea why are doing sum (value * 2500) / 65535 on every timer event. If you intend to convert to mv you should use the equation (5 * raw value/max ADC value) -2.5, as you say later on in your post.

I'm afraid the above statement is incorrect. The ADC16 has a resolution of 16bits plus sign so you were correct with your initial statement.


You scaling to mV should therefore read:
Code: Select all
        If ch = 1 Then
            List1.AddItem ("Ch" & ch & " " & 2500 * value / 16383 & "mv")
        ElseIf ch = 2 Then
            List1.AddItem ("Ch" & ch & " " & 2500 * value / 8191 & "mv")
        ElseIf ch = 3 Then
            List1.AddItem ("Ch" & ch & " " & 2500 * value / 8191 & "mv")
        ElseIf ch = 4 Then
            List1.AddItem ("Ch" & ch & " " & 2500 * value / 8191 & "mv")
        ElseIf ch = 5 Then
            List1.AddItem ("Ch" & ch & " " & 2500 * value / 8191 & "mv")
        ElseIf ch = 6 Then
            List1.AddItem ("Ch" & ch & " " & 2500 * value / 65535 & "mv")
        ElseIf ch = 7 Then
            List1.AddItem ("Ch" & ch & " " & 2500 * value / 8191 & "mv")


which should give you the correct mV before you go on to scale to pressure, depth, etc
Regards

Mark
markB
Site Admin
Site Admin
 
Posts: 83
Joined: Tue Mar 27, 2007 9:43 am
Location: Cambridgeshire,UK


Return to VB and VBA (Excel, Access)

Who is online

Users browsing this forum: No registered users and 0 guests