Files
PBSwissMX/logbook.md

490 lines
19 KiB
Markdown

Text that was in readme and not used any more is stored here
============================================================
*** 14.12.2016 ***
==================
Parker stage
============
Using IDE
---------
1 detect current sensor direction
Motor[1].PhaseOffset 683
Motor[1].PwmSf 2154
2 current bias
Motor[1].IaBias=0
Motor[1].IbBias=0
3 Voltage six step
Motor[1].PhaseOffset -683
Motor[1].PwmSf -2154
Motor[1].PhasePosSf=2048/(1*256*213333.3333)
4 Tune Current Loop (Mag=200, dur=50)
Motor[1].IiGain 10.5
Motor[1].IpfGain=0
Motor[1].IpbGain=14.7
5 Current six step
Motor[1].PhasePosSf=2048/(1*1*61440000.)
6 Phase ref search
Motor[1].PhaseFindingDac=160.95
Motor[1].PhaseFindingTime=50
Open Loop
---------
20mm = 1003994 enc_step
20mm = 1'000'000 enc_step -> 20nm/enc step
1 pole= 600'000 enc_step -> 12mm
>>>>>>>>>> DONT FORGET <<<<<<<<<<<
$$$***
!common()
>>> open loop with encoder counts <<<
!encoder_sim(enc=1,tbl=1,mot=1)
!encoder_inc(enc=1,tbl=9,mot=9,encctrl=7,posSf=1./1)
!motor(mot=1,dirCur=400,contCur=500,peakCur=2400,timeAtPeak=1,IiGain=1,IpfGain=0,IpbGain=2,JogSpeed=1.,numPhase=3,invDir=True)
#1j/
#1,9hmz
#1j:2048 -> moves one pole= 650'000 enc_step =13mm (Electrical Pitch in MX80 doc)
512= 90deg -> check phase *
* o x * o x
* * o o x x * * o o x x
* o* xo x * o* xo x
* o * x o x * o * x o x
* o x * o x * o x * o x
*------o------x-----*------o------x-----*------o------x-----*------o------x-----*------o------x-----*------o------x
* o x * o x * o x * o x * o x * o x
* o * x o x * o * x o x * o * x o x
* o* xo x * o* xo x * o* xo x
* * o o x x * * o o x x * * o o x x
* o x * o x * o x
0 512 1024 1536 2048
>>> scaling encoder etc to um <<<
!encoder_sim(enc=1,tbl=1,mot=1,posSf=12000./2048)
!encoder_inc(enc=1,tbl=9,mot=9,encctrl=7,posSf=12000./600000)
!motor(mot=1,dirCur=400,contCur=500,peakCur=2400,timeAtPeak=1,IiGain=1,IpfGain=0,IpbGain=2,JogSpeed=1.*12000./2048,numPhase=3,invDir=True)
JogSpeed=1.*12000./2048 6um/ms =6mm/s
>>> close the loop with inc-encoder <<<
servoSf : motorusteps/userUnits
!encoder_sim(enc=1,tbl=9,mot=9,posSf=12000./2048)
!encoder_inc(enc=1,tbl=1,mot=1,encctrl=7,posSf=12000./600000)
!motor(mot=1,dirCur=400,contCur=500,peakCur=2400,timeAtPeak=1,IiGain=1,IpfGain=0,IpbGain=2,JogSpeed=6.,numPhase=3,invDir=True,servoSf=2048/12000.)
>>> close the loop with inc-encoder removing direct current<<<
$$$***
!common()
!encoder_sim(enc=1,tbl=9,mot=9,posSf=12000./2048)
!encoder_inc(enc=1,tbl=1,mot=1,encctrl=7,posSf=12000./600000)
!motor(mot=1,dirCur=0,contCur=500,peakCur=800,timeAtPeak=1,IiGain=1,IpfGain=0,IpbGain=2,JogSpeed=6.,numPhase=3,invDir=True,servoSf=2048/12000.)
Motors are not moving, because no current will be set due to some wrong parameters.
But the servoloop is running and gives output:
ServoOut set value from 0.5099 to -0.5099 (= MaxPosErr*Kp) when moving at different position
Motor[1].Servo.MaxPosErr=1000.0169
Motor[1].Servo.Kp=0.000512
1000.0169*0.000512=0.5120086528
Motor[1].Servo.Kp=0.0007
Motor[1].Servo.MaxPosErr=1000.0169
1000.0169*0.0007=0.70001183
Now some elements have to be reconfigured:
SlipGain,PwmSf,PhaseMode,PhaseCtrl,PhasePosSf
Motor[1].pPhaseEnc = PowerBrick[0].Chan[0].PhaseCapt.a //is default
use configuration open loop with encoder counts
#1j/
Read PowerBrick[0].Chan[0].PhaseCapt 130559
move one pole (13mm)
Read PowerBrick[0].Chan[0].PhaseCapt 166599808
difference = 166599808-130559= 166469249
166469249/256 = 650270 =650000incr = 13mm
1 commutation cycle=163537664 PhaseCapt = 2048 com_cycl_units
PhasePosSf= 2048./166469249 = 1.2303e-05 or precise: 2048/(256*650000)=1.23077e-05
servoSf : motorusteps/userUnits
servoSf=2048/12000.,PhaseCtrl=4,SlipGain=0,PhasePosSf=1.23077e-05
*******************************
****** WORKS !!!!!!!!!!!! *****
** But positioning has very bad performance **
*******************************
// controlling speed/velocity on iqCmd and constant current(=torque) on idCmd
//precission +-1 step in steady state
$$$***
!common()
!encoder_inc(enc=1,tbl=1,mot=1,encctrl=7,posSf=12000./600000)
!motor(mot=1,dirCur=300,contCur=800,peakCur=2400,timeAtPeak=1,IiGain=1,IpfGain=0,IpbGain=2,JogSpeed=6.,numPhase=3,invDir=True,servoSf=2048/12000.)
// controlling torque(=current) on iqCmd and idCmd=0
//precission +-100 and more step in steady state
$$$***
!common()
!encoder_inc(enc=1,tbl=1,mot=1,encctrl=7,posSf=12000./600000)
!motor(mot=1,dirCur=0,contCur=800,peakCur=2400,timeAtPeak=1,IiGain=1,IpfGain=0,IpbGain=2,JogSpeed=6.,numPhase=3,invDir=True,servoSf=2048/12000.,PhaseCtrl=4,SlipGain=0,PhasePosSf=1.23077e-05,PhaseMode=0,PhaseFindingDac=200,PhaseFindingTime=22.586512)
#1out10
!!! HOLD BY HAND TO LIMIT THE SPEED !!!
Motor[1].Servo.Kp=1
Motor[1].InPosBand=0
Motor[1].Servo.BreakPosErr=0
#1j/
#1j:1000
*******************************
-> Tadejs input: use simulated encoder for the phasing
Motor[1].Servo.BreakPosErr=0
Motor[3].Servo.Kp=2000
///Motor[3].Servo.BreakPosErr=0
//Motor[3].Servo.Kp=2000
//#3out5
Testing IDE with QBL test motor
===============================
>>> close the loop with inc-encoder removing direct current<<<
-> the current/speed must be set with that PWM-scale factor
Motor idx 1 3
Motor[x].AdvGain 0.020479999 0
Motor[x].PhasePosSf 0 0.0160000000000000003
Motor[x].PhaseCtrl 6 4
Motor[x].PhaseMode 1 0
Motor[x].PwmSf -15134.891 4309
Motor[x].SlipGain 0.25 0
Motor[x].PhaseFindingDac 0 95.976563
Motor[x].PhaseFindingTime 0 22.586512
>>> origin setup by ide+ tweaks <<<
!encoder_inc(enc=3,tbl=3,mot=3,encctrl=7,posSf=1./2000)
!motor_servo(mot=3,ctrl='ServoCtrl',Kp=4.0424199*2000, Kvfb=160.43646*2000,Kvff=160.43646*2000,Kaff=3184.5818*2000)
!motor(mot=3,numPhase=3,servo=None, homing=None,dirCur=0,contCur=1790,peakCur=5400,timeAtPeak=1,IiGain=1.0628819,IpfGain=0,IpbGain=6.5684085,AdvGain=0,FatalFeLimit=2000,WarnFeLimit=1000,InPosBand=0,PhasePosSf=0.016,PhaseCtrl=4,PhaseMode=0,PwmSf=4309,SlipGain=0,PhaseFindingDac=95.976563,PhaseFindingTime=22.586512)
AdvGain
PhasePosSf 0 does not work at all -> must be calculated correctly as below
PhaseCtrl 6 not working. must be 4 for phase feedback and 6 for direct microstepping
PhaseMode 0,1 both are working, should be 0 for 3 phase
PwmSf 0 2000 4309 -> the higher, the more torque on error
SlipGain 0.25 squeezing
PhaseFindingDac 0 no change
PhaseFindingTime 0 no change
$$$***
!common()
!encoder_inc(enc=3,tbl=3,mot=3,encctrl=7,posSf=1./2000)
!motor_servo(mot=3,ctrl='ServoCtrl',Kp=4.0424199*2000, Kvfb=160.43646*2000,Kvff=160.43646*2000,Kaff=3184.5818*2000)
!motor(mot=3,numPhase=3,servo=None, homing=None,dirCur=0,contCur=1790,peakCur=5400,timeAtPeak=1,IiGain=1.0628819,IpfGain=0,IpbGain=6.5684085,AdvGain=0,FatalFeLimit=2000,WarnFeLimit=1000,InPosBand=0,PhasePosSf=0.016,PhaseCtrl=6,PhaseMode=1,PwmSf=1000,SlipGain=0,PhaseFindingDac=0,PhaseFindingTime=0)
!sh sleep 1
#3j/
!sh sleep 10
#3j:100
#3out10 sets directly the Motor[3].ServoOut value , sets to 10% of Motor[x].MaxDac
Motor[3].MaxDac=4526.9282
Out ServoOut iqCmd IqVolts
#3out100 -> 4526.9 set to 100 %of Motor[x].MaxDac
#3out50 -> 2263.46411 2263.4641
#3out10 -> 452.692822 452.69281
iqMeas=iqCmd if motor is blocked, when motor moves, iqCmd stays and iqMeas drops
PwmSf IqCmd iqMeas(when blocked)
Motor[3].PwmSf;Motor[3].IqCmd;Motor[3].IqMeas;Motor[3].IqVolts
PwmSf=500 IqCmd=2263.4641 IqMeas=232.44925 IqVolts=34406.398
PwmSf=1000 IqCmd=2263.4641 IqMeas=779.05316 IqVolts=34406.398
PwmSf=2000 IqCmd=2263.4641 IqMeas=1944.9929 IqVolts=34406.398
PwmSf=3000 IqCmd=2263.4641 IqMeas=2234.2734 IqVolts=34406.398
Motor[x].PhasePosSf scale factor to convert encoder position to phase position
Motor[3].pPhaseEnc=PowerBrick[0].Chan[2].PhaseCapt.a
Motor[3].PhaseEncLeftShift=0
Motor[3].PhaseEncRightShift=0
1 rev=2000*256 enc_steps (PowerBrick[0].Chan[2].PhaseCapt)
4 Pole magnet, 2000 enc_steps/rev
encoder configured to have 1 enc_step per revolution
PhasePosSf=0.016=1/62.5=32/2000= (4*2048)/(256*2000) = (numPoles*const)/(256*2000)
const=Power PMAC divides a commutation cycle into 2048 parts
Motor[3].PhasePos position of the phase: 0..2048 this does not change if the motor is blocked
>>>>>>find PhasePosSf <<<<<<<<<<<
$$$***
!common()
!encoder_sim(enc=3,tbl=3,mot=3)
!encoder_inc(enc=3,tbl=11,mot=11,encctrl=7,posSf=1./2000)
!motor(mot=3,numPhase=3, dirCur=500,contCur=1790,peakCur=2400,timeAtPeak=1,IiGain=1.0628819,IpfGain=0,IpbGain=6.5684085,AdvGain=0,FatalFeLimit=2000,WarnFeLimit=1000,InPosBand=0,PhasePosSf=0.0,PhaseCtrl=4,PhaseMode=0,SlipGain=0)
Do manually one revolution
feeling 4 pole changes -> 8 poles (locks on N-S S-N positions, moves on N-N S-S position)
Motor[3].pPhaseEnc -> Motor[3].pPhaseEnc=PowerBrick[0].Chan[2].PhaseCapt.a
PowerBrick[0].Chan[2].PhaseCapt after one revolution
1535488-1022464=513024=512000
Phase_step = change pole from N->S->N
1 Phase_step = 2048 Phase_uStep
512000 PhaseEnc_step == 4 pole changes = 4*2048 Phase_uStep
PhasePosSf=Phase_uStep/PhaseEnc_step=4*2048/512000==0.016
!encoder_inc(enc=3,tbl=3,mot=3,encctrl=7,posSf=1./2000)
!motor(mot=3,numPhase=3, dirCur=0,contCur=1790,peakCur=2400,timeAtPeak=1,IiGain=1.0628819,IpfGain=0,IpbGain=6.5684085,AdvGain=0,FatalFeLimit=2000,WarnFeLimit=1000,InPosBand=0,servoSf=2000./1,PhasePosSf=0.016,PhaseCtrl=4,PhaseMode=0,PwmSf=4309,SlipGain=0,PhaseFindingDac=95.976563,PhaseFindingTime=22.586512)
Motor[3].Servo.BreakPosErr=0
Motor[3].Servo.Kp=2000
#3out5
#3j/
PowerBrick[0].AdcAmpCtrl = $f00cfe00 $f00cfe00
PowerBrick[0].Chan[0].InCtrl = $47 $47
PowerBrick[0].Chan[0].OutCtrl = $f000001 $f000101
PowerBrick[1].AdcAmpCtrl = $f00cfe00 $f00cfe00
Motor[1].Servo.Kp = 4.0424199 4.0424199
Motor[1].Servo.Kvifb = 0 0
Motor[1].Servo.Kviff = 0 0
Motor[1].Servo.Kvfb = 160.43646 40.951927
Motor[1].Servo.Kvff = 160.43646 40.951927
Motor[1].Servo.Kafb = 0 0
Motor[1].Servo.Kaff = 3184.5818 207.48897
Motor[1].Servo.Ki = 2.6301687e-4 0.0010304153
Motor[1].Servo.Kfff = 0 0
Motor[1].PhasePosSf = 0.0160000000000000003 1.59999999999999993e-5
Motor[1].IiGain = 1.0628819 0.2278125
Motor[1].IpbGain = 6.5684085 0.0099999998
Motor[1].MotorTa = -10 -10
Motor[1].MotorTs = -50 -50
Motor[1].I2tSet = 1499.7477 418.92395
Motor[1].I2tTrip = 18220758 2632459
Motor[1].JogOffset = 0 0
Motor[1].AdcMask = $fffc0000 $fffc0000
Motor[1].PhaseOffset = 683 -683
Motor[1].Stime = 0 0
Motor[1].PwmSf = 4309 -2154
Motor[1].MaxDac = 4524.3784 1675.6958
Motor[1].PhaseFindingDac = 95.976563 0
Motor[1].PhaseFindingTime = 22.586512 1
Motor[1].TraceSize = 0 0
Motor[1].Control[0] = $14000100 $14000100
Motor[1].Control[1] = $0 $0
Node15[0].MasterNum = 255 255
Node15[1].MasterNum = 255 255
Node15[2].MasterNum = 255 255
Node15[3].MasterNum = 255 255
IDE Setup -> changed variables
------------------------------
*Command/Feedback(3)
Motor[3].pAbsPhasePos=0 // Encoder //12/9/2016 :8:51 AM - 129.129.144.138
Motor[3].AbsPhasePosFormat=0 // Encoder //12/9/2016 :8:51 AM - 129.129.144.138
Motor[3].AbsPhasePosSf=0 // Encoder //12/9/2016 :8:51 AM - 129.129.144.138
Motor[3].AbsPhasePosOffset=0 // Encoder //12/9/2016 :8:51 AM - 129.129.144.138
Motor[3].PhaseFindingTime=1 // Encoder //12/9/2016 :8:51 AM - 129.129.144.138
Motor[3].PhaseFindingDac=0 // Encoder //12/9/2016 :8:51 AM - 129.129.144.138
*Hardware Interface
Motor[3].pLimits=PowerBrick[0].Chan[2].Status.a // Hardware Interface //12/9/2016 :8:53 AM - 129.129.144.138
Motor[3].pEnc= EncTable[3].a // Hardware Interface //12/9/2016 :8:53 AM - 129.129.144.138
Motor[3].pEnc2= EncTable[3].a // Hardware Interface //12/9/2016 :8:53 AM - 129.129.144.138
Motor[3].EncType= 5 // Hardware Interface //12/9/2016 :8:53 AM - 129.129.144.138
Motor[3].pDac=PowerBrick[0].Chan[2].Pwm[0].a // Hardware Interface //12/9/2016 :8:53 AM - 129.129.144.138
Motor[3].pAdc=PowerBrick[0].Chan[2].AdcAmp[0].a // Hardware Interface //12/9/2016 :8:53 AM - 129.129.144.138
Motor[3].pAmpEnable=PowerBrick[0].Chan[2].OutCtrl.a // Hardware Interface //12/9/2016 :8:53 AM - 129.129.144.138
Motor[3].ServoCtrl = 1 // Hardware Interface //12/9/2016 :8:53 AM - 129.129.144.138
Motor[3].PhaseCtrl = 4 // Hardware Interface //12/9/2016 :8:53 AM - 129.129.144.138
Gate3[0].Chan[2].PackIndata = 0 // Hardware Interface //12/9/2016 :8:53 AM - 129.129.144.138
Gate3[0].Chan[2].PackOutdata = 0 // Hardware Interface //12/9/2016 :8:53 AM - 129.129.144.138
Motor[3].PhaseMode = 0 // Hardware Interface //12/9/2016 :8:53 AM - 129.129.144.138
Motor[3].pPhaseEnc=PowerBrick[0].Chan[2].PhaseCapt.a // Hardware Interface //12/9/2016 :8:53 AM - 129.129.144.138
BrickLV.Chan[2].TwoPhaseMode=0 // Hardware Interface //12/9/2016 :8:53 AM - 129.129.144.138
Motor[3].PhaseSplineCtrl = 0 // Hardware Interface //12/9/2016 :8:53 AM - 129.129.144.138
Motor[3].pSineTable = Sys.SineTable[0].a // Hardware Interface //12/9/2016 :8:53 AM - 129.129.144.138
Motor[3].pVoltSineTable = Sys.SineTable[0].a // Hardware Interface //12/9/2016 :8:53 AM - 129.129.144.138
Motor[3].PwmDbComp = 0 // Hardware Interface //12/9/2016 :8:53 AM - 129.129.144.138
Motor[3].PwmDbI = 0 // Hardware Interface //12/9/2016 :8:53 AM - 129.129.144.138
PowerBrick[0].Chan[2].OutputMode = 0 // Hardware Interface //12/9/2016 :8:53 AM - 129.129.144.138
Motor[3].PwmSf =7618.5 // Hardware Interface //12/9/2016 :8:53 AM - 129.129.144.138
Motor[3].AmpEnableBit = 8 // Hardware Interface //12/9/2016 :8:53 AM - 129.129.144.138
Motor[3].AmpFaultBit = 7 // Hardware Interface //12/9/2016 :8:53 AM - 129.129.144.138
Motor[3].AmpFaultLevel = 1 // Hardware Interface //12/9/2016 :8:53 AM - 129.129.144.138
Motor[3].pAmpFault=PowerBrick[0].Chan[2].Status.a // Hardware Interface //12/9/2016 :8:53 AM - 129.129.144.138
Motor[3].LimitBits = 9 // Hardware Interface //12/9/2016 :8:53 AM - 129.129.144.138
Motor[3].DacShift=0 // Hardware Interface //12/9/2016 :8:53 AM - 129.129.144.138
Motor[3].AdcMask = $FFFC0000 // Hardware Interface //12/9/2016 :8:53 AM - 129.129.144.138
Motor[3].ctrl=Sys.servoctrl // Hardware Interface //12/9/2016 :8:53 AM - 129.129.144.138
Motor[3].DtOverRotorTc = 0 // Hardware Interface //12/9/2016 0:8:53 AM - 129.129.144.138
Motor[3].IxCoupleGain = 0 // Hardware Interface //12/9/2016 :8:53 AM - 129.129.144.138
Motor[3].SlipGain = 0 // Hardware Interface //12/9/2016 :8:53 AM - 129.129.144.138
Motor[3].AdvGain = 0 // Hardware Interface //12/9/2016 :8:53 AM - 129.129.144.138
Motor[3].Stime = 0 // Hardware Interface //12/9/2016 :8:53 AM - 129.129.144.138
Motor[3].PhaseOffset =-683 // Hardware Interface //12/9/2016 :8:53 AM - 129.129.144.138
BrickLV.Reset = 1 // Hardware Interface //12/9/2016 :8:53 AM - 129.129.144.138
*** 16.1.2017 ***
==================
Parker stage current step response
----------------------------------
Motor[2].IiGain=0
Motor[2].IpfGain=1
Motor[2].IpbGain=-1
Current step: Magnitude 4000 bits
Phasing 0
Dwell 10 ms
Motor 2 Phase pos at hard limit (towards kable)
> Motor[2].PhasePos;#2$
Motor[2].PhasePos=1317.26495427904138
Motor[2].PhasePos=1286.11002741653601
Motor[2].PhasePos=1310.62328616849777
Motor[2].PhasePos=1310.62328616849686
Motor[2].PhasePos=1307.26431089312473
Motor[2].PhasePos=1323.77420922660667
Motor[2].PhasePos=1323.77735999583911
Motor[2].PhasePos=1331.42989161901664
Motor[2].PhasePos=1332.17854273394619
Use Motor[2].PhasePos=1330
Use Motor[3].PhasePos=150 (or 1200???)
*** 19.1.2017 ***
==================
Friction force of Parker stage
X(top stage): 1N max 0.1N min.. depends on the magnetic poles
#3out20 -> Force 2N
#3out30 -> Force 3N (changes in torque at poles)
Weight: ca 250g
Y(lower stage): 1N max 0.1N min.. depends on the magnetic poles
#2out20 -> Force 2.5N iqCmd=402
#2out30 -> Force 3N iqCmd=603 (changes in torque at poles)
Weight: ca 750g
*** 27.1.2017 ***
==================
Friction force of Parker stage: see blue logbook.
Calculate the current at a given force:
import numpy as np
import plt as matplotlib.pyplot
F=np.array([+300, +100, 0.,-50,-100,-150,-200,-250,-300])
i=np.array([+625, 214, 38.,-104,-207,-300,-400,-500,-600])
plt.plot(i,F,'.-')
average Motor[3].iqMeas -610.949923065
average Motor[3].iaMeas 432.573485303
average Motor[3].ibMeas -699.459308138
-> icMeas 432.573485303-699.459308138=-266.885822835
Check cur_bits to current
-------------------------
Block motor 4
set current to 10%: #4out10
Measure current with amp meter and ./move_record.py
Motor[4].PhasePos=313
gelb 293 mA
idCmd=0
average Motor[4].iqMeas 452.897308732
average Motor[4].iaMeas -274.830633873
average Motor[4].ibMeas 523.056988602
-> icMeas 248.226
rot 560 mA
average Motor[4].iqMeas 452.719438794
average Motor[4].iaMeas -264.325534893
average Motor[4].ibMeas 523.057788442
-> icMeas 258.73
schwarz 290mA
average Motor[4].iqMeas 453.042713114
average Motor[4].iaMeas -252.726254749
average Motor[4].ibMeas 523.302539492
-> icMeas 270.57
PhasePos=0 ia=-512 ib=260 ic=240
PhasePos=682 ia=250 ib=250 ic=500
PhasePos=1364 ia=320 ib=-500 ic=180
https://de.wikipedia.org/wiki/D/q-Transformation
ia=-sin(phi)*iq
ib=-sin(phi-120deg)*iq
ic=-sin(phi-240deg)*iq
...cant yet figure out the scaling...
Measuring position depenmdent friction(=current)
------------------------------------------------
./move_record.py cfg = {"sequencer": ['prog_1(host="SAROP11-CPPM-MOT6871",acq_per=10)', 'plot_1()']}
Avg current forward: 37.2596025196 Avg current backward: -68.9828819531
lut [[ 1.00000000e+03 -2.70746096e+01]
[ 1.31399384e+03 -3.76975094e+01]
[ 1.71398707e+03 -5.78253228e+01]
...
[ 2.57135808e+04 -1.09363816e+01]
[ 2.61135740e+04 -1.42231517e+01]
[ 2.65135673e+04 -1.19655511e+01]
[ 2.69135605e+04 -6.38521106e+01]]
Python to Matlab
----------------
import numpy as np, scipy.io
fn='/home/zamofing_t/Documents/prj/SwissFEL/epics_ioc_modules/ESB_MX/python/data/prog_1.npz'
fh=np.load(fn)
scipy.io.savemat(fn[:-3]+'mat',mdict=dict(fh.iteritems()))