39
The BECK-IPC based MAX-DOAS system Last edited: 2006-Nov-13 13:44 Written by Manne Kihlman, Sweden Email: [email protected]

The BECK-IPC based MAX-DOAS system  · Web viewLast edited: 2006-Nov-13 13:44. Written by Manne Kihlman, Sweden. Email: [email protected] Table of contents: Getting started 3. The CompactFlash

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: The BECK-IPC based MAX-DOAS system  · Web viewLast edited: 2006-Nov-13 13:44. Written by Manne Kihlman, Sweden. Email: manne@kedu.se Table of contents: Getting started 3. The CompactFlash

The BECK-IPC based MAX-DOAS system

Last edited: 2006-Nov-13 13:44Written by Manne Kihlman, SwedenEmail: [email protected]

Page 2: The BECK-IPC based MAX-DOAS system  · Web viewLast edited: 2006-Nov-13 13:44. Written by Manne Kihlman, Sweden. Email: manne@kedu.se Table of contents: Getting started 3. The CompactFlash

Table of contents:

Getting started......................................................................................................................3The CompactFlash card.......................................................................................................4The kongo.exe program.......................................................................................................4The cfg.txt file.....................................................................................................................5

Cfgsafe.txt........................................................................................................................6Cfgonce.txt.......................................................................................................................6DELAY=..........................................................................................................................6STEPSPERROUND=......................................................................................................7MOTORSTEPSCOMP=..................................................................................................7MOTORANGLECOMP=................................................................................................7SKIPMOTOR=................................................................................................................7POWERSAVE=...............................................................................................................7MOTORSWAP=..............................................................................................................7BATTERYLIMIT=..........................................................................................................8STARTCHN= and STOPCHN=......................................................................................8DEBUG=.........................................................................................................................8CONEANGLE=...............................................................................................................8SPECTROMETERTYPE=..............................................................................................8INSTRUMENTNAME=..................................................................................................8SERVER=........................................................................................................................9FTPTIMEOUT=..............................................................................................................9COMPASS=....................................................................................................................9PERCENT=.....................................................................................................................9CHANNEL=....................................................................................................................9REALTIME=.................................................................................................................10MEAS=..........................................................................................................................10Special MEAS= parameters...........................................................................................11

The programs and sourcecodes..........................................................................................12KONGO.EXE................................................................................................................12Showpak........................................................................................................................12

Description of the electronics............................................................................................12The chip.ini file..............................................................................................................14How to change the default baudrate for the spectrometer.............................................15The first version of the PCB-board................................................................................15The GPS connection on the old system.........................................................................15Serial port handshake.....................................................................................................16The solenoids.................................................................................................................16Stepper motor control and reference switch..................................................................16

The file-format in the scanning system.............................................................................18Checksum......................................................................................................................19Header size.....................................................................................................................19Date and time.................................................................................................................20The ADC-converter.......................................................................................................20Compressed data............................................................................................................21

Page 3: The BECK-IPC based MAX-DOAS system  · Web viewLast edited: 2006-Nov-13 13:44. Written by Manne Kihlman, Sweden. Email: manne@kedu.se Table of contents: Getting started 3. The CompactFlash

The tx.exe and transfer.exe programs................................................................................23The connectors on the new system....................................................................................24The PCB.............................................................................................................................28

Getting started Follow this if you want a quick start.

For old system:Connect your PC with a null modem cable to the COM port on the PCB. The null modem cable must have the cables required for hardware handshake i.e pins 2,3,5,7,8 must be connected to 3,2,5,8,7 respectively.

For new system:For the new version of the electronics, an ordinary elongation cable is instead required.where pins 2,3,5,7,8 must be connected to 2,3,5,7,8 respectively.

Start hyperterminal or any other terminal-emulator in 115200 baud, 8 databits, 1 stopbit, no parity and using hardware handshake. Choose to connect directly to the serial port where the null modem is connected.

Hyperterminal will start to show the output of the scanning software running on the embedded computer. The computer has multitasking capabilities making it possible to start new programs while others are running. The output can be changed by holding Control key and pressing f. It then toggles between USER, SHELL and BOTH. In USER-mode, only the output from the running programs is shown. In SHELL-mode, only the output from the operating system is shown. In BOTH-mode, both are shown.

Now press Ctrl-F until you have SHELL mode. The output from the scanning software should stop.

Press enter, then hyperterminal will display B:\>Type dir<enter> then the hyperterminal will show the files stored on the compact flash card.

The embedded computer has two internal disk drives. B: is the compact flash and A: is the startup-internal disk-drive.By entering A:<enter> you make the start-up disk your current disk-drive.By entering B:<enter> you make the CompactFlash disk your current disk-drive.

The file autoexec.bat stored on A: determines what happens when the computer restarts.You can display this file by entering

A: <enter>type autoexec.bat<enter>

Something similar to this will show:pio 5 5extide.exe

Page 4: The BECK-IPC based MAX-DOAS system  · Web viewLast edited: 2006-Nov-13 13:44. Written by Manne Kihlman, Sweden. Email: manne@kedu.se Table of contents: Getting started 3. The CompactFlash

b:kongo.exe

Explanation: The command pio 5 5 sets the PIO5 output of the CPU to low. This will cause the RTS signal on the COM port to raise high. This signal is used for the serial hardware handshake and tells the computer in the other end that it is ready to receive data. The command extide.exe loads the driver for the CompactFlash card. The command b: makes the CompactFlash card the current drive. The command kongo.exe starts the program kongo.exe stored on the CompactFlash. This program handles all the scanning and the communication with the spectrometer and GPS.

The CompactFlash card Currently 1GB compact flash cards are used. Tested versions of CompactFlash cards to be known to work are cards from SanDisk, Crucial and TwinMOS but cards from other manufacturers may also work. All files on the compact flash card can also be read/written by removing it from the PCB and inserting it in a CF-adapter on a standard PC. Power should be turned off from the Embedded computer before removing/inserting it.

The kongo.exe program The program kongo.exe stored on the CompactFlash card is automatically stared at startup. This program reads its configuration from the cfg.txt file also stored on the CompactFlash.

