LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help With Control Scheme

Hey, so i tried putting in a wait, and that didnt make a difference... it's running off of a custom made program called GenScheme. It's written in ironpython. We're looking on switching over to labview to replace genscheme. Im on the engineering side of this so i dont know a whole lot about the programing... im going to try to attatch the portion of code related to the atomlab...

0 Kudos
Message 11 of 22
(705 Views)
import System

import struct

from SerialType import SerialType

class AtomLab300(SerialType):
	"""The Serial Dose Calibrator type that contains methods for communicating with Atomlab 300 dose calibrators."""
	def __init__(self, vss):
		SerialType.__init__(self)
		self.name = "AtomLab300"
		self.vss = vss
		self.activity = 0.0
		self.isotope = ""
		self.unit = "Ci"
		self.reader = System.Timers.Timer(1000)
		self.reader.Elapsed += self.readerTick

	def get(self, item):
		if item == "activity": #Return the last activity read.
			return self.activity
		if item == "isotope": #Return the last isotope read.
			return self.isotope
		if item == "unit": #Return the last unit read.
			return self.unit

	def open(self):
		self.vss.SelectedSubsystem.serialdevice.configurePort(baudrate=4800, newline='', recvdelay=50)
		self.updateReadStatus("REQ", 0.0, True) #Requesting data...
		self.reader.Start()

	def readerTick(self, sender, event):
		response = self.vss.SelectedSubsystem.serialdevice.sendrecvline("\x31")
		if response == "":
			self.updateReadStatus("ERR", 0.0) #AtomLab300 is not responding.
			return None
		if not response.startswith("~"):
			self.updateReadStatus("ERR", 0.0) #Incomplete record received.
			return None
		fields = response.split()
		if len(fields) < 4:
			return None
		isotope = fields[1]
		dialvalue = fields[2]
		activity = fields[3]
		unit = fields[4]
		self.isotope = isotope
		self.activity = activity
		self.unit = unit.strip()
		self.updateReadStatus("OK", 100.0)

	def close(self):
		self.reader.Stop()

 

0 Kudos
Message 12 of 22
(703 Views)

Like I said, our ex-programmer wrote this code, so I'm not overly familiar with it, but if there is other code that might be helpful I can look!! This was just what was listed under serial dose calibrator... And thanks for everyones help!!

0 Kudos
Message 13 of 22
(702 Views)

Drill down into "updateReadStatus" to see what characters are sent that trigger the device to return data.

0 Kudos
Message 14 of 22
(696 Views)

ok so i ran it with breakpoints and it looks like it returns 4 values? one of which is activity (the value i need), is there some way to access all of them individually?

Untitled1.png

 

 

Untitled2.png

 

and just below the code in this last picture all of the fields are broken up individually to display them in-program.

0 Kudos
Message 15 of 22
(692 Views)

Hi Sundown,

So one thing that I would suggest doing is making sure that you are reading the correct number of bites in your VISA program.  You could be waiting for bites that will never come and therefore you time out.  One way to do that is to use a VISA Bites at Port Property Node.  This tells you how many bites are sitting at the write port and you can wire it to the read.  Please see below for example code. Also, have you tried to communicate with this device in Measurement and Automation Explorer?

 

Good luck,

Kira

Applications Engineer

National Instruments

Message 16 of 22
(658 Views)

It looks like call-and-respond. Send a few specific Bytes to the instrument to get it to send interesting data. To see what commands to send, either "sniff" the com port (such as with PortMon) while the Python app is running, or find where the com port writes are happening in the Python source.

Message 17 of 22
(654 Views)

Well, sort of good news... I added in the part Kira suggested and for the first time got a response in the read buffer, as you can see in the top... However, it returned gibberish!! Same affect with the IDN command. So would this imply that I need different commands like Todd said? I tried finding other commands for the Atomlab but havent had any luck so far... And thanks for everyones help by the way!!

Untitled.png

0 Kudos
Message 18 of 22
(630 Views)

Looks like the baud rate setting is wrong.

0 Kudos
Message 19 of 22
(625 Views)

yep just caught this error after i posted : p

changed to 4800 and finnally "good" responses... it now flashes all 4 elements ( the reading, units, etc.) very quickly... is there an easy way to break up these four elements?

But other than that I think I can make the rest of it work, so thanks everyone!!!

0 Kudos
Message 20 of 22
(622 Views)