summaryrefslogtreecommitdiff
path: root/digital/asserv/tools/step.py
blob: 5b5040b11e5c004a3e991d990e621385823ae3b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import sys

import Gnuplot

import asserv
import proto.popen_io
import serial

def step (name, offset, kp, ki, kd, plots, **param):
    if sys.argv[1] == '!':
        io = proto.popen_io.PopenIO (sys.argv[2:])
    else:
        io = serial.Serial (sys.argv[1])
    p = { name + 'kp': kp, name + 'ki': ki, name + 'kd': kd}
    p.update (param)
    a = asserv.Proto (io, **p)
    a.stats (*plots)
    a.consign (name, offset)
    #a.speed (name, 16)
    array = a.get_stats (225)
    a.close ()

    g = Gnuplot.Gnuplot (persist = True)
    g ('set data style lines')
    g.plot (*[array[:, i] for i in xrange (len (plots))])

step ('t', 0x200, 1, 0, 16, ('te', 'lw', 'rw'))
#step ('a', 0x200, 1, 0, 16, ('ae', 'lw', 'rw'))
#step ('a0', 100, 0.8, 0.05, 0.05, ('a0e', 'a0w', 'a0i'), I = 8191)