Page 5: The BECK-IPC based MAX-DOAS system  · Web viewLast edited: 2006-Nov-13 13:44. Written by Manne Kihlman, Sweden. Email: manne@kedu.se Table of contents: Getting started 3. The CompactFlash

The cfg.txt file The file cfg.txt looks similar to this:

% This is the cfg.txt file% This is a comment

MOTORDELAY=1STEPSPERROUND=2560MOTORANGLECOMP=180SKIPMOTOR=0

% Save power with the help of the internal stepper motor controllerPOWERSAVE=1BATTERYLIMIT=11.0

% STARTCHN=1000 this has been commented away% STOPCHN= 1999

STARTCHN=0STOPCHN=0DEBUG=1

%This name will be written in the spectrum-files (maximum 16 characters)%It also defines the name for the file containing the IP number uploaded to the serverINSTRUMENTNAME=Nicaragua_site1

SERVER=192.168.1.20 novac 1225 10

% timeout in miliseconds for accessing the serverFTPTIMEOUT=2000

PERCENT=0.74

% COMPASS= compassdir tiltX tiltY temperatureCOMPASS= 0.0 5.0 3.0 23.0

% sum1 is inside the specrometer [1 to 15]%-----pos----time-sum1-sum2--chn--basename--repetitions-flagMEAS= 0 -1 1 1 0 up_ang 1 0MEAS= 640 0 1 1 0 down 1 1MEAS= 1280 0 1 1 0 left 1 2MEAS= 1920 0 1 1 0 left 1 3----------------------------------- end of cfg.txt file ----------------------------------------------

The current cfg.txt settings can be displayed by entering the following in hyperterminaltype cfg.txt <enter>

Page 6: The BECK-IPC based MAX-DOAS system  · Web viewLast edited: 2006-Nov-13 13:44. Written by Manne Kihlman, Sweden. Email: manne@kedu.se Table of contents: Getting started 3. The CompactFlash

However, the cfg.txt file is usually longer than what can be displayed on the hyperterminal window. The cfg.txt file can be downloaded to your PC by sending the following command from hyperterminal:

ztrans com s cfg.txt 115200<enter>

This will start zmodem-download in hyperterminal. The file will be stored in the location on your PC as given by the Transfer->Receive File menu in hyperterminal. A new cfg.txt file can be uploaded to the embedded computer by first deleting the old file by sending:

del cfg.txt<enter>

and then sending the following command:ztrans com r 115200<enter>

After sending that, choose the menu Transfer->Send file. Then choose the cfg.txt you want to upload and choose Zmodem transfer in the dialog. The file created on the embedded computer will have the same name as on your PC (i.e. cfg.txt).

Files can also be uploaded and downloaded in a convenient way from your computer with the transfer program. See the chapter about transfer.exe for more information.

Cfgsafe.txt When kongo.exe starts (which typically happens at powerup) the program searches for a file called cfgsafe.txt. If such a file exists then it will be copied into the cfg.txt file. The purpose of this is to return to a default setting if connection with the central server is lost for a long time and the power is cut.

Here follows a description of all the fields in the cfg.txt file.

Cfgonce.txt If this file exists at the time when the measurements are supposed to start from the first MEAS= line, the program will instead parse this file in the same way as cfg.txt is parsed and execute each measurement according to the MEAS= lines in this file.After all measurements are done from this file, the file will be deleted. This feature is useful if you want to temporarily execute a different set of measurement without disturbing the routine measurements.

DELAY= This determines how many milliseconds to pause between each pulse when pulsing the stepper-motor. If this is set to 0 then the fastest possible speed will be used.If the old scanning hardware mechanics is used then DELAY=1000 should be used to cause a pulse speed of 1 pulse/second. If the new mechanics with Faulhaber motor and MCBL2805 controller is used then DELAY=2 should be used to cause a pulse speed of 500 pulses/second. The actual rotation speed is dependent on the number of steps/per round for the stepper-motor. The old motor had 200 steps/round. When using stepper-motor-simulation mode with MCBL2805 the factory setting is 1000. However this value

Page 7: The BECK-IPC based MAX-DOAS system  · Web viewLast edited: 2006-Nov-13 13:44. Written by Manne Kihlman, Sweden. Email: manne@kedu.se Table of contents: Getting started 3. The CompactFlash

can be changed to any value by reconfiguring the MCBL2805. With the new electronics with built in stepper-motor controller DELAY=1 is recommended.

STEPSPERROUND= This gives the number of steps required to make one full turn of the scanning system. This string should be followed by one or two integer values. If only one value is given or if the second value is zero then the system assumes that there is only one motor to control. If a value is positive, it indicates that the motor can only move in one direction. If a value is negative it indicates that motor 1 and/or motor 2 respectively can move both ways. For example STEPSPERROUND= -1000 –4000 indicates that first motor needs 1000 steps and second motor needs 4000 steps to make a full turn and both motors are capable of moving both ways.

MOTORSTEPSCOMP=

This determines the location of the reference position switch for the motor(s). Inside the software, the true position will be set to represent this position when the reference switch is detected. If two values are given by STEPSPERROUND= then also two values must follow this string.

MOTORANGLECOMP= This is an alternative to MOTORSTEPS= if it is more convenient to give the reference position in degrees. This string must be given after STEPSPERROUND= has been given since the given values are converted to steps with the help of the knowledge of number of steps per round.

SKIPMOTOR= If this value is not zero then all motor-activity is skipped.

POWERSAVE= This argument is only useful when using the internal stepper-motor controller in the new electronics. This argument can either be 1 or 0. Value 1 indicates that the current through the stepper-motor windings should be reduced to 1/3 of the nominal current when the stepper-motor is not moving. With the value 0, the current will not be reduced. Nominal current is 160mA. With the reduction it will thus be 160/3=53mA. Only the first internal stepper-motor controller can use current reduction. The second stepper-motor controller, also used for solenoids, always has the current set to 160mA.

MOTORSWAP= If this value is not zero then the first and second motor will be swapped with each other.This parameter can be useful if the first motor controller has been destroyed in field and you want to use the second controller as a replacement. However, remember that the second stepper motor controller does not have power-save capability. This feature swaps both the step and dir pulses as well as the sensing of the reference switch. It also swaps the internal stepper motor controllers. Notice: To make this work in a proper way with the internal stepper motor controller, the flag value of each MEAS= line should contain

