marceluda / rp_lock-in_pid_h

Lock-in and PID application for RedPitaya enviroment (only with harmonic modulation)
GNU General Public License v3.0
7 stars 8 forks source link

Streaming values #3

Open RobaczeQ opened 3 years ago

RobaczeQ commented 3 years ago

Hello marceluda,

I tried using streaming that you implemented recently, but i get empty bin file, and rp.allan also is empty.

Using windows and anaconda, streaming fails: File "C:\ProgramData\Anaconda3\lib\subprocess.py", line 1307, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, FileNotFoundError: [WinError 2]

With Linux it works, but it returns empty bin file.

I mailed to marceluda@gmail.com 2 months ago some questions, but you didn't replay, there is better place to ask some?
I really appreciate any help you can provide.

marceluda commented 3 years ago

Hello RobaczeQ.

Please, let me know which script for streaming you are talking about.

I've made all my test on linux (I don't have windows).

Some implementations relays on Linux NetCat. I made others more platform independent. Maybe if you send more detail of which tools are trying to use I can help you to make ir works.

Best regards, Marcelo

El sáb, 19 dic 2020 a las 22:27, RobaczeQ (notifications@github.com) escribió:

Hello marceluda,

I tried using streaming that you implemented recently, but i get empty bin file, and rp.allan also is empty.

Using windows and anaconda, streaming fails: File "C:\ProgramData\Anaconda3\lib\subprocess.py", line 1307, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, FileNotFoundError: [WinError 2]

With Linux it works, but it returns empty bin file.

I mailed to marceluda@gmail.com 2 months ago some questions, but you didn't replay, there is better place to ask some? I really appreciate any help you can provide.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/marceluda/rp_lock-in_pid_h/issues/3, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACALCQH43F5D7BELQ4U77VLSVVHGTANCNFSM4VCWO5JA .

RobaczeQ commented 3 years ago

rp.start_streaming() from control_hugo.py (resources/remote_control) Using

            rp.start_streaming('error ctrl_A ctrl_B')
            time.sleep(3600)
            rp.stop_streaming()
            d=read_dump(rp.allan[-1][2])
            d.plotr(start=0,end=-1,signals='error ctrl_A')

d cannot be executed because rp.allan is empty array.

Tried using Cent OS 7.0 (64-bit) and Ubuntu Linux 14.04 LTS (64-bit) (because those are supported by Xilinx Vivado 2015.2), the same problem on Ubuntu Linux 20.04 LTS, where i`m trying to debug this using spyder3.

rp.get_curv(log='name' ) works ok, but i`m interested in longer acquisition like that streaming.

marceluda commented 3 years ago

oook.

I've never documented these functions because they are not very well implemented. They are slow, inefficient and not very intuitive.

Anyway, you can try it out.

I've fixed a couple of things, so: download https://github.com/marceluda/rp_lock-in_pid_h/blob/master/resources/remote_control/read_dump.py again and checkout the example: https://github.com/marceluda/rp_lock-in_pid_h/blob/master/resources/remote_control/example_streaming.py

When you stream, the local script stores the data on a binary file. You have to open that binary file with read_dump() and process it

The names of the signals yo can acquire are the ones you see at rp.lock object

El dom, 20 dic 2020 a las 15:16, RobaczeQ (notifications@github.com) escribió:

rp.start_streaming() from control_hugo.py (resources/remote_control) Using

        rp.start_streaming('error ctrl_A ctrl_B')
        time.sleep(3600)
        rp.stop_streaming()
        d=read_dump(rp.allan[-1][2])
        d.plotr(start=0,end=-1,signals='error ctrl_A')

d cannot be executed because rp.allan is empty array.

Tried using Cent OS 7.0 (64-bit) and Ubuntu Linux 14.04 LTS (64-bit) (because those are supported by Xilinx Vivado 2015.2), the same problem on Ubuntu Linux 20.04 LTS, where i`m trying to debug this using spyder3.

rp.get_curv(log='name' ) works ok, but i`m interested in longer acquisition like that streaming.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/marceluda/rp_lock-in_pid_h/issues/3#issuecomment-748641947, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACALCQDEOFUJ7PI7ITODMDLSVY5QNANCNFSM4VCWO5JA .

RobaczeQ commented 3 years ago
20201221_061149_dump.bin
Traceback (most recent call last):

  File "rp_lock-in_pid_h-master/resources/remote_control/example_streaming.py", line 56, in <module>
    d = read_dump('20201221_061055_dump.bin')

  File "rp_lock-in_pid_h-master/resources/remote_control/read_dump.py", line 122, in __init__
    self.load_params()

  File "rp_lock-in_pid_h-master/resources/remote_control/read_dump.py", line 158, in load_params
    self.ylbl=txt1.decode().split('\n')[0].split(' ')[1].split(',')

IndexError: list index out of range

Yeah, it's the same, dump file is 0 bytes, so it can't be read properly.

I've never documented these functions because they are not very well implemented. They are slow, inefficient and not very intuitive.

So, for longer acquisition what I should use instead of that? Or do you mean "rp.get_curv()"?

If that works for you, could you tell about what you're using? Like System/environment? It could try setting up another system and installing all libraries when certain error about them pop up.

marceluda commented 3 years ago

Ok... This is part of the poor implementation I'm talking to you about

Probably, you are having problems in the STEMLab side.

Please... make a remote login (with SSH) to the RedPitaya as root and run:

apt install netcat

you need python3 and netcat in the REdPitaya SO to make te streaming.

