From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Some serial drivers for lab stuff

Hi,

Yes, it works better with CrLf  Smiley Surprised

I'm just a rookie and i don't know what is the more adapted method catching serial response :

depending of results or command the phmeter can send  one or more line each terminated with CrLf

I obtain a result with the folowing method, but is it the best way  ?

my longest message is 400 bytes so i let 500ms to catch complete message (1/9600 *8*400 -> 333ms)

1) i use 500ms whatever the real length and without CrLf ligne detection

2) i have to use 2 pass to obtain the message !

3) is the 20ms wait really usefull ?

Best regards

Sébastien
CLAD / Labview 2011, Win Xp
------------------------------------------------------
Mission d'une semaine- à plusieurs mois laissez moi un MP...
RP et Midi-pyrénées .Km+++ si possibilité de télétravail

Kudos always accepted / Les petits clicks jaunes sont toujours appréciés
Don't forget to valid a good answer / pensez à valider une réponse correcte
0 Kudos
Message 21 of 31
(2,532 Views)
i forgot...

the same with front panel...
CLAD / Labview 2011, Win Xp
------------------------------------------------------
Mission d'une semaine- à plusieurs mois laissez moi un MP...
RP et Midi-pyrénées .Km+++ si possibilité de télétravail

Kudos always accepted / Les petits clicks jaunes sont toujours appréciés
Don't forget to valid a good answer / pensez à valider une réponse correcte
0 Kudos
Message 22 of 31
(2,516 Views)
Sébastien,

I can't really answer your questions with a deep understanding of what is going on, but I know for talking to my meter, I needed to add lots of waiting periods for it to work reliably.

For instance, after I initialize the port, I wait 100 msec... without it, the meter often misses the next command.

After I issue the command for the meter to read out, I wait 900 msec and often find that it gives me a slightly variable number of bytes, depending on whether it was asleap or not when the computer queried it... I put in a routine to evaluate the output +/- 10 bytes and to re-read it if not.

When I send other commands, such as to change which pH channel I'm reading, I actually have to wait 2000 msec before it has fully changed... and then the buffer still has the reading from the previous probe in it, so I read and discard that reading and wait some more.

I'm fortunate that I have time to wait; I'm going to be querying the meters about every 10 minutes, so I don't really care if it takes a while to get through the

I've posted my code... If anyone else looking at it sees something they'd improve, I'd welcome the suggestion. I don't claim that this is the best way to do it, but I found that if I shortened any of the wait periods, it got unreliable. The meter is pretty slow to respond to commands.

Good luck,
mike
0 Kudos
Message 23 of 31
(2,506 Views)
hi, thank you for the vi, it's not easy to make a hardaware comparison if device
is not exactly the same ( at least same brand) but the global schema overall looks like  !

I don't have retrospect enough to juge your vi but  why don't you use the "bytes at port" out as an input for read block ?

Could you in 2-3 words tell me what the for loop do on data

Best regards

Sébastien

PS : if that can distract you( all of you), do not hesitate to correct my "english sentences", that will not upset me, on the contrary, that will allows me to make less error thereafter
CLAD / Labview 2011, Win Xp
------------------------------------------------------
Mission d'une semaine- à plusieurs mois laissez moi un MP...
RP et Midi-pyrénées .Km+++ si possibilité de télétravail

Kudos always accepted / Les petits clicks jaunes sont toujours appréciés
Don't forget to valid a good answer / pensez à valider une réponse correcte
0 Kudos
Message 24 of 31
(2,483 Views)

Hi,

 

Thank you for your driver.

I could use it to read temperature from temperature controller.

I also modified it to set the temperature setpoint and try to control the temperature, but

failed.

Attached please find my modified code.

I will appreciate it If you could figure it out for me.

 

Thank you,

 

Guoguang

Qian

 

 

 

0 Kudos
Message 25 of 31
(1,961 Views)

Appending to a six-year-old thread is often not the best way  to get good responses.  

 

It also helps if you provide specific information about what failed.  Did the computer go up in smoke? Did the setpoint change but to an incorrect value? what errors, if any, occurred? The most recent VI posted in this thread was for a pH meter, not a temperature controller. What is the manufacturer and model of your temperature controller?

 

What is the communications protocol? When you write to the device you send messages starting with STX and ending with carriage return. One note states that the return message starts with STX. Does it terminate with carriage return? If so, enable termination characters, set x0D as the termination character and remove Bytes at Port and the Wait.  Can the device accept successive commands as fast as they can be sent or does it need time to rspond to one command before the next is sent?

 

Lynn

Message 26 of 31
(1,948 Views)

After looking at your VI, I noticed mention of DigiSense 89000. I found the manual on the ColePalmer website.

 

The communication protocol is fairly well documented. The device sends three kinds of messages: one byte <ACK> or <NAK> and multi-byte <STX> ... <CR><LF>. Your VI does not implement the protocol very well. The device is also set up for XON/XOFF handshaking although it is probably not necessary to use it.

 

The commands you send may be part of the problem as well: Set Mode (to value entered by user), Set to Cool, Set to Autotune, Set Power up mode, Set Setpoint (to value entered by user). Inside loop: Request current Process Variable value, Read, repeat. After the loop, eXit remote mode.  Problems: It will not control or return data while in autotune Control Run status. You may need to autotune when you first set up the system but the run status should probably be 1 or 2. Also, when reading the PV, values may include OPEN, OVER, or UNDER. Your VI does not check for these. 

 

I would set it up to read the <ACK>/<NAK> response after each command before writing the next command.  Make sure the correct commands are being sent. Use an enum for the Mode input from the user so the user cannot enter invalid modes. In the loop I would read one character after the write and test it for <ACK>,<NAK>, or <STX>. When the first character is <STX> then read the rest of the message with <LF> as termination character. Check the message for OPEN, OVER, or UNDER before scanning the numeric part.

 

Lynn

Message 27 of 31
(1,965 Views)

Hi Lynn,

 

Thank you so much for your reply.

Sorry for not writing the problem clearly.

Let me rewrite it below:

The purpose of the code is to set setpoint of temperature controller then read

the temperature in a while loop. When temperature reading reachs the setpoint 

within 0.5 C while loop stops and then code exit. 

 

When I run the code It could set the setpoint and read temperature. But the heater

didn't turn on even temperature reading is below the setpoint. My modification is based

on my understanding of the manual. I probably missed or  misunderstood something in

the manual. it will be great If you could give some clue about how to turn on the heater.

 

My temperature is Model 89000-10.

 

Thanks again,

 

Guoguang

0 Kudos
Message 28 of 31
(1,953 Views)

Guoguang,

 

I do not have the time to study the entire manual to see what needs to be done. In general the best way to start something like this is to operate the temperature controller manually. Write down every button you press or every setting you change while running it by hand. Then write the code to do the same things programmatically. 

 

Some instruments may have complex settings which interact in ways that might seem strange to someone not accustomed to the terminology used by the manuals or the details of how the intrument works.

 

As I pointed out in my previous post I wonder about the autotune and cooling settings.

 

Lynn

0 Kudos
Message 29 of 31
(1,939 Views)

Lynn,

 

Thank you for your help.

I will try the way you mentioned this week. I will let you know the result.

 

Thanks,

 

Guoguang

 

 

0 Kudos
Message 30 of 31
(1,930 Views)