Page 8: The BECK-IPC based MAX-DOAS system  · Web viewLast edited: 2006-Nov-13 13:44. Written by Manne Kihlman, Sweden. Email: manne@kedu.se Table of contents: Getting started 3. The CompactFlash

the value 7. (Remember this value usually determines the state of the solenoids and the value 7 indicates that no solenoids are connected and instead a stepper motor is connected to the 2nd motor connector).

BATTERYLIMIT= The computer should shut down activity if the battery voltage is lower than this threshold. The battery is checked at startup and just before a new measurement is done.If the battery level is low it will cut power to GPS, compass, motors and spectrometer and will recheck the voltage every 5 seconds. If the voltage reaches above this level again it will give these units power again. This only works with pcbversion 4 and newer and with the ADC installed.

STARTCHN= and STOPCHN= This determines the start-channel and stop-cannel of the spectrum polled from the spectrometer. If both values are zero or if these parameters are not given then the all channels of the spectrum are used.

DEBUG= The higher value given here, the more text will kongo.exe produce for debugging purposes. If DEBUG=0 then no text is written. Usually DEBUG=1 is a good parameter.

CONEANGLE= Defines the cone-angle of the instrument. Default is 90 degrees. This value is written in the header of each spectrum (version 4 and newer).

SPECTROMETERTYPE= This identifies what kind of spectrometer that are used. Currently only the value HR4000 and USB4000 are understood. For other values or if this parameter is not given, the program will assume that a S2000 compatible spectrometer is connected.This parameter affects the following things:

How exposure time is sent (with USB4000 and HR4000 it is sent with command ’i’ instead of command ‘I’)

What exposure times are tested for determining automatic exposure time (300ms and 10ms for HR4000 and USB4000 and 50ms and 10ms otherwise)

The maximum allowed number before saturation of the AD-converter (16384 for HR400 and 65536 for USB4000 and 4096 otherwise). This affects the calculation of automatic exposure time.

INSTRUMENTNAME= This name will be written in the header of the spectrum-files (maximum 16 characters) It also defines the name for the files uploaded to the ftp-server. After 2006-Nov-13, this value will also be read at startup from the spectrometer with the “?x0” command and this argument is therefore not needed anymore in the cfg.txt file. If still given in cfg.txt, it will override the serial number retrieved by the “?x0” command.

Page 9: The BECK-IPC based MAX-DOAS system  · Web viewLast edited: 2006-Nov-13 13:44. Written by Manne Kihlman, Sweden. Email: manne@kedu.se Table of contents: Getting started 3. The CompactFlash

SERVER= This determines the server where the embedded computer should try to upload existing upload.pak files. Three or optionally four arguments should be given, for exampleSERVER= 192.168.1.20 novac 1225 12

will contact an ftp-server with ip-nr 192.168.1.20 using username novac and password 1225 and it will try to upload after 12 full scans. Since typically a full scan takes 5 minutes (heavily depending on measurement strategy), the interval between each upload will be approximately 1 hour. If the fourth argument is not given then a default value of 10 is used, giving a typical interval of 50 minutes. The ftp connection will be made after the last measurement in the MEAS= list has been made. If the ftp transfer was unsuccessful it will not try again until another 12 full scans has been made. However, if the ftp-transfer was successful until the last transferred byte then the current upload.pak on the instrument will be deleted. If SERVER= is not given at all or if the IP nr=0.0.0.0 then no attempt to connect is made.

FTPTIMEOUT= This determines the timeout in milliseconds for accessing the server given by the SEVER= parameter. The currently installed server at Chalmers is slow on responding and a reasonably high value of 20 seconds (FTPTIMEOUT=20000) is therefore suggested. However this will force the measurements to stop during 20 seconds or until the reply arrives from the ftp-server when ftp-connection is attempted. This value could be lowered if other ftp-servers are used that are faster on replying, to speed up measurements.

COMPASS= Should be followed by 4 decimal numbers representing compassdir, tiltX, tiltY and temperature. For example: COMPASS= 0.0 5.0 3.0 23.0These four values are only copied into the headed of the spectrum-file.If the electronic compass module has been installed and is successfully detected then it will measure the true compass direction before a new full scan is started and the value from the electronic compass will instead be written in the header. The measurement will only be refreshed once every full scan. Compassdir,tiltX and tiltY are stored as integers multiplied by 10 thus giving 1 decimal point precision. Temperature is saved as a floaing point number.

More about TemperatureIf the spectrometer type is HR4000 or USB4000, kongo will read the temperature sensor located inside the spectrometer with the "?t" command. The value will be written in the temperature field in the spectrum header. The sensor is only read before the first MEAS=. If temperature is given as the fourth argument on the COMPASS= line, it will override the value queried from the spectrometer. Therefore, to use the spectrometer result, only use 3 arguments on the COMPASS= line or no COMPASS= line.

PERCENT= A decimal number between 0 and 1 should follow this string. It is used when automatic exposure time is used, see MEAS= below.

Page 10: The BECK-IPC based MAX-DOAS system  · Web viewLast edited: 2006-Nov-13 13:44. Written by Manne Kihlman, Sweden. Email: manne@kedu.se Table of contents: Getting started 3. The CompactFlash

CHANNEL= This determines the channel where the max-value used for the automatic exposure is determined. The light intensity will be averaged over 10 pixels centered on the channel given by this argument. If CHANNEL=-1 or if it is not defined then the max-value over all pixels will be used to determine automatic exposure time.

REALTIME= If realtime=0 then work.pak will be renamed to upload.pak only after a full scan. If it is one then it will try to rename it after every executed MEAS= line.

MEAS= This determines the different measurement position that should be used.Typically many MEAS= lines are following each other with increasing position in the end of the cfg.txt see the example in the beginning of this chapter.STEPSPERROUND= should always be defined before the first MEAS= line.

If only one value are given for the STEPSPERROUND= then only one parameter indicating the motorposition is expected. A MEAS= definition then looks like this

MEAS= pos1 exptime sum1 sum2 chn basename repetitions flagFor example:MEAS= 0 -1 1 1 0 up_ang 1 0