Let me know if it worked out.

El lun, 21 dic 2020 a las 11:16, RobaczeQ (notifications@github.com) escribió:

20201221_061149_dump.bin Traceback (most recent call last):

File "rp_lock-in_pid_h-master/resources/remote_control/example_streaming.py", line 56, in d = read_dump('20201221_061055_dump.bin')

File "rp_lock-in_pid_h-master/resources/remote_control/read_dump.py", line 122, in init self.load_params()

File "rp_lock-in_pid_h-master/resources/remote_control/read_dump.py", line 158, in load_params self.ylbl=txt1.decode().split('\n')[0].split(' ')[1].split(',')

IndexError: list index out of range

Yeah, it's the same, dump file is 0 bytes, so it can't be read properly.

I've never documented these functions because they are not very well implemented. They are slow, inefficient and not very intuitive.

So, for longer acquisition what I should use instead of that? Or do you mean "rp.get_curv()"?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/marceluda/rp_lock-in_pid_h/issues/3#issuecomment-748995324, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACALCQDWT4WFY2BAAPS52N3SV5KCXANCNFSM4VCWO5JA .

RobaczeQ commented 3 years ago

Still the same problem.

marceluda commented 3 years ago

well

there's something missing somewhere 🤔

your client computer it's running Linux?

Do you have netcat installed on the client?

If you run the script with all the logs ... you can see some info about the streaming. For example, in my case I run:

from numpy import * import numpy as np from matplotlib import pyplot as plt from time import sleep,time

PATH of control_hugo.py file

import sys

from control_hugo import red_pitaya_control,red_pitaya_app

AppName = 'lock_in+pid_harmonic' host = 'rp-f00a3b.local' port = 22 # default port trigger_type = 6 # 6 is externa trigger

filename = 'test.npz' rp=red_pitaya_app(AppName=AppName,host=host,port=port,filename=filename,password='root')

I see the log:

auth method: pass Remote Command: uname -a Remote Command: echo $SSH_CONNECTION rp.osc.load(): /opt/redpitaya/www/apps/lock_in+pid_harmonic/py/osc.py Remote Command: /opt/redpitaya/www/apps/lock_in+pid_harmonic/py/osc.py rp.lock_in+pid_harmonic.load(): /opt/redpitaya/www/apps/lock_in+pid_harmonic/py/lock.py Remote Command: /opt/redpitaya/www/apps/lock_in+pid_harmonic/py/lock.py Remote Command: cat /opt/redpitaya/www/apps/lock_in+pid_harmonic/index.html Remote Command: /opt/redpitaya/bin/calib -r -v

Then I run:

rp.start_streaming(signals='oscA oscB',log='Arrancamos') sleep(1000) rp.stop_streaming()

And I get:

Getting streaming for [oscA oscB] start_streaming(): Getting streaming for [oscA oscB] start_streaming():Arrancamos start_streaming(): filename=20201221_123619_dump.bin 20201221_123619_dump.bin remote: /opt/redpitaya/www/apps/lock_in+pid_harmonic/py/data_dump.py -s 192.168.0.5 -p 6000 --params oscA oscB

The last line is what the script is running on the STEAMLab device OS. You can login with SSH and run it. And see the local errors. But before running that line you need to start netcat in your client computer:

So, run in your computer:

nc -l 6000 > test_file.bin

It will keep waiting for data. Then, run in redpitaya OS the line you get from log. In my case:

/opt/redpitaya/www/apps/lock_in+pid_harmonic/py/data_dump.py -s 192.168.0.5 -p 6000 --params oscA oscB

One of these steps should fail and tell us what's going on.

El lun, 21 dic 2020 a las 11:36, RobaczeQ (notifications@github.com) escribió:

Still the same problem.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/marceluda/rp_lock-in_pid_h/issues/3#issuecomment-749005047, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACALCQCY3SVROIOHFTGTUFLSV5MPDANCNFSM4VCWO5JA .

RobaczeQ commented 3 years ago

your client computer it's running Linux?

I`m running Windows with virtual machine (Linux)

Do you have netcat installed on the client?

Yes

that part of code:

#%%

from numpy import *
import numpy as np
from matplotlib import pyplot as plt
from time import sleep,time

# PATH of control_hugo.py file
import sys

from control_hugo import red_pitaya_control,red_pitaya_app

AppName      = 'lock_in+pid_harmonic'
host         = '192.168.1.21'
port         = 22  # default port
trigger_type = 6   # 6 is externa trigger

#%%
filename = 'test.npz'
rp=red_pitaya_app(AppName=AppName,host=host,port=port,filename=filename,password='root')

# reduce log noise on Windows platform
import logging
logging.basicConfig()
logging.getLogger("paramiko").setLevel(logging.WARNING)
rp.verbose = False

#%%

rp.start_streaming(signals='oscA oscB',log='Arrancamos')

sleep(10)

rp.stop_streaming()

gives

Reloaded modules: control_hugo
auth method: pass
Remote Command: uname -a
Remote Command: echo $SSH_CONNECTION
rp.osc.load(): /opt/redpitaya/www/apps/lock_in+pid_harmonic/py/osc.py
Remote Command: /opt/redpitaya/www/apps/lock_in+pid_harmonic/py/osc.py
rp.lock_in+pid_harmonic.load(): /opt/redpitaya/www/apps/lock_in+pid_harmonic/py/lock.py
Remote Command: /opt/redpitaya/www/apps/lock_in+pid_harmonic/py/lock.py
Remote Command: cat /opt/redpitaya/www/apps/lock_in+pid_harmonic/index.html
Remote Command: /opt/redpitaya/bin/calib -r -v
Getting streaming for [oscA oscB]
20201221_075143_dump.bin

And dump file is empty.

Adding sys.path.append('path') of control_hugo.py doesn't help either.

marceluda commented 3 years ago

Plese... do NOT run this block:

import logging

logging.basicConfig()

logging.getLogger("paramiko").setLevel(logging.WARNING)

rp.verbose = False

That's only to HIDE the logs... and we need to SEE the logs...

El lun, 21 dic 2020 a las 12:56, RobaczeQ (notifications@github.com) escribió:

your client computer it's running Linux?

I`m running Windows with virtual machine (Linux)

