¿ªÔÆÌåÓý

Re: Help with EZGPIB


 

Thanks Harvey;

I was hoping for a simple answer such as:

Sname:=EZGPIB_ConvertStripToNumber(Sname,Sname,Sname); // where Sname is the string

Or some variation that uses commas, colons, quotes, or other punctuation. I looked through all the sample code and examples from Ulrich Bangert and found nothing (that I understood anyway). I tried some guesses and came to the conclusion that this function will not do what I want.

?

I went through all the functions and found the

?

EZGPIB_ConvertRemove(What:string;FromWhere:string);

Removes all instances of ¡°What¡± in ¡°Where¡±

?

This is the total description and a novice programmer, like me, does not really understand how to use this when there are no examples. What exactly do I put in the brackets? I tried different things until the compiler stopped complaining. I probably have it wrong even though it works.

?

I also went through a Pascal tutorial but it does not go beyond simple strings. Strings separated by commas may be regarded as an array, or more than one string. I am not a programmer and writing a page of code to replace three lines is asking for frustration.

?

So the following works

?

EZGPIB_ConvertRemove('NZFN', Answer);??? ??????????? // Answer is the string

EZGPIB_ConvertRemove('NTDN', Answer);

EZGPIB_ConvertRemove('K', Answer);

?

but with the correct punctuation it might be written as one line such as

?

EZGPIB_ConvertRemove('NZFN', Answer; 'NTDN', Answer; 'K', Answer); ?// does not work

?

Attempts at variations gave compile errors like ¡°too many variables¡±

?

My complete program is not very elegant but is easy to understand and modify, and it works.

It sets up the 4192A to display Magnitude, Phase, and Frequency. Then it starts with a frequency, and step frequency, and reads 9 times (e.g. 1kHz to 9kHz in 1kHz steps), the step frequency is increased and 9 more reads are taken (e.g. 10kHz to 90kHz in 10kHz steps), this is repeated again (e.g. 100kHz to 900kHz in 100kHz steps). If this was the last loop then 10 reads can be taken (e.g. 100kHz to 1000kHz in 100kHz steps). All reads are appended to the end of a buffer and upon completion the buffer is read to memory. Copy and paste makes variations easy so any of the units the 4192A can calculate can be read. The 4192A is quite versatile but is 1980 technology so the 7470A plotter was not yet invented and I have to work within the limitations.

The same program with slight modifications will control the HP4193A Vector Impedance Meter.

If there is no simple improvement then I will post the program to a file in a 4192A folder. Maybe an expert could re-write it to be easier to use. I cannot see how to pass variables to the EZGPIB functions and could not find suitable examples to follow.

?

This is an interim solution as I would like to move on to a C++ program that could be more interactive. Perhaps someone has already written such programs in C++.

?

My present program is this:


Program HP_4192A_Project;????????????????????? ??????????????? // LF Impedance Analyzer

// Note this is a work in progress. It acquires 3 freq decades of Z, phase, and Freq

?

?const filename= 'C:\users\user\My Documents\GPIB Prologix\HP4192A_Data.txt';

?? HP4192A???? =16;????? ?????????????????????????????????????????????????????? // LF Impedance Analyzer

?? Timeout?? =10.0;????? ?????????????????????????????????????????????????????? //

?var Answer:string;

???? i:integer;

????

begin

? ezgpib_screenclear;??????????????????????????????? ???????????????????????????????????? // Clear output console screen

? EZGPIB_ScreenWriteLn('HP 4192A Project');? ? ? ? ? ? ? ? ? ? ? ? ? // display title

? EZGPIB_fileclearbuffer;????? ??????????????????????????????????????????????????????? // clear buffer

?if EZGPIB_FileExists(Filename)then EZGPIB_fileDelete(Filename); // delete old file

? EZGPIB_BusWriteData(HP4192A,'A1B1T3F1');?? ??????????????????????????????? // Z, deg, hold/manual trig, display A/B/C

? EZGPIB_BusWriteData(HP4192A,'FR1EN');????????? ??????????????? // Spot Fequ 1 kHz

? EZGPIB_BusWriteData(HP4192A,'SF1EN');????????????? ??????????? // Step 1kHz

? EZGPIB_BusWriteData(HP4192A,'ABW0');?????????????? ?????????? // Abort Sweep, Manual Sweep

for i:=1 to 9 do

begin;

? EZGPIB_BusWriteData(HP4192A,'EX');???????????????? // Trigger

? EZGPIB_BusWaitForData(HP4192A,Answer,Timeout);??? // Get data

? EZGPIB_ConvertRemove('NZFN', Answer);?????? ??????????????? // delete NZFN

? EZGPIB_ConvertRemove('NTDN', Answer);?????? ??????????????? // delete NTDN

? EZGPIB_ConvertRemove('K', Answer);??????????????? ??????????????? ??????????????? // delete K

