取消
显示结果 
搜索替代 
您的意思是: 

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 项奖励
11 条消息(共 22 条)
1,348 次查看
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 项奖励
12 条消息(共 22 条)
1,346 次查看

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 项奖励
13 条消息(共 22 条)
1,345 次查看

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

0 项奖励
14 条消息(共 22 条)
1,339 次查看

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 项奖励
15 条消息(共 22 条)
1,335 次查看

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

16 条消息(共 22 条)
1,301 次查看

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.

17 条消息(共 22 条)
1,297 次查看

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 项奖励
18 条消息(共 22 条)
1,273 次查看

Looks like the baud rate setting is wrong.

0 项奖励
19 条消息(共 22 条)
1,268 次查看

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 项奖励
20 条消息(共 22 条)
1,265 次查看