
60
Appendix C. Programming
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
f r o m m o g d e v i c e i m p o r t M O G D e v i c e
i m p o r t sys
i m p o r t m a t p l o t l i b . p y p l o t as plt
# c o n n e c t to the d e v i c e
dev = M O G D e v i c e ( ’ 1 0 . 1 . 1 . 3 2 ’ )
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# D e m o n s t r a t e s i m p l e c o m m a n d
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
p r i n t ( ’ D e v i c e i n f o : ’ , dev . ask ( ’ i n f o ’ ) )
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# F i n d o p t i m u m e x p o s u r e t i m e
# cam , atime , < max > f i n d s o p t i m u m but w i t h
# m a x i m u m of < max > m i l l i s e c o n d s
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
s h u t t e r S t r = dev . ask ( ’ cam , atime , 4 0 0 \ n ’ )
s h u t t e r T i m e = f l o a t ( s h u t t e r S t r )
p r i n t ( ’ E x p o s u r e t i m e : %.2 fms ’ % s h u t t e r T i m e )
if (400 - s h u t t e r T i m e < 1) :
p r i n t ( ’ I n s u f f i c i e n t i n p u t p o w e r ’ )
sys . e x i t ()
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# A c q u i r e s p e c t r u m
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
b u f l e n = 0
c o l s = 2 5 9 2
# s e n s o r w i d t h
b u f s i z e = c o l s *2
# two b y t e s per p i x e l
m a x y = 2 * 4 0 9 6
# 12 - bit sensor , two r o w s a d d e d
b i n d a t a = ’ ’
dev . s e n d ( ’ spe \ n ’ )
# d e a l w it h f r a g m e n t e d tcp / ip p a c k e t s
w h i l e buflen < b u f s i z e :
c h u n k = dev . r e c v ( bufsize - b u f l e n )
c h l e n = len ( c h u n k )
b i n d a t a += c h u n k
b u f l e n += c h l e n
i m a g e = []
Summary of Contents for MWM
Page 1: ...MWM wavemeter Revision 3 19 mogwave 1 4 15 Firmware 0 6 9 ...
Page 4: ...ii ...
Page 7: ...Contents v G Ugrading firmware 83 References 84 ...
Page 8: ...vi Contents ...
Page 54: ...46 Chapter 6 Calibration ...
Page 58: ...50 Appendix A Specifications ...
Page 66: ...58 Appendix B Communications ...
Page 70: ...62 Appendix C Programming ...
Page 86: ...78 Appendix E mogwave configuration ...
Page 92: ......
Page 94: ...86 ...
Page 95: ......