? EZGPIB_FileAddToBuffer(Answer);? ???????????????????????????????????? // add to buffer

? EZGPIB_ScreenWriteLn(Answer);????????????????????? ??????????????????? // Display on screen

? EZGPIB_TimeWaitForMultipleOf(1);?????????????????? ?????????????????? // Delay 1 seconds

? EZGPIB_BusWriteData(HP4192A,'W2');???????????????? ?????????????? // Step up

end;

? EZGPIB_BusWriteData(HP4192A,'SF10EN');???????????? ?????????? // Step 10kHz

for i:=1 to 9 do

begin;

? EZGPIB_BusWriteData(HP4192A,'EX');???????????????? // Trigger

? EZGPIB_BusWaitForData(HP4192A,Answer,Timeout);??? // Get data

? EZGPIB_ConvertRemove('NZFN', Answer);?????? ??????????????? // delete NZFN

??EZGPIB_ConvertRemove('NTDN', Answer);?????? ??????????????? // delete NTDN

? EZGPIB_ConvertRemove('K', Answer);??????????????? ??????????????? ??????????????? // delete K

? EZGPIB_FileAddToBuffer(Answer);??????????????????? ?????????????????? // add to buffer

? EZGPIB_ScreenWriteLn(Answer);????????????????????? ??????????????????? // Display on screen

? EZGPIB_TimeWaitForMultipleOf(1);?????????????????? ?????????????????? // Delay 1 seconds

? EZGPIB_BusWriteData(HP4192A,'W2');???????????????? ?????????????? // Step up

end;

? EZGPIB_BusWriteData(HP4192A,'SF100EN');???????????? ??????? // Step 100kHz

for i:=1 to 10 do

begin;

? EZGPIB_BusWriteData(HP4192A,'EX');???????????????? // Trigger

? EZGPIB_BusWaitForData(HP4192A,Answer,Timeout);??? // Get data

??EZGPIB_ConvertRemove('NZFN', Answer);?????? ??????????????? // delete NZFN

? EZGPIB_ConvertRemove('NTDN', Answer);?????? ??????????????? // delete NTDN

? EZGPIB_ConvertRemove('K', Answer);??????????????? ??????????????? ??????????????? // delete K

? EZGPIB_FileAddToBuffer(Answer);??????????????????? ?????????????????? // add to buffer

? EZGPIB_ScreenWriteLn(Answer);????????????????????? ??????????????????? // Display on screen

? EZGPIB_TimeWaitForMultipleOf(1);?????????????????? ?????????????????? // Delay 1 seconds

? EZGPIB_BusWriteData(HP4192A,'W2');???????????????? ?????????????? // Step up

end;

? EZGPIB_FileWrite(Filename);??????????????????????? ?????????????????????????? // write to file

end.


On Tue, Feb 5, 2019 at 12:20 AM Harvey White <madyn@...> wrote:
On Mon, 04 Feb 2019 15:36:34 -0800, you wrote:

What happens if you run the strip program, then copy the result string
from the beginning up to the comma?? In pascal, you can find the
location of the comma, and delete all the characters before it.? This
ought to give you the second part of the string, which you can strip
off the beginning.

This uses standard pascal functions.

Of course, if you could read one thing at a time (NZFN, then NTDN,
etc), you could convert each item individually.

Another option would be to search the string for NZFN, then replace it
by spaces, ditto for NTDN, etc.


maybe easier to copy out to substrings.

C has a token function that automatically parses things like this, and
pascal doesn't (that I know of).

You may want to look for parsing programs, just for fun

depends on how involved you want to get with the programming.

Harvey



>I am looking for help from someone experienced with EZGPIB, or possibly Pascal if any of this makes sense. I wrote a program in EZGPIB that is working well to get data from my HP4192A.?Each read of data is in the following format which is added to a buffer and, at the end of the program, stored in a file. I think the reads are tab separated but that is not the problem.?NZFN+017.78E+03,NTDN-005.38E+00,K+01.000000?To remove unwanted characters (NZFN = |Z|, NTDN = Phase, K = kHz) I used?Answer:=EZGPIB_ConvertStripToNumber(Answer);?// an EZGPIB function. Answer is a string variable?This only strips the first characters so I get?+017.78E+03,NTDN-005.38E+00,K+01.000000?I think the comma terminates the string as far as the function is concerned. I don¡¯t know how to make the function remove all unwanted characters. Does anyone know? I tried a different function three times to remove all characters. It works however I should be able to use it once with the proper formatting to do the job but
>I don¡¯t know how. Any suggestions??EZGPIB_ConvertRemove('NZFN', Answer); EZGPIB_ConvertRemove('NTDN', Answer); EZGPIB_ConvertRemove('K', Answer);?The result is what I am after: +017.78E+03,-005.38E+00,+01.000000
>
>




Join [email protected] to automatically receive all group messages.