Do you have netcat installed on the client?

Yes

that part of code:

filename = 'test.npz' rp=red_pitaya_app(AppName=AppName,host=host,port=port,filename=filename,password='root')

reduce log noise on Windows platform

import logging logging.basicConfig() logging.getLogger("paramiko").setLevel(logging.WARNING) rp.verbose = False

%%

rp.start_streaming(signals='oscA oscB',log='Arrancamos')

sleep(10)

rp.stop_streaming()

gives

Reloaded modules: control_hugo auth method: pass Remote Command: uname -a Remote Command: echo $SSH_CONNECTION rp.osc.load(): /opt/redpitaya/www/apps/lock_in+pid_harmonic/py/osc.py Remote Command: /opt/redpitaya/www/apps/lock_in+pid_harmonic/py/osc.py rp.lock_in+pid_harmonic.load(): /opt/redpitaya/www/apps/lock_in+pid_harmonic/py/lock.py Remote Command: /opt/redpitaya/www/apps/lock_in+pid_harmonic/py/lock.py Remote Command: cat /opt/redpitaya/www/apps/lock_in+pid_harmonic/index.html Remote Command: /opt/redpitaya/bin/calib -r -v Getting streaming for [oscA oscB] 20201221_075143_dump.bin

And dump file is empty.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/marceluda/rp_lock-in_pid_h/issues/3#issuecomment-749046354, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACALCQDKHN7QZRBM2T4YQA3SV5V27ANCNFSM4VCWO5JA .

RobaczeQ commented 3 years ago
Reloaded modules: control_hugo
auth method: pass
Remote Command: uname -a
Remote Command: echo $SSH_CONNECTION
rp.osc.load(): /opt/redpitaya/www/apps/lock_in+pid_harmonic/py/osc.py
Remote Command: /opt/redpitaya/www/apps/lock_in+pid_harmonic/py/osc.py
rp.lock_in+pid_harmonic.load(): /opt/redpitaya/www/apps/lock_in+pid_harmonic/py/lock.py
Remote Command: /opt/redpitaya/www/apps/lock_in+pid_harmonic/py/lock.py
Remote Command: cat /opt/redpitaya/www/apps/lock_in+pid_harmonic/index.html
Remote Command: /opt/redpitaya/bin/calib -r -v
Getting streaming for [in1 in2]
start_streaming(): Getting streaming for [in1 in2]
start_streaming():Arrancamos
start_streaming(): filename=20201221_081353_dump.bin
20201221_081353_dump.bin
remote: /opt/redpitaya/www/apps/lock_in+pid_harmonic/py/data_dump.py  -s 192.168.1.169 -p 6000 --params in1 in2
Remote Command: ps ax 
Remote Command: kill 2024
stop_straming(): killing pid: 2024
marceluda commented 3 years ago

That's it!

Now... you have to run in your computer (from terminal):

nc -l 6000 > test_file.bin

And then, in the RP (through SSH) :

/opt/redpitaya/www/apps/lock_in+pid_harmonic/py/data_dump.py -s 192.168.1.169 -p 6000 --params in1 in2

And there will be some errors (unseen until now) that tell us what's wrong

El lun, 21 dic 2020 a las 13:15, RobaczeQ (notifications@github.com) escribió:

Reloaded modules: control_hugo auth method: pass Remote Command: uname -a Remote Command: echo $SSH_CONNECTION rp.osc.load(): /opt/redpitaya/www/apps/lock_in+pid_harmonic/py/osc.py Remote Command: /opt/redpitaya/www/apps/lock_in+pid_harmonic/py/osc.py rp.lock_in+pid_harmonic.load(): /opt/redpitaya/www/apps/lock_in+pid_harmonic/py/lock.py Remote Command: /opt/redpitaya/www/apps/lock_in+pid_harmonic/py/lock.py Remote Command: cat /opt/redpitaya/www/apps/lock_in+pid_harmonic/index.html Remote Command: /opt/redpitaya/bin/calib -r -v Getting streaming for [in1 in2] start_streaming(): Getting streaming for [in1 in2] start_streaming():Arrancamos start_streaming(): filename=20201221_081353_dump.bin 20201221_081353_dump.bin remote: /opt/redpitaya/www/apps/lock_in+pid_harmonic/py/data_dump.py -s 192.168.1.169 -p 6000 --params in1 in2 Remote Command: ps ax Remote Command: kill 2024 stop_straming(): killing pid: 2024

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/marceluda/rp_lock-in_pid_h/issues/3#issuecomment-749055344, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACALCQHUKA3TG4T4QRIKXULSV5YAXANCNFSM4VCWO5JA .

RobaczeQ commented 3 years ago

Redpitaya only show after that command: 1608568111.6387084

In computer terminal nothing happens, test_file.bin is empty.

