Created
July 6, 2019 06:14
-
-
Save Spirit532/29513731ed9e9b71df8ead4858c31006 to your computer and use it in GitHub Desktop.
Pfeiffer protocol - reading a PPT-100 vacuum gauge through a USB->RS485 adapter and python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import serial | |
ser = serial.Serial('COM11', 9600, timeout=0.5) #open the rs485 adapter | |
while True: | |
ser.write(('0010074002=?106\r').encode()) #request pressure from PPT-100, pfeiffer protocol | |
result = ser.readline() #read pressure back, use timeout | |
#return value is this: | |
#adr ac prn ty value chk r | |
#001 10 740 06 100023 025 \r | |
#100023 is 1.000[*10^]3, with an offset of 20, e.g. 23 - 20 = 3, or 11-20 = -9 | |
print(result[10:11].decode("ascii") +"."+ result[11:14].decode("ascii") + "x10^" + str(int(result[14:16].decode("ascii"))-20) + "mbar") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment