Go to the Home Page - IECI Logo

Interworld Electronics

 
and Computer Industries Inc.         
Interworld Electronics Home Page
  Your ALT-Text here Home    Your ALT-Text here Data Acquisition    Your ALT-Text here Pico    Your ALT-Text here Interfacing an ADC-16 with a Palm Pilot
PicoScope 5000
PicoScope 3000
ADC-200-100 
ADC-40/42/and ADC-100 
ADC-212 and ADC-216 Scope
Software Options for the ADC-200
Palm to ADC-16 (App Note)
Temperature & Humidity 
High Speed High Resolution ADC-212
DrDaq Low Cost Data Acquisition 
Automotive Prdts
Demo Software and Upgrades
Enviro Mon Data Logger for  temperature etc.
DrDaq Low Cost Data Acquisition 
PicoLog  Logging Software
USB Instruments
Press Releases 
Technical tips
Interfacing an ADC-16 with a Palm Pilot Converts PC to Oscilloscope (1435 bytes)
Palm PilotPalm Pilot


US Prices
CDN Prices

Privacy and Security

Introduction

Palm pilots are becoming ever more popular and useful as everyday organizers, but can they be used for data logging?

Yes is the answer, a Palm Pilot has an RS-232 serial connector so in theory any Pico serial port device can be used in conjunction with a Palm Pilot. There are two main considerations, Hardware & Software.

 

 

Hardware Return to top of page

It states in the ADC-16 help file that the serial port requirements are:


Pin Name Function
3 TX Data from the PC to the ADC-16
2 RX Data from the ADC-16 to the PC
7 RTS Held at a positive voltage (>7V) to power the ADC-16
5 GND 0V line
4 DTR Held at a negative voltage (<-7V) to power the ADC-16

The Palm Pilot has a 10-pin RS-232 serial connector, which can be used to communicate with a wide range of external devices.

 

Below is the pin-out description for the 10-pin serial edge connector:

Pin Name Function
1 DTR Data Terminal Ready signal
2 VCC 3.3 Volts
3 RD (in) Receive data
4 RTS (out) Request to send
5 TD (out) Transmit data
6 CTS (in) Clear to send
7 GP1 (in) Interupt line
8 GP2 (in) modem sync
9 unused unused
10 GND signal ground

From this it can be clearly seen that the ADC-16 can not be powered by a Palm Pilot alone.

Return to top of page

To get round the power problems an adapter had to be built. This is quite small and can run of a 9 volt PP3 battery. The device fits in series with the serial cable.


Power adapter


Software

The ADC-16 has the following serial protocol:

  • Switch RTS on and DTR off to provide power.
  • Wait for more than 1 second for the ADC-16 to settle
  • Send an single control byte to the ADC-16
  • Wait for the 3 byte response from the ADC-16

The Palm Pilot operating system is unique and differs from Windows programming in many aspects.

There are a number of development tools available for writing Palm Pilot applications, for this particular example VFDIDE was used. It is a C++ compiler with a Visual form designer built in and can be downloaded free of charge from: www.vfdide.com

Return to top of page

The structure of the program is as follows:

Once the program is broken down into blocks it is easier to code the individual parts

Start Application Return to top of page

static void StartApplication(void) {
Err Error;
FormPtr Frm;

Frm = FrmInitForm(frmadc16);
FrmSetActiveForm(Frm);
FrmDrawForm(Frm);

Open Serial port Return to top of page

The following code is used to open and setup the serial port:

error = SerOpen(SerIORef, 0, 9600);
if(error) {
FrmCustomAlert (AlertGenericAlert, strErrSerPortOpen, "can't open port","can't open port" );
SerClearErr(SerIORef);
return;}

SerIOConnected = true;
sstSetup.baudRate = 9600;
sstSetup.flags = serSettingsFlagBitsPerChar8|
serSettingsFlagParityOnM;


Send control byte to ADC16 Return to top of page

The control bytes are defined in the help file, and are declaired at the start of the program.

static unsigned char channels[] = {0X1F, 0X3F,0X5F,0X7F, 0X9F, 0XBF, 0XDF, 0XFF};

For example 0X1F makes a request for a 16-bit single ended reading from channel1. These control bytes are used as so:

msg = channels[0]; SerSend(SerIORef, &msg, StrLen(&msg), &error);

Wait for response Return to top of page

Resolution (bits) Conversion Time (ms)
8 6.6
9 8.9
10 14
11 23
12 41
13 78
14 151
15 298
16 657

 

Once a request for data has been send it is neccessary to wait for a response. The duration of the delay between request and reply will depend on the resolution of the result:

SerReceiveWait(SerIORef, 3, 1000);
SerReceiveCheck(SerIORef, &nbytes);
anbytes = SerReceive(SerIORef, data, nbytes, 100, &err);
if (err != 0)
ret = false; else
ret = true;
SerReceiveFlush(SerIORef, 1);
return(ret);}

 

Display the result Return to top of page

The data is returned in three bytes, the first byte is the sign, the second is the most significant byte (MSB) and the third is the least significant bit (LSB). In this example the sign is ignored.

value = (data[1]<<8)+data[2];
volts = (2.5/65535)*value;

The problem now is that idealy the volts is floating point, however the Palm operating system does not have conventional ways of converting floating point values into strings.

FloatToString(volts, szvolts, 3);
StrCopy(szResult, "Voltage = ");
StrCat(szResult, szvolts);
WinDrawChars(szResult, StrLen(szResult),20,60);

The FloattoString function was taken from one of the many usergroups that offers assistance to palm programmers, it makes a rather neat solution to an otherwise tricky display problem.

Close serial port Return to top of page

It is essential that the port is closed after being used for a couple of important reasons:

  • The serial port uses alot of power, keeping the time that it is open to minimum will keep battery usage down to a minimum
  • Other applications that require the serial port will not function as access to the serial port will be denied

Results

Once the code has been compiled and downloaded to the Palm Pilot it is now possible to connect the ADC16 with aid from the power adapter.

Full code can be downloaded here: adc16.zip

References

ADC16 online help file, by Pico Technology Ltd
Palm Programming by Glen Bachmann, published by SAMS
www.palm.com
NewsGroups
pilot.programmer
pilot.programmer.gcc

Written by Matthew Laver

 

Return to top of page


 USA Office: Tel: 1-877-902-2979    Fax: 1-877-FAX-IECI     Pacific  Time Zone    
                   Tel:1-425-223-4311    Fax: 1-425-223-4303     Pacific Time Zone
P.O. Box 1280. Street Address: 145 Tyee Drive, Point Roberts, WA 98281

Sales inquiries to:  sales at interworldusa.com  Support & Service: support at interworldusa.com

Western Canada: - Vancouver, B.C. Tel: 1-(604) 925-6150    Fax: 1-(604) 925-6170 Toll Free:1-(800) 663-6001

    2454 Haywood Ave, West Vancouver, B.C. V7V 1Y1
  Eastern Canada: - Markham, Ontario Tel: 1-(905) 513-7027    Fax: 1-(905) 513-7029 Toll Free:1-(800) 465-0164
3555 14th Ave, Unit 12, Markham, Ontario L3R 0H5

Sales inquiries to:  sales at interworld.ca    Support & Service: support at interworld.ca

To visit our Australian web site, please click here.