After a while

1608568307.157256
(UNKNOWN) [192.168.1.169] 6000 (?) : Connection timed out
Traceback (most recent call last):
  File "/opt/redpitaya/www/apps/lock_in+pid_harmonic/py/data_dump.py", line 124, in <module>
    process.stdin.flush()
BrokenPipeError: [Errno 32] Broken pipe

I can ping computer from Redpitaya, so connection should be ok.

marceluda commented 3 years ago

There's seem to be some kind of network communication problem

My last test I suggest to you is:

Run in your machine:

nc -l 6000 > test_file.txt

Then Run in RedPitaya:

echo "Hello, this is a message" | nc 192.168.1.169 6000

After that, you should have "Hello, this is a message" in the test_file.txt of your machine .

I'm working on a better solution for streaming... but it's still not ready.

El lun, 21 dic 2020 a las 13:33, RobaczeQ (notifications@github.com) escribió:

Redpitaya only show after that command: 1608568111.6387084

In computer terminal nothing happens, bin is empty.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/marceluda/rp_lock-in_pid_h/issues/3#issuecomment-749064222, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACALCQCMSABAD5HFHLEGUILSV52FJANCNFSM4VCWO5JA .

RobaczeQ commented 3 years ago

There's seem to be some kind of network communication problem After that, you should have "Hello, this is a message" in the test_file.txt of your machine .

Nothing happens. Right, some communication problem. I will try to resolve that, if I will get it to working, i will post the solution.

I'm working on a better solution for streaming... but it's still not ready.

Nice to hear that, but probably connection problem is on my end and other things could also fail to communicate well. Still, i will appreciate info about your system, maybe the problem is with virtual machine, so if it will not work, i will try to set up a proper one.

Thanks for your time.

marceluda commented 3 years ago

Ok, thanks for the update.

You have some connection problem ... I see. Maybe related with firewalls or the VM network device.

The test you made it's kind of a standard test. Yo can see it in https://www.digitalocean.com/community/tutorials/how-to-use-netcat-to-establish-and-test-tcp-and-udp-connections-on-a-vps "How To Send Files through Netcat"

El lun, 21 dic 2020 a las 14:32, RobaczeQ (notifications@github.com) escribió:

There's seem to be some kind of network communication problem After that, you should have "Hello, this is a message" in the test_file.txt of your machine .

Nothing happens. Right, some communication problem. I will try to resolve that, if I will get it to working, i will post the solution.

I'm working on a better solution for streaming... but it's still not ready.

Nice to hear that, but probably connection problem is on my end and other things could also fail to communicate well. Thanks for your time.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/marceluda/rp_lock-in_pid_h/issues/3#issuecomment-749100387, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACALCQDOL6ZURG2E3BYMEUTSV6BBPANCNFSM4VCWO5JA .

RobaczeQ commented 3 years ago

Starting with Linux Virtual Machine: Network Adapter should be bridged using replicating physical network Default DNS servers even if browsing internet is possible, aren't good. 1.1.1.1 works. Then it works.

With windows (using anaconda): There are more complications. Firewall blocks communication, need to be turn off. Netcat isn't supported there by "netcat" or "nc" in console. There is possible using it thru python (download in anaconda) or standalone version using .exe format. I tried both, but ended using standalone version. So, control_hugo.py need to be changed

self.stream = subprocess.Popen( file_path + ' -l -p 6000', shell=True, stdin=subprocess.PIPE , stdout=self.file , stderr=subprocess.PIPE)

When shell is true, then it creates child processes, so when process is terminated by

            for i in [ y.strip().split(' ')[0] for y in filter(lambda x: 'data_dump.py' in x, result.split('\n'))  ]:
                self.ssh_cmd('kill '+str(i))
                self.log('stop_straming(): killing pid: '+str(i))
            self.stream.terminate() 

it only kills one process, and program can't do self.stream.communicate(). Using desktop ip all of them (3) can be closed.

            for i in [ y.strip().split(' ')[0] for y in filter(lambda x: self.info['myIP'] in x, result.split('\n'))  ]:
                self.ssh_cmd('kill '+str(i))
                self.log('stop_straming(): killing pid: '+str(i))
            self.stream.terminate()

Thanks for your help :)

RobaczeQ commented 3 years ago

Another small question, is it possible to pass thru rp.lock.out1 particular value? Like set rp.lock.out1=100? rp.lock.out_sw sets it back to 0.

And another one, about relocking: I wanted to turn off PIDs when in2 is below certain threshold, apply to out1 ramp/sawtooth signal instead of PIDA , and when signal in2 return above threshold turn on PIDs. That doesn't work that way?

