I have a Pico ADC16 which is currently being used for optical measurements. I have the task of updating the software that is currently being used.
I have attempted to write a program in c# and have got stuck, although i managed to open the port and report the driver version correctly.
The problem came when i attempted to set the channels and read values.
I suspected that it was due to problems with calling the adc1632.dll correctly from .NET, so i dumped that and went back to native c++.
However i have the exact same problem. When i set the channels it returns true, but never does when i ask for a value.
I have a serial monitor program which shows the comms and nothing goes to the ADC16 after the port has been opened. The pico recorder software works and is reading values.
So my questions are: should i expect, when calling set_channel , for information to be sent to the pico, or does this wait until get value is called? and why are no values being read?
Here is my C++ code (i'm a c# programmer so it might not be too good, but it compiles ok). I'm using VS2005 and the lastest SDK from pico website.
// PicoOldSchool.cpp : Defines the entry point for the console application.
int _tmain(int argc, _TCHAR* argv)
unsigned short port = 1;
unsigned short channel = 1;
unsigned short resolution = 16;
unsigned short single_ended = short(false);
unsigned short filter_factor = 10;
long value = 100;
//make sure it is closed and wait
//open the pico port and report and wait
opened = adc16_open_unit(port);
opened = 0;
//set the channel -> returns true
opened = adc16_set_channel (port, channel, resolution, single_ended, filter_factor);
for (int l = 0; l<5; l++)
ok = adc16_get_value (&value, port, channel);
//close the port
// stdafx.h :
#include <windows.h> // for dodgy sleep function