If two values are given for the STEPSPERROUND= then two parameters indicating the two motor-positions is expected (pos1 and pos2):

MEAS= pos1 pos2 exptime sum1 sum2 chn basename repetitions flagFor exampleMEAS= 0 0 -1 1 1 0 up_ang 1 0

Position pos1 and pos2 are given as motor-steps.

Exposure time is given in milliseconds if positive. If a negative exposure-time is given then an automatic exposure time is calculated by making two test measurements at 10ms and 50ms and getting the intensity values (determined by PERCENT= and CHANNEL=) in the retrieved spectrum and then extrapolate the exposure time by the formula:

where and are the intensities when using 10ms and 50ms exposure time respectively. The parameter percent can be changed with the PERCENT= parameter.

If the exposure time set to 0 then the same exposure time will be used as in the first MEAS= line. Typically the first MEAS= line is used for the zenith measurement and uses

Page 11: The BECK-IPC based MAX-DOAS system  · Web viewLast edited: 2006-Nov-13 13:44. Written by Manne Kihlman, Sweden. Email: manne@kedu.se Table of contents: Getting started 3. The CompactFlash

automatic exposure time. When it is beneficial to use the same exposure time for all the rest of the measurements then all the following exposure times can be set to zero. The true (used exposure time) is written in the exptime field in the header. This value will be negative to indicate that it was set automatically. A positive value indicates that it was not set automatically.

Sum1 is the number of spectrums added together inside the spectrometer. This number is limited to a value between 1 and 15 for the S2000. For USB4000 it is not limited. For HR4000 it currently only works with 1 spectrum.

Sum2 is the number of spectrums added together in the embedded computer. This number is limited to a value between 1 and 32767. The total number of added spectrums are sum1*sum2. It is better to use a high sum1 instead of a high sum2 since it reduces the time for transfer of spectrum from the spectrometer to the embedded computer.

Channel is the channel-number for the spectrometer. When a double-spectrometer is used then chn=0 will use the master-channel and chn=1 will use the slave channel. Values above 256 have special meaning, see the documentation for the OceanOptics spectrometers. With a single spectrometer chn=0 should be used.

Basename gives the name of this direction. This is copied into the header of the spectrum file.

The value repetitions determine how many times this MEAS= line will be repeated.If this value is 0 then it will not be executed at all. The repeat parameter is useful when doing wind-measurements, where the system should stand for a long time taking many spectrums in the same direction. If the repetitions number is missing in the MEAS= line then repetitions will be set to 1.

The flag value determines the state of the solenoids, see special solenoid chapter below. If a flag value is missing in the MEAS= line then flag=7 will be used. The value 7 has a special meaning with the new electronics. It will then use the electronics for the solenoids and drive a second stepper motor on the same connection as where the solenoids are connected. This mode is not possible to use together with solenoids.

Special MEAS= parameters

When the program finds the string HOMEMOTOR on a MEAS= line it will home the motors according to the two numbers following MEAS= representing each of the two motors. The value can be -1,1 or 0. For example:

MEAS= -1 -1 HOMEMOTOR

If the number is zero then that motor should not be homed. If the value is 1 then it should rotate in the positive direction while seeking the reference switch. If the value is -1 then it

Page 12: The BECK-IPC based MAX-DOAS system  · Web viewLast edited: 2006-Nov-13 13:44. Written by Manne Kihlman, Sweden. Email: manne@kedu.se Table of contents: Getting started 3. The CompactFlash

should rotate in the negative direction while seeking the reference switch. A line like MEAS= -1 -1 HOMEMOTOR can be inserted at any place in the list of measurements.

Page 13: The BECK-IPC based MAX-DOAS system  · Web viewLast edited: 2006-Nov-13 13:44. Written by Manne Kihlman, Sweden. Email: manne@kedu.se Table of contents: Getting started 3. The CompactFlash

The programs and sourcecodes

KONGO.EXE The scanning program has been compiled with freeware Watcom C-compiler to produce a standard DOS-16 bit application and has then been downloaded to the embedded computer. The program does however use some interrupts that are special for the BECK-IPC computers and will therefore crash if run on a standard Windows or DOS-computer.The watcom compiler can be downloaded from:http://www.kedu.se/novac/open-watcom-win32-1.3.exe

To compile it with the watcom compiler, open the kongo.wpj file when watcom has started. The code should be compiled for 80186 processor and should use “Floating Point calls” These are respectively set by the menus:

C Compiler Switches->10. Memory model and processor switchesC Compiler Switches->7. Code Gen Strategy switches

Showpak This program should be run on your PC and is a skeleton for a fetch-and-display application for the system. The program should be started from where you want your upload.pak file downloaded. When the program starts up and if an upload.pak exists on your PC then it will show the spectrum stored in the upload.pak. You can walk forward backward between the different spectrum one at a time by pressing arrow up-down key. You can walk forward backward between the different spectrum ten at a time by pressing pageup-pagedown. Almost all of the parameters given in the header are also shown in the window. A file export.std is created for the currently displayed spectrum in the default folder. This is a standard std file that can be opened in doasis etc.. When key P is pressed, the programs tries to poll new data by connecting, first through com1 and then com5 to the embedded computer, and tries to fetch a new upload.pak. If successful, the new information will be stored in the end of the upload.pak file already on your PC. It will also try to poll the embedded computer if it starts without an upload.pak file in its default folder. Showpak has been compiled with the freeware compiler Bloodshed Dev-C++.

Description of the electronics The control system is based on the BECK-IPC SC12-LC chip. This is an embedded computer that can run programs in a similar manner as MS-DOS programs. In one single chip, it consists of an 80186 processor running on 20 MHz, 512 Kbyte RAM, 512 Kbyte of FLASH-EEPROM containing an operating system and the running programs. It also contains a 10Mbit/s Ethernet-network interface and two RS232 connections. It also contains an embedded operating system similar to MS-DOS. It has multitasking capabilities, a web-server, ftp-server and built in commands for using the network-interface. Approximately 200K byte of the FLASH-EEPROM is occupied by the operating system, leaving 312 Kbyte for simulating a disk drive where running programs can be stored and collected data saved.