I`m using ctrl_A on out1 so i can have ramp and PID in one signal, I understand that i can lock when i have those options (scan enable on, pid off -> scan off, pid on) using Trigger Lock image But when it locks, it turns off scan and sets pid to on. image Is there a way using this Re-lock system (Error Enable, Signal Enable, RL reset) to have automatic relock when in2 have lower value than specific treshold?

marceluda commented 3 years ago

El mié, 6 ene 2021 a las 8:02, RobaczeQ (notifications@github.com) escribió:

Another small question, is it possible to pass thru rp.lock.out1 particular value? Like set rp.lock.out1=100? rp.lock.out_sw sets it back to 0.

rp.lock.out1 is a read only variable. The way to do what you want is to change rp.lock.out_sw to one of the auxiliar fpga registers ( AuxA or AuxB ) and then set the value of AuxA or AuxB.

And another one, about relocking: I wanted to turn off PIDs when in2 is below certain threshold, apply to out1 ramp/sawtooth signal instead of PIDA , and when signal in2 return above threshold turn on PIDs. That doesn't work that way?

It should work like that. I haven't used the relock system for a while, after making other version changes. I think it should work , but I would try to check it.

I`m using ctrl_A on out1 so i can have ramp and PID in one signal, I understand that i can lock when i have those options (scan enable on, pid off -> scan off, pid on) using Trigger Lock [image: image] https://user-images.githubusercontent.com/54936640/103760722-ce438980-5015-11eb-9b20-72eaad4da930.png But when it locks, it turns off scan and sets pid to on. [image: image] https://user-images.githubusercontent.com/54936640/103761092-680b3680-5016-11eb-8121-3e9c6a839209.png Is there a way using this Re-lock system (Error Enable, Signal Enable, RL reset) to have automatic relock when in2 have lower value than specific treshold?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/marceluda/rp_lock-in_pid_h/issues/3#issuecomment-755234540, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACALCQDAKPZPULYJ3M7QAB3SYQ7LNANCNFSM4VCWO5JA .

RobaczeQ commented 3 years ago

It should work like that. I haven't used the relock system for a while, after making other version changes. I think it should work , but I would try to check it.

For me it's not working correctly. I have one signal which is above 4000 int, and I have "Signal Enable in2<200" and "RL reset" on and it turning locking randomly when i have still good lock. It could cause lock to break off, and while its not locked its not trying to lock thru Ramp on, PID off -> PID on, Ramp off. When its starts then it doesn't turn off pids so signal looks like that: relock

When i turn off pids in lock control it makes signal ctrl_A to be not as Ramp should be (from 8191->-8192): Screenshot_4

Have you seen streaming app that came out in one of last redpitaya updates? Do you think its possible to have it implemented also in locking app (while it is not possible to have 2 app running simultaneously)?

I'm trying to bypass relock feature by just doing C program where I can turn this lock by setting "Scan enable" and "Trigger Lock" when specific signal is below certain threshold (I'm thinking about using slow input so i have free fast one). But I`m not seeing certain lock functions in src folder. Should I just use:

lock_update(rp_app_params_t *params)

like that lock_update('lock_control', 2+128+2*256+1024)? Or it should be different syntax?

Is this possible to have in PIDs slow inputs (and in lock trigger signal)? PIDB have only error and in1. Would be really nice if it would be possible to have in PIDB input PIDA output, but as you said earlier there isn't, so it would need to be out1>in2 to use pids in series.

marceluda commented 3 years ago

El vie, 19 mar 2021 a las 8:16, RobaczeQ @.***>) escribió:

It should work like that. I haven't used the relock system for a while, after making other version changes. I think it should work , but I would try to check it.

For me it's not working correctly. I have one signal which is above 4000 int, and I have "Signal Enable in2<200" and "RL reset" on and it turning locking randomly when i have still good lock. It could cause lock to break off, and while its not locked its not trying to lock thru Ramp on, PID off -> PID on, Ramp off. When its starts then it doesn't turn off pids so signal looks like that: [image: relock] https://user-images.githubusercontent.com/54936640/111771827-6e3a5080-88ac-11eb-8218-51e192cff0b6.png

When i turn off pids in lock control it makes signal ctrl_A to be not as Ramp should be (from 8191->-8192): [image: Screenshot_4] https://user-images.githubusercontent.com/54936640/111767448-08979580-88a7-11eb-9765-5046bcb76465.png

Have you seen streaming app that came out in one of last redpitaya updates? Do you think its possible to have it implemented also in locking app (while it is not possible to have 2 app running simultaneously)?

I'm working to make something similar to that right now. But it's still on development

I'm trying to bypass relock feature by just doing C program where I can turn this lock by setting "Scan enable" and "Trigger Lock" when specific signal is below certain threshold (I'm thinking about using slow input so i have free fast one). But I`m not seeing certain lock functions in src folder. Should I just use:

lock_update(rp_app_params_t *params)

like that lock_update('lock_control', 2+128+2*256+1024)? Or it should be different syntax?

I don't understand where you are implementing the C code. ¿Its an external program or are you modifying the C code of the web server plugin?

The register you should control is that, the 'lock_control' one.

You can make some tests using the python sripts on /opt/redpitaya/www/apps/lock_in+pid_harmonic/py to read or set that values

Also, you can use the monitor command line program ( https://redpitaya.readthedocs.io/en/latest/developerGuide/software/clt.html#accessing-system-registers) that comes with RP. You only need to know the memory address of the register you want to change. To know that, use the script lock_reg_table.py ... it will show you the memory addresses ( https://github.com/marceluda/rp_lock-in_pid_h/tree/master/lock_in%2Bpid_harmonic/py )

Is this possible to have in PIDs slow inputs (and in lock trigger signal)?

Slow inputs were not working very well. I don't remember, but I think I disabled them.

PIDB have only error and in1.

If you press "More options" Button you have more inputs options

Would be really nice if it would be possible to have in PIDB input PIDA output, but as you said earlier there isn't, so it would need to be out1>in2 to use pids in series.

I'm considering this to next versions...

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/marceluda/rp_lock-in_pid_h/issues/3#issuecomment-802757465, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACALCQHT76537B4UNQDQPZTTEMW7HANCNFSM4VCWO5JA .

RobaczeQ commented 3 years ago

I'm working to make something similar to that right now. But it's still on development

Do you mean relock or streaming values? Could you tell me how "Re-lock system" should work? Maybe I`m using them wrongly. Error Enable Signal Enable *RL reset

I don't understand where you are implementing the C code. ¿Its an external program or are you modifying the C code of the web server plugin?

I just wanted working relock, so I thought about using lock_in+pid_harmonic\src\lock.c and some rp library so i can check voltage on slow input and if its below threshold set lock_control to "Scan enable" + "Trigger Lock". It would be app on redpitaya side, so I can turn on it via ssh.

Currently I use python with chromedriver, checking on web page value of in2 and setting lock_control accordingly to in2 value, but it's not fast enough. Looks like site refresh about 200-300 ms, so they is some lag using that metod.

marceluda commented 3 years ago

Ok ... first, sorry for the late answer.

El jue, 1 abr 2021 a las 16:16, RobaczeQ @.***>) escribió:

I'm working to make something similar to that right now. But it's still on development

Do you mean relock or streaming values?

Streaming values. I've just published a new version of the App with that:

Could you tell me how "Re-lock system" should work? Maybe I`m using them wrongly. Error Enable Signal Enable *RL reset

The idea is this:

  • You chose a signal that should be alway above a value (signal anble)
  • Or you chose a signal that should be always near zero (like error), so... its amplitude should be below some value
  • Or you may choose both options

If something of this NOT happens ... then the PIDs are freezed and the relock procedure is started.

The relock procedure is a triangle scan that on each semi-period sets the scan amplitude to double.

If it never meet the conditions of locking ... then, it just stop scanning

I don't understand where you are implementing the C code. ¿Its an external program or are you modifying the C code of the web server plugin?

I just wanted working relock, so I thought about using lock_in+pid_harmonic\src\lock.c and some rp library so i can check voltage on slow input and if its below threshold set lock_control to "Scan enable"

  • "Trigger Lock". It would be app on redpitaya side, so I can turn on it via ssh.

Now you have a more clear code to use as base. You can access it here:

https://github.com/marceluda/rp_lock-in_pid_h/tree/master/lock_in%2Bpid_harmonic/c

Here you have samples of code to access one register or several, without the web server part.

Also, you can check the file: https://github.com/marceluda/rp_lock-in_pid_h/blob/master/lock_in%2Bpid_harmonic/nginx.conf

Modifying this file on the App you can give you access to run or control your C app by HTTP request to virtual URIs.

Currently I use python with chromedriver, checking on web page value of in2 and setting lock_control accordingly to in2 value, but it's not fast enough. Looks like site refresh about 200-300 ms, so they is some lag using that metod.

Using C code you can make your own re-lockin logic very fast. And you can start the relocking procedure just by a web browser call.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/marceluda/rp_lock-in_pid_h/issues/3#issuecomment-812116682, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACALCQEXBMCIMNQX5NWSGC3TGTBBFANCNFSM4VCWO5JA .

marceluda commented 3 years ago

The re-locking procedure was described here: https://doi.org/10.1063/1.5080345 (from my dropbox https://www.dropbox.com/s/rnzjvvotj3dromt/RSI_1.5080345.pdf?dl=0). See the 1. Lock-control section and the last part.

The idea was taken from here: https://doi.org/10.1063/1.4938282

El jue, 1 abr 2021 a las 12:31, Marcelo @.***>) escribió:

El vie, 19 mar 2021 a las 8:16, RobaczeQ @.***>) escribió:

It should work like that. I haven't used the relock system for a while, after making other version changes. I think it should work , but I would try to check it.

For me it's not working correctly. I have one signal which is above 4000 int, and I have "Signal Enable in2<200" and "RL reset" on and it turning locking randomly when i have still good lock. It could cause lock to break off, and while its not locked its not trying to lock thru Ramp on, PID off -> PID on, Ramp off. When its starts then it doesn't turn off pids so signal looks like that: [image: relock] https://user-images.githubusercontent.com/54936640/111771827-6e3a5080-88ac-11eb-8218-51e192cff0b6.png

When i turn off pids in lock control it makes signal ctrl_A to be not as Ramp should be (from 8191->-8192): [image: Screenshot_4] https://user-images.githubusercontent.com/54936640/111767448-08979580-88a7-11eb-9765-5046bcb76465.png

Have you seen streaming app that came out in one of last redpitaya updates? Do you think its possible to have it implemented also in locking app (while it is not possible to have 2 app running simultaneously)?

I'm working to make something similar to that right now. But it's still on development