Page 14: The BECK-IPC based MAX-DOAS system  · Web viewLast edited: 2006-Nov-13 13:44. Written by Manne Kihlman, Sweden. Email: manne@kedu.se Table of contents: Getting started 3. The CompactFlash

It is also possible to directly upgrade the system by using the SC13-LC chip instead. This chip has 40 MHz clock instead of 20MHz and has 10/100 Mbit/s Ethernet-connection. However, the power-consumption is twice as high and this chip was not chosen because of this.

Page 15: The BECK-IPC based MAX-DOAS system  · Web viewLast edited: 2006-Nov-13 13:44. Written by Manne Kihlman, Sweden. Email: manne@kedu.se Table of contents: Getting started 3. The CompactFlash

The chip.ini file The SC12 circuit is configured by the file chip.ini stored on the internal disk A:\It can be displayed by entering type chip.ini in hyperterminal. The file looks similar to this:

[FTP]DRIVE0=1USER0=novacPASSWORD0=1225USER1=administratorPASSWORD1=1225DRIVE1=0TIMEOUT=65535

[WEB]ENABLE=1DRIVE=1WEBSERVERSTACK=10240SECURE=1

MAINPAGE=main.htmTEMPPATH=B:\

[TELNET]USER0=novacPASSWORD0=1225USER1=administratorPASSWORD1=1225

[SERIAL]EXT_BAUD=115200EXT_RECVQUEUE=10240EXT_SENDQUEUE=10240COM_BAUD=115200COM_RECVQUEUE=10240COM_SENDQUEUE=10240

[IP]NETMASK=255.255.0.0GATEWAY=129.16.1.4ADDRESS=129.16.35.207DHCP=0

The baud-rate used for communicating with the spectrometer is set by the EXT_BAUD parameter. Make sure this parameter match the baud-rate for your spectrometer. The default baud-rate for OceanOptics spectrometers is 9600 but can be changed with the x43 command. With the ADC-1000 and 2000 spectrometers baud-rates up to 115200 can be used which greatly reduces the time for transmission. The baud-rate for communicating with your PC is set by the COM_BAUD parameter.If connecting by Ethernet, the parameters are given after the [IP] tag. By default telnet and ftp server is enabled and the web server is disabled. The passwords are also given in the chip.ini file. For more information, see the documentation for the SC12 chip in the folder SC12V0110.

Page 16: The BECK-IPC based MAX-DOAS system  · Web viewLast edited: 2006-Nov-13 13:44. Written by Manne Kihlman, Sweden. Email: manne@kedu.se Table of contents: Getting started 3. The CompactFlash

How to change the default baudrate for the spectrometer To change the default baudrate for the spectrometer you should connect it directly to the serial port of your PC. Using hyperterminal, and communicating at the baudrate the spectrometer is currently set to you should give the commands:

“x43<enter>””Baud 6<enter>”

Then you should check that it works by entering“?x43<enter>”and the spectrometer should then respond“Baud 6”

Now turn off the power to the spectrometer and turn on it again. It should now communicate at 115200 baud.

The first version of the PCB-board

In the first version of the MAX-DOAS system the SC12-LC chip is mounted on a DK50 experiment board. The DK-50 board also has a holder for a CompactFlash card. Currently a 1GB Compact Flash card is used in this holder. An area of the PCB with extra holes has been used to build additional electronics. On this area, a separate 5V voltage regulator is built, the connection to the GPS, a MOS-FET power switch to turn on/off the power to the motor-controllers. It also contains one or two MOS-FET power switches to control one or two solenoids. The embedded computer has two DB9 RS-232 connections. The one marked EXT is used to connect to the spectrometer. The one marked COM is used to make contact to an external PC. The COM port is by default configured to 57600 baud, 8 databits, 1 stopbit, no parity and hardware handshake. The hardware handshake is configured in such way that the embedded-computer always accepts incoming data (by setting RTS to positive), since the computer has large (10240 byte) serial buffers and are quick to respond to incoming data.

The GPS connection on the old system Any GPS device with a serial output giving NMEA strings at 4800 baud can be used. There are a lot of choices of these on the market for example the Evermore GM-X205, GlobalSat BU-305, GlobalSat BR355 or San Jose GM48. Since there are no serial ports left on the embedded computer, a separate interface was built on the experiment area on the PCB. It consists of a PC16F84 microcontroller that searches for the $GPRMC or the $GPGGA string in the data from the GPS. Every odd time it searches for $GPRMC and every even time it searches for $GPGGA. When found, it stores the string following the identification into an internal RAM-memory until a * is encountered, indicating the end of the string, or until the maximum length of 62 characters is reached. The data stored in the RAM is then transferred to the Embedded CPU using a 2 wire interface, using one wire as clock and the other as data. The clock timing is determined by the SC12 CPU by rising and lowering the clock signal in software.

Page 17: The BECK-IPC based MAX-DOAS system  · Web viewLast edited: 2006-Nov-13 13:44. Written by Manne Kihlman, Sweden. Email: manne@kedu.se Table of contents: Getting started 3. The CompactFlash

The PIC16F84 uses a cheramic resonance at 20MHz as its oscillator source. The file gps20.asm contains the source code (assembler) for the program running in the PIC16F84. The freeware-tools PICASM and TOPIC have been used to assembler and download it into the PIC16F84.

For the new versions of the electronic, either PIC16F627, PIC16F628 or PIC16F628A can be used since these have 2 pins more and these are required to control the ADC. The source code for those are called gps20_7.asm, gps20_7_627.asm, and gps20_7_628.asm. These chips do not need an external frequency source. The freeware tools MPASMWIN and WinPic have been used to assemble and download the program to the chip.

Serial port handshake Transmission from the embedded-computer is put on hold until the CTS signal is high. This is required to make communication with serial radio-modems reliable under bad conditions. When failure to send, the radio-modem puts the CTS low, preventing further data-flow, until successful and the sets the CTS signal high.

The solenoids Two solenoids can be controlled by the system. The state of the two solenoids are determined by the two lower bits of the flag-number given as the last parameter on a MEAS= definition. If the bit is 1 then current will flow in the solenoid. For each value of the flag number, the following solenoids will be activated:Flag value Solenoid 1 Solenoid 20 off off1 on off2 off on3 of of4 alternating off7 Will control a second stepper motor with the electronics.