I'm trying to bypass relock feature by just doing C program where I can turn this lock by setting "Scan enable" and "Trigger Lock" when specific signal is below certain threshold (I'm thinking about using slow input so i have free fast one). But I`m not seeing certain lock functions in src folder. Should I just use:

lock_update(rp_app_params_t *params)

like that lock_update('lock_control', 2+128+2*256+1024)? Or it should be different syntax?

I don't understand where you are implementing the C code. ¿Its an external program or are you modifying the C code of the web server plugin?

The register you should control is that, the 'lock_control' one.

You can make some tests using the python sripts on /opt/redpitaya/www/apps/lock_in+pid_harmonic/py to read or set that values

Also, you can use the monitor command line program ( https://redpitaya.readthedocs.io/en/latest/developerGuide/software/clt.html#accessing-system-registers) that comes with RP. You only need to know the memory address of the register you want to change. To know that, use the script lock_reg_table.py ... it will show you the memory addresses ( https://github.com/marceluda/rp_lock-in_pid_h/tree/master/lock_in%2Bpid_harmonic/py )

Is this possible to have in PIDs slow inputs (and in lock trigger signal)?

Slow inputs were not working very well. I don't remember, but I think I disabled them.

PIDB have only error and in1.

If you press "More options" Button you have more inputs options

Would be really nice if it would be possible to have in PIDB input PIDA output, but as you said earlier there isn't, so it would need to be out1>in2 to use pids in series.

I'm considering this to next versions...

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/marceluda/rp_lock-in_pid_h/issues/3#issuecomment-802757465, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACALCQHT76537B4UNQDQPZTTEMW7HANCNFSM4VCWO5JA .

RobaczeQ commented 3 years ago

Thank you for your time.

The idea is this:

  • You chose a signal that should be alway above a value (signal anble)
  • Or you chose a signal that should be always near zero (like error), so... its amplitude should be below some value
  • Or you may choose both options

If something of this NOT happens ... then the PIDs are freezed and the relock procedure is started.

The relock procedure is a triangle scan that on each semi-period sets the scan amplitude to double.

  • If while scanning the conditions you choseed are met again ... then, the scan stops and continues the locking by un-freezing the PIDs
  • If not, continues scanning every time a larger amplitude. You start near the value you had before failing because it is more probable your stabilization condition its near that.

If it never meet the conditions of locking ... then, it just stop scanning

So, what "RL reset" is doing? This seems like RL enable, but is that it?

I thought relock will use "Ramp Controller", or it is using that? Or it's some predefined ramp value that will be doubled each semi-period? Looks like "Ramp period" from "Ramp Controller" is used there, but "Ramp hig lim", "Ramp low lim", "Ramp B factor" doesn't do anything there. image Still, I doesn't know why relocking signal there is starting from -8000 int and slowly going up to -4000 int, and not going higher. Probably it's locked on specific double times. Also it should be starting from 0 int not -8000. I`m not using "Lock-in modules", but "Harmonic oscilator" and "Demodulation" seems doing something to that, but that's probably as intended, I have those on 0/off.

If the lock condition is never met, the submodule will continue increasing the scan ampli- tude until it makes a semi-period sweep with the longest width (1 V ≡ 8192 int) and then will stop ramp.

Or that -4000 from -8000 is half of 8192, other half is below -1V, so it restarts to small? But as you can see in this example it would be only 1/4 of Redpitaya range.

Streaming values. I've just published a new version of the App with that

Did you check Redpitaya tool? I can't really check your streaming because network via VPN have probably blocked ports, so netcat can't send data. image image

0.98 MS/sec is the fastest streaming for continuous data, but continuity may be broken for the first half second.

Using Redpitaya app it looks like it have better performance than yours netcat (Also thanks to that it something different, I`m able to do that via VPN). Up to 62.5 MHz on 1 channel 8 bit. Using 2 channels halve rate, also 16 bit halve rate. So 2 channel, 16 bit is 15.6 MHz.

marceluda commented 3 years ago

El lun., 5 de abril de 2021 16:44, RobaczeQ @.***> escribió:

Thank you for your time.

The idea is this:

  • You chose a signal that should be alway above a value (signal anble)
  • Or you chose a signal that should be always near zero (like error), so... its amplitude should be below some value
  • Or you may choose both options

If something of this NOT happens ... then the PIDs are freezed and the relock procedure is started.

The relock procedure is a triangle scan that on each semi-period sets the scan amplitude to double.

  • If while scanning the conditions you choseed are met again ... then, the scan stops and continues the locking by un-freezing the PIDs
  • If not, continues scanning every time a larger amplitude. You start near the value you had before failing because it is more probable your stabilization condition its near that.

If it never meet the conditions of locking ... then, it just stop scanning

So, what "RL reset" is doing? This seems like RL enable, but is that it?

No exactly. If the relock fails, it stop scanning. If yo want to estart all over again, you nees to reset the relock state.

I thought relock will use "Ramp Controller", or it is using that

Yes, it use that

Or it's some predefined ramp value that will be doubled each semi-period? Looks like "Ramp period" from "Ramp Controller" is used there, but "Ramp hig lim", "Ramp low lim", "Ramp B factor" doesn't do anything there.

Relock justa take control of theeae ramp registers, incremeting the limits in ecah sweep.

[image: image]

https://user-images.githubusercontent.com/54936640/113610783-ded3c200-964d-11eb-9a85-90dc5b73a288.png Still, I doesn't know why relocking signal there is starting from -8000 int and slowly going up to -4000 int, and not going higher.

That's probably a bug 🤔

Probably it's locked on specific double times. Also it should be starting from 0 int not -8000. I`m not using "Lock-in modules", but "Harmonic oscilator" and "Demodulation" seems doing something to that, but that's probably as intended, I have those on 0/off.

The relock system is separated from lock-in demodulation

If the lock condition is never met, the submodule will continue increasing the scan ampli- tude until it makes a semi-period sweep with the longest width (1 V ≡ 8192 int) and then will stop ramp.

Or that -4000 from -8000 is half of 8192, other half is below -1V, so it restarts to small? But as you can see in this example it would be only 1/4 of Redpitaya range.

I should check whtas going on with relock system. It worked ok on Lock_in+PID version... But i've made lots of changes and I may have affected something on that system🤔

Streaming values. I've just published a new version of the App with that

Did you check Redpitaya tool? I can't really check your streaming because network via VPN have probably blocked ports, so netcat can't send data.

I tryied it. I can maybe add an option for in device save, like the RP tool🤔.

[image: image]

https://user-images.githubusercontent.com/54936640/113617141-51e13680-9656-11eb-99d4-46f93ba09864.png [image: image] https://user-images.githubusercontent.com/54936640/113615932-c7e49e00-9654-11eb-9ebf-e352a761b8c8.png

0.98 MS/sec is the fastest streaming for continuous data, but continuity may be broken for the first half second.

Using Redpitaya app it looks like it have better performance than yours netcat (Also thanks to that it something different, I`m able to do that via VPN). Up to 62.5 MHz on 1 channel 8 bit. Using 2 channels halve rate, also 16 bit halve rate. So 2 channel, 16 bit is 15.6 MHz.

The RP system IS much more efficient. It uses a internal FPGA FIFO I cannot implement in my APP, that has much more performance. Thats why Im limited in bandwith

You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/marceluda/rp_lock-in_pid_h/issues/3#issuecomment-813608251, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACALCQABHXPVMD2AM273MS3THIHIDANCNFSM4VCWO5JA .

RobaczeQ commented 3 years ago

No exactly. If the relock fails, it stop scanning. If yo want to estart all over again, you nees to reset the relock state.

So, keeping enabled "RL reset" should make it not relocking? Like ramp reset keeps ramp from starting? So, I should keep "RL reset" off to relock? If relock fails, then it won't try another time on his own? Then I should click "RL reset" 2 times to enable relock again?

Now you have a more clear code to use as base. You can access it here:

https://github.com/marceluda/rp_lock-in_pid_h/tree/master/lock_in%2Bpid_harmonic/c

I don't understand some of that code, but looks like I could just use read_reg() and write_reg() to change registers, which is probably enough to do another relock.

Here you have samples of code to access one register or several, without the web server part.

Also, you can check the file: https://github.com/marceluda/rp_lock-in_pid_h/blob/master/lock_in%2Bpid_harmonic/nginx.conf

Using C code you can make your own re-lockin logic very fast. And you can start the relocking procedure just by a web browser call. Modifying this file on the App you can give you access to run or control your C app by HTTP request to virtual URIs.

https://github.com/marceluda/rp_lock-in_pid_h/blob/master/resources/remote_control/http_version/control_finn.py This looks like more elegant way to change values than I`m using now (using selenium and accessing each box on live webpage). Nice to see that I could done better. Probably starting from scratch would be good idea. I really appreciate your work and help.

marceluda commented 3 years ago

El lun, 5 abr 2021 a las 19:04, RobaczeQ @.***>) escribió:

No exactly. If the relock fails, it stop scanning. If yo want to estart all over again, you nees to reset the relock state.

So, keeping enabled "RL reset" should make it not relocking? Like ramp reset keeps ramp from starting? So, I should keep "RL reset" off to relock? If relock fails, then it won't try another time on his own? Then I should click "RL reset" 2 times to enable relock again?

Exactly. It's supposed to work like that.

Now you have a more clear code to use as base. You can access it here:

https://github.com/marceluda/rp_lock-in_pid_h/tree/master/lock_in%2Bpid_harmonic/c

I don't understand some of that code, but looks like I could just use read_reg() and write_reg() to change registers, which is probably enough to do another relock.

Yes. That's why it is more simple. Most of the code is just reading arguments. The important part is:

Opening the memory access:

char *name = "/dev/mem";

int fd; void lock_ptr ; int32_t lock ; // Pointer for lock block memory addreses long lock_size = sysconf(_SC_PAGESIZE); long lock_addr = LOCK_FPGA_BASE_ADDR & (~(lock_size-1)); long lock_off = LOCK_FPGA_BASE_ADDR - lock_addr; // mmap(addr, length, prot , flags , fd , offset ); lock_ptr = mmap(NULL, LOCK_FPGA_BASE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd , lock_addr);

lock       = lock_ptr ;

Then use write_reg and read_reg using the index ... (the index numbers for this version are here: https://github.com/marceluda/rp_lock-in_pid_h/blob/master/lock_in%2Bpid_harmonic/c/lock.txt

then closing memory access:

munmap(lock_ptr, sysconf(_SC_PAGESIZE));

Here you have samples of code to access one register or several, without

the web server part.

Also, you can check the file:

https://github.com/marceluda/rp_lock-in_pid_h/blob/master/lock_in%2Bpid_harmonic/nginx.conf

Using C code you can make your own re-lockin logic very fast. And you can start the relocking procedure just by a web browser call. Modifying this file on the App you can give you access to run or control your C app by HTTP request to virtual URIs.

https://github.com/marceluda/rp_lock-in_pid_h/blob/master/resources/remote_control/http_version/control_finn.py This looks like more elegant way to change values than I`m using now (using selenium and accessing each box on live webpage). Nice to see that I could done better. Probably starting from scratch would be good idea. I really appreciate your work and help.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/marceluda/rp_lock-in_pid_h/issues/3#issuecomment-813676969, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACALCQF2MIGHJV5LVF2AOETTHIXYVANCNFSM4VCWO5JA .

RobaczeQ commented 3 years ago

As you state in "Compact embedded device for lock-in measurements and experiment active control" τd=2^n_d8ns/pidX_kd60/64 but changing pidX_kd 10x shows 10x τ instead of 0.1x (in web application). In article is correct formula or on web page?

I tried using Step response measuring but triggering doesn't work well. I used oscA=ctrl_A, Triger source=Channel1, Mode=Normal, Edge Rising and it doesn't catch that ctrl_A rised above triggering level.