Stepper motor control and reference switch

One step signal and one direction signal controls each motor. First motor is controlled by the same signals as RTS and CTS on the EXT-serial port. Therefore, hardware handshake cannot be used when communicating with the spectrometer. However, this is not a problem since the embedded computer has large enough input buffers.The following PIO pins on the SC12-LC is used to control the motor(s):

PIO9 Direction/Reference switch for motor1 (also CTS for EXT-serial)PIO10 Pulse for stepper motor1 (also RTS for EXT-serial)PIO0 Direction/Reference for stepper motor2 (optional)PIO1 Pulse for stepper motor2 (optional)

The reference switch is connected through a 1K resistor between the direction signal and ground. When the reference signal is sensed in software, the direction pin is temporarily

Page 18: The BECK-IPC based MAX-DOAS system  · Web viewLast edited: 2006-Nov-13 13:44. Written by Manne Kihlman, Sweden. Email: manne@kedu.se Table of contents: Getting started 3. The CompactFlash

switched to input mode with internal pull-up. If the input on the direction/reference pin is logical zero it means the reference position has been reached. The 1K-resistor prevents a complete shortening of the direction pin when the direction pin is switched back to output mode. Observe that the input resistance of the direction input of the stepper-motor controller cannot be lower than 20K for this to work. This is not a problem when using the MCBL2805.

(Notice when configuring a new system: The MCBL2805 takes the pulse input on its AIN-pin and takes the direction on its FAULT-pin. Stepper-emulation mode is configured in the MCBL2805 by sending the STEPMOD command. Then it should be configured by sending the DIRIN command to accept direction-input on its FAULT pin to get the direction. After sending these commands, then send EEPSAV to store these settings in non-volatile memory.)

Page 19: The BECK-IPC based MAX-DOAS system  · Web viewLast edited: 2006-Nov-13 13:44. Written by Manne Kihlman, Sweden. Email: manne@kedu.se Table of contents: Getting started 3. The CompactFlash

The file-format in the scanning system

The software running in the embedded CPU in the scanning system stores the spectra in a special format in one single file. This file increases every time a new spectrum is saved and the new spectrum is appended to the end of the file. The file is called work.pak and is as the name indicates, the data that is worked on. There is another file called upload.pak, and as the name indicates, this is data that is ready to be uploaded. Whenever the scanning software is not saving to work.pak, it checks if there is no file called upload.pak. It will then try to rename the work.pak file if it exists to upload.pak. Thus to retrieve all spectra, the remote software should check if a upload.pak file exists, download it, check if the download was successful and then delete the upload.pak file. If new spectra are available there will appear a new upload.pak file and the operation can be repeated. In the remote end, the software can choose to append a new upload.pak to the end of an existing upload.pak if it is preferable that all spectra are stored in just one file.

The file-format of the upload.pak file is as follows:Header1Compressed data 1Header2Compressed data 2Header3Compressed data 3Header…Compressed data …

There is no special data in the beginning or end of the file. Thus, the files can be appended to each other.

Each spectrum has a header and a data filed containing compressed data. There is no limit in how many spectra that may be contained in one file. The header has the following format: (this is defined in the sourcecode mk_pack.c)

#define hdr_version 5

struct MKZYhdr{ char ident[4]; // "MKZY" unsigned short hdrsize; // this is the size in bytes of the header unsigned short hdrversion; // version of the header unsigned short size; // the number of bytes with compressed data unsigned short checksum; // checksum for the uncompressed data char name[12]; // the name of this specific measurement char instrumentname[16]; // the name of the instrument unsigned short startc; // the startchannel for the first data-point unsigned short pixels; // number of pixels saved in the data-field short viewangle; // the viewing angle of the instrument

Page 20: The BECK-IPC based MAX-DOAS system  · Web viewLast edited: 2006-Nov-13 13:44. Written by Manne Kihlman, Sweden. Email: manne@kedu.se Table of contents: Getting started 3. The CompactFlash

unsigned short scans; // total number of scans added short exptime; // exposure time, negative if set automatic unsigned char channel; // channel of the spectrometer, typically 0 unsigned char flag; // for further use, currently contains the // status of the solenoid(s) in bit 0 and 1 unsigned long date; // date unsigned long starttime; // time when the scanning was started unsigned long stoptime; // time when the scanning was finished double lat; // GPS latitude in degrees double lon; // GPS longitude in degrees short altitude; // new in version 2 char measureidx; // new in version 2, nr between 0 and measurecnt-1 char measurecnt; //new in version 2 // number of MEAS= lines in cfg.txt short viewangle2; //new in version 3, direction of 2nd motor short compassdir; //new in version 3, given in cfg.txt short tiltX; //new in version 3, given in cfg.txt short tiltY; //new in version 3, given in cfg.txt float temperature; //new in version 3, given in cfg.txt char coneangle; //new in version 4, given in cfg.txt unsigned short ADC[8]; //new in version 5};

Checksum The checksum is calculated on the uncompressed data and is therefore also a check that the compression is working properly. The checksum can be calculated with the following routine in C:

long spec[]; // containing the spectral data points int speclen; // containing the number of datapoints stored in the spec vector unsigned long checksum; unsigned short *p; checksum=0; for(i=0;i<speclen;i++) checksum+=spec[i]; p=(unsigned short *)&checksum; MKZY.checksum=p[0]+p[1];

Thus, all spectral points are added together into an unsigned long and the upper and lower word of that longword is the added to give a checksum in the format of an unsigned short.

Header size The field hdrsize has been included to make it possible to add further fields to to the end of the header in the future. This field should contain the size of the header in number of bytes. To make it possible for a newer software to read an older header version and vice versa the software should only read the number of bytes given in this number or the

Page 21: The BECK-IPC based MAX-DOAS system  · Web viewLast edited: 2006-Nov-13 13:44. Written by Manne Kihlman, Sweden. Email: manne@kedu.se Table of contents: Getting started 3. The CompactFlash

number of bytes of the header that it can understand whichever is the smallest. If more unsupported bytes exists then it should just be skipped. This way, fields in the header that is not implemented in the file or in the software will thus just be omitted.

A field (hdrversion) indicating the version number of the header also exists. This will increase in future versions of the header. In he latest version of the header when this was written (27-July-2006) this field has the value 5.

Date and time Times and dates are given as GMT (Greenwich Mean Time).The GPS are reread every time the list of measurement angles is started from the beginning. If reading a correct latitude and longitude from the GPS was possible then the CPU clock is set to the date and time fields retrieved by the GPS. This updating of the clock is only done once, i.e. the first time a correct GPS position was retrieved. Thus, if the scanning system has successfully retrieved a GPS position since it was powered on, then the clock will be set to Greenwich Mean Time. The CPU clock does not have a battery that keeps the clock running after poweroff. However, the following mechanism has also been implemented that sets the clock at startup to a reasonable value: After start up after reset or power-cycling, the scanning software will check the time and date of the last change made to the file work.pak. If no such file exists then it tries to use upload.pak instead. It sets the time&date to the same as when the last change was made. Therefore, the time&date saved in the spectra will always increase. Thus, when there is no way to get GPS-reception, the clock will still survive short power failures but will lag with approximately 10-60 seconds for every short power failure.

The date field in the header is an unsigned long. When this values is written in decimal representation with 6 digits it will write in the following way: ddmmyy.Thus to represent 29-November 2005 this field will have the decimal value 291105

The starttime and stoptime in the header are both unsigned long numbers.When these values are written in decimal representation with 8 digits it will write in the following way: hhmmssdd where dd are the decimal seconds.Thus to represent the time 670 milliseconds after 9:35:00 in the morning the time fields should have the decimal value 09350067

The ADC-converter The voltages read by the ADC just before the spectrum is retrieved will be stored in the eight fields called ADC in the header. The first value is the battery voltage multiplied with 100. Thus a value of ADC[0]=1380 will indicate that the battery voltage is 13.8V.The rest of the values will be set by the voltage (millivolt) on the rest 7 ADC channels that are available on the 9 pin DSUB marked ADC (see section of connectors on new system). The measured voltages can be between 0 and 4095 mV. For measuring the battery, an internal voltage divider of 10 has been used to give a maximum value of 40.95V.

Page 22: The BECK-IPC based MAX-DOAS system  · Web viewLast edited: 2006-Nov-13 13:44. Written by Manne Kihlman, Sweden. Email: manne@kedu.se Table of contents: Getting started 3. The CompactFlash

Compressed data After the header follows the compressed data actually containing the spectrum.The number of bytes of data is given by the field size in the header.

When compressing, the pixel values representing the spectrum are represented in a different way: The first pixel is unchanged, the following pixels is changed to the difference between the current pixel and the foregoing pixel values. This way, the pixel values can be represented with much smaller numbers if the spectrum is smooth or has low intensities. After this change of representation, the pixels are compressed by dividing it into chunks of data and just using the number of bits that are required to represent the values in each chunk. The number of pixels in each chunk varies and are choose so that the total size is minimized. Each chunks starts with a 12 bit long header. The first 7 bits contains the number of pixels in the chunk. Thus the maximum length of a chunk is 127 pixels. The following 5 bits determines how many bits are used to represent the pixels in the chunk. Thus the maximum number of bits is 31. After the chunk header comes the pixels and are then only saved with the number of bits that are given in the chunk header. After the data-bits representing the pixel values follows immediately the next chunk if the current chunk was not the last one.

For example a file containing two spectra looks like this:

1 Spectrum Header1 Compressed Pixel data {

Chunk 112 bits of Chunk header (X nr of pixels, Y nr of bits)X*Y number of bits representing the pixelsChunk 212 bits of Chunk header (X nr of pixels, Y nr of bits)X*Y number of bits representing the pixelsChunk …12 bits of Chunk header (X nr of pixels, Y nr of bits)X*Y number of bits representing the pixels} The compressed data are always filled to end on a full byte.

2 Spectrum Header2 Compressed Pixel data {

Chunk 112 bits of Chunk header (X nr of pixels, Y nr of bits)X*Y number of bits representing the pixelsChunk 212 bits of Chunk header (X nr of pixels, Y nr of bits)X*Y number of bits representing the pixelsChunk …12 bits of Chunk header (X nr of pixels, Y nr of bits)X*Y number of bits representing the pixels} The compressed data are always filled to end on a full byte.

Page 23: The BECK-IPC based MAX-DOAS system  · Web viewLast edited: 2006-Nov-13 13:44. Written by Manne Kihlman, Sweden. Email: manne@kedu.se Table of contents: Getting started 3. The CompactFlash

The following subroutine written in C can be used to uncompress a data-field:Inpek is a pointer to the compressed data. The pixels will be uncompressed to ut. Kvar is total number of pixels (can be retrieved from MKZY.pixels).

long UnPack(unsigned char *inpek, long kvar, long *ut){ long *utpek,a; short len,curr,short j,jj; unsigned short lentofile=0; long bit=0; utpek=ut; while(kvar>0) { for(len=0,j=0;j<7;j++,bit++) { // fetch chunk length len+=len; len|=inpek[(bit>>3)]>>(7-(bit&0x7))&1; } for(curr=0,j=0;j<5;j++,bit++) { // fetch number of bits in chunk curr+=curr; curr|=inpek[(bit>>3)]>>(7-(bit&0x7))&1; } if(curr) { for(jj=0;jj<len;jj++) // walk through all the pixels in this chunk { a=inpek[(bit>>3)]>>(7-(bit&0x7))&1; if(a) a=-1; // negative pixel value? bit++; for(j=1;j<curr;j++,bit++) // get all the bits for one pixel { a+=a; a|=inpek[(bit>>3)]>>(7-(bit&0x7))&1; } *utpek++=a; } } else for(jj=0;jj<len;jj++) *utpek++=0; // just fill with zero if nr of bits is 0 kvar-=len; lentofile+=len; } for(jj=1;jj<lentofile;jj++) // convert from representation as differences ut[jj]+=ut[jj-1]; return(lentofile); // return the number of pixels successfully read}

Page 24: The BECK-IPC based MAX-DOAS system  · Web viewLast edited: 2006-Nov-13 13:44. Written by Manne Kihlman, Sweden. Email: manne@kedu.se Table of contents: Getting started 3. The CompactFlash

The tx.exe and transfer.exe programs

tx.exe is a program that runs on the BECK-CPU and can be used to download/upload files in a convenient manner when the systems are connected through FREEWAVE serial radio-modems. It communicates with a console program called transfer.exe that should be run on your PC.

The arguments given on the command lines to transfer.exe are: transfer.exe s/r/d/x filename radionumber

First parameter must be either r (for recieve), s (for send), d (for delete) or x (for execute)

Second argument must be the filename. The file must be in the current directorywhen you run the program.

Third argument is optional. If it is given then it is the radio-number to call before starting the transfer with the ATD command. If the number only consists of one digit it will assume that it is the callbook number and will then use the ATDT command instead. If no argument is given then it assumes that the BECK-PC is directly connected to your computer.

Some examples on how to use it:Send:

transfer s cfg.txt 1(This will update the cfg.txt on the system connected to the second radio in the callbook of the master-modem.)

transfer s kongo.exe(This will update the kongo.exe on the system connected directly to your COM-port)

Receive:transfer r upload.pak 9222930(This will download the file called upload.pak from the system connected to radiowith number 922-2930 without deleting it afterwards.)

Remote execution:To remotely execute a command use x as first argument. For example:

transfer.exe x dir 2(This will show a directory listing of the BECK-system connected to radio 2)

Remote delete:To remotely delete a file use d as first argument. For example:

transfer.exe d upload.pak 2(This will delete the file upload.pak on the BECK-system connected to radio 2)

Page 25: The BECK-IPC based MAX-DOAS system  · Web viewLast edited: 2006-Nov-13 13:44. Written by Manne Kihlman, Sweden. Email: manne@kedu.se Table of contents: Getting started 3. The CompactFlash

The connectors on the new system

The new system has connectors on the long side shown on figure 1 and on the short side shown in figure 2.

Figure 1. The connections on the long-side of the computer.

The long side of the computer contains connection for serial port to the computer (9 pin female DSUB), Ethernet (standard 8 pin RJ45-8/8 Ethernet contact), power connector (2,1 mm plug), connector for solenoids or second stepper motor (9 pin male DSUB).

Page 26: The BECK-IPC based MAX-DOAS system  · Web viewLast edited: 2006-Nov-13 13:44. Written by Manne Kihlman, Sweden. Email: manne@kedu.se Table of contents: Getting started 3. The CompactFlash

Figure 2. The short side of the computer.

The short side of the computer contains connectors for first stepper motor (9 pin male DSUB), the compass (3 pole 3.5mm jack), a hole where wires to GPS and spectrometer are coming out, and the connection to the ADC (9 pin male DSUB).

The pins on the connections has the following functions:

Serial port connection:Pin 2: TxPin 3: RxPin 5 GNDPin 7: RTSPin 8: CTSAll other pins are unconnected

Ethernet:Pin 1 TX+Pin 2 TX-Pin 3 RX+Pin 4-5 connected togetherPin 6 Rx-Pin 7-8 connected together

Page 27: The BECK-IPC based MAX-DOAS system  · Web viewLast edited: 2006-Nov-13 13:44. Written by Manne Kihlman, Sweden. Email: manne@kedu.se Table of contents: Getting started 3. The CompactFlash

Power connector:Center pin: +12V (maximum allowed voltage is +16V).Circumference: GND

Stepper motor 2 or solenoid:Pin 1 stepper motor winding 1 or solenoid 1Pin 2 stepper motor winding 1 or solenoid 1Pin 3 stepper motor winding 2 or solenoid 2Pin 4 stepper motor winding 2 or solenoid 2Pin 5 GNDPin 6 MOSFET-ED GND, will turn off when PC says so.Pin 7 Power +12VPin 8 Step pulse for 2nd stepper motorPin 9 Dir/reference switch for 2nd stepper motorThe reference switch should be serially connected with a 1Kohm resistor between pin 5 (GND) and pin 9 (Dir/reference)

Connectors on short edge:Stepper motor 1:Pin 1 stepper motor winding 1Pin 2 stepper motor winding 1Pin 3 stepper motor winding 2Pin 4 stepper motor winding 2Pin 5 GNDPin 6 MOSFET-ED GND, will turn off when PC says so.Pin 7 Power +12VPin 8 Step pulse for 1st stepper motorPin 9 Dir/reference switch for 1st stepper motorThe reference switch should be serially connected with a 1Kohm resistor between pin 5 (GND) and pin 9 (Dir/reference)

GPS:

Page 28: The BECK-IPC based MAX-DOAS system  · Web viewLast edited: 2006-Nov-13 13:44. Written by Manne Kihlman, Sweden. Email: manne@kedu.se Table of contents: Getting started 3. The CompactFlash

SpectrometerPin 1 +5V powerPin 2 RXPin 3 TXPin 5 GNDPin 1 and 5 also go to a separate power connector (DC-plug 1.3/3.4mm)

ADCPin 1 +5V power source to drive external sensorsPin 2 Channel 2 on ADCPin 3 Channel 3 on ADCPin 4 Channel 4 on ADCPin 5 GNDPin 6 Channel 5 on ADCPin 7 Channel 6 on ADCPin 8 Channel 7 on ADCPin 9 Channel 8 on ADC

(Channel 1 on ADC is internally connected to the battery voltage through a X10 divider)

Page 29: The BECK-IPC based MAX-DOAS system  · Web viewLast edited: 2006-Nov-13 13:44. Written by Manne Kihlman, Sweden. Email: manne@kedu.se Table of contents: Getting started 3. The CompactFlash

The PCB The new system has been designed with the ExpressPCB software that is freeware.The printed circuit boards have been ordered from ExpressPCB with the help of the program. The ExpressPCB program can be downloaded from:http://www.kedu.se/novac/ExpressPCBSetup.exe

Figure 3 and 4 shows the bottom and top layer of the PCB as given by the ExpressPCB software. The CAD drawing can be downloaded at http://www.kedu.se/novac/maxdoas10.pcb

Figure 3: Bottom layer of PCB

Figure 4: Top layer of PCB