Analog Output always jumps to 10V
floesche opened this issue · 1 comments
The issue was mostly discussed via email. Here a reconstruction for future reference:
Initial error description (Us):
We’re having a little trouble getting the AO functionality to work in at least one version of the G4 controller. We’re still checking a few things to have a better idea of where the error comes from (possibly our code, TBD), but I have two quick questions that would be helpful for understanding:
Can you remind us of what the dedicated role of AO0 and AO1 are? AO0 clearly shows the X position encoded as a voltage. Does AO1 have a dedicated role? We have some confusion about which is the ‘first’ AO channel that we can directly control with AO functions.
The behavior we see is that as soon as we start sending commands to run the display to your panel host, the AO channels (other than AO0) jump up from 0V to 10V. Does this make sense to you? is this a clue for what the problem might be? It can’t be as simple as a problem with the format of our AO functions since this happens on all channels I looked at.
Re (Host Dev):
Re Re (Us):
AO0 reports the X position
A01 and A02, A03, A04, A05 all jump up to 10V. A06 and AO7 do not.
Does this offer any clue?
Also on this system, which we use for some long-running experiments, we’re using the .242 version. Do you have any reason to think for troubleshooting this issue alone, we should install one of the newer builds?Just a few more related questions so we can get to the bottom of this:
- Should the format for analog output functions (.afn) files be identical to position functions or does something need to be different since the AOs can be negative and positive?
- Here is an example of the test experiment I ran the other day (sending functions to all 4 AO channels). In this version we were using the ‘combined command’. Can you remind me what the frame rate / FPS relates to? IS this for the constant velocity mode or does it have anything to do with AO functions?
Re Re Re (Host Dev):
I ran a test on my machine and was getting a constant 10 Vs for AO1 (Y position) when there is only 1 Y position in the pattern so I am assuming that is what is happening when you run it as well. You should see it change if you are running multiple Y positions. I do see the voltages changing for AO2-AO5 so you might want to check your AO function files. You can also send me those files as well.
- Pretty much, the voltage range for -10 to 10 v is equal to -32768 to 32767.
- FPS set the frame rate for the "Constant Rate Playback" mode. So it doesn't have any effect if you are not using that mode. The AO functions are outputted at 1kHz.
Re Re Re Re (Us):
Thanks for the update, very helpful. Which version of the panel host are you currently testing with?
For the binary data, can you remind me if it’s just sign bit or 2’s complement for the negative data.
Re Re Re Re Re (Host Dev):
It should be 2s complement for negative.
An I16 has a range of -32768 to 32767 which will then scale to -10 to 10 Volts.
Ex. The software sends 16000 which is approximately 4.88V. If you break it down to bits 00111110 10000000, the low byte is 128 and the high byte is 62. Once you join them together you will get 16000.
Ex. The software sends -16000 which is approximately -4.88V. If you break it down to bits 11000001 10000000, the low byte is 128 and the high bytes is 193. Once you join them together you will get -16000.
I built version 248 to look at the current AO output on the front panel.
Re Re Re Re Re Re (Us):
This is very helpful. I’m not sure the data format is the problem, since it used to work before, and we have this problem across channels including the ones we are not using, but this will be super helpful for troubleshooting next week.
Re Re Re Re Re Re Re (Host Dev):
You can try an older version as a sanity check. I can send you a link to an older version if you don't have one.
Re Re Re Re Re Re Re Re (Us):
I ran into another issue when trying to debug the problem: Whenever I start the log and then include the "Set Active Analog Output Channels" [0x2 0x11] command, G4 host hangs.
For example, I sent the "Set Active Analog Output Channels" with channel 4, I get the correct response "Active Analog Output Channel Value 4 Set" from G4 host via TCP (G4 host window shows: "Set Active Analog Output Channels received").
When I then run "Start Display" [0x3 0x21], the TCP become unresponsive and the G4 Host window shows "Error: TDMS Advanced Synchronous Write in Advanced TDMS Writes.vi->TDMS Log Module.vi->Logging Loop(TDMS).vi->Main Host.vi" several times.
In that case the TDMS log contains the 0x2 0x11 command, but not the 0x3 0x21.
Attached a screenshot of the G4 Host window.
I tried different versions of G4 Host (240..248), the description is based on my latest v248 observation.
I also saw the issue on several machines.
Can you check if you see a similar issue? Do you have an idea for a fix or workaround?
Re Re Re Re Re Re Re Re Re (Host Dev):
I don't see that error, but I do see some backlogging of the AO output so that may be related. Let me resolve that and then I'll send you a new build.
You set the Active Analog Output channels, but did you also set the analog output functions?
Re Re Re Re Re Re Re Re Re Re (Us):
yes.
I tried it in both orders and will debug that in more detail later (once the logging works).
The examples I sent you was the minimal example that breaks the G4 Host.
We’re just discussing this as a group right now…so we haven’t yet been able to get the analog output functions working, so the plan for now is:
@floesche will run a super simple test with minimal dependencies on any of our code and then send you his code and the files he’s using so you can see what we’re trying…hopefully by end of today.
We’d appreciate it if you could send us one of your analog output functions (.afn files) so we can check how yours are formatted. Any small scripts, etc you are using for testing that you can share today might also help!please find attached 3 MATLABscripts with minimal dependencies. They basically call directly the TCP commands. You will need pnet and the dec2char.m (included in the package).
The scripts also require the c:\matlabroot\G4Debug folder (also included in the package).
AnalogOutputDebug01.m script replicates the error I described yesterday.
AnalogOutputDebug02.m script removes the "start log" command and works well on my machines.
AnalogOutputDebug03.m It attempts to set the voltage on channel 3 to 5 volts (using the Analog Output Function), but doesn't do that on my my setup with the oscilloscope attached. I can't activate the log (see AnalogOutputDebug01.m).
Can you please have a look at the scripts and see if they work for you or what we need to change to get it to work?
Re Re Re Re Re Re Re Re Re Re Re (Host Dev):
Re: AnalogOutputDebug01.m script replicates the error I described yesterday.
- So the issue here is that the "Start Log" command creates the files based on the active AO channels so if you activate the AO channels after the "Start Log", they won't be created. So you have to send those AO commands before starting the log or I could create all the AO files and they will be empty if you don't activate the channels if you want to go that route.
Re: AnalogOutputDebug03.m It attempts to set the voltage on channel 3 to 5 volts (using the Analog Output Function), but doesn't do that on my my setup with the oscilloscope attached. I can't activate the log (see AnalogOutputDebug01.m).
- We have the same issue with the "Start Log" command coming before the AO commands
- I think there is some confusion here with the channel assignments. The active channels refer to the four AO function channels, but not the actual physical channel number. So analog output function channels 0-3 correspond to AO2-AO5. You set the active analog output channel command to 3 which will activate channel 0 and 1 (AO2 and AO3). Then you set the "Output Function ID" channel to 3 which corresponds to AO5 when you should have set it to 1 if you wanted to because channel 1 is AO3.
Set Active Analog Output Channels 0x2, 0x11, Active Analog Output Channels Set the activeanalog output channels for FPGA playback. First 4 bits represent the active channels
0001 - Active Channel 0
0010 - Active Channel 1
0100 - Active Channel 2
1000 - Active Channel 3
0011 - Active Channel 0 and 1
...
1111 - Active Channel 0,1,2,3
Set Output Function ID 0x4, 0x31, Analog Output Channel, Output Function ID LO, Ouput Function ID HI Set the analog output function for the specified channel. Analog Output Channel = 0-3. Output Function ID = 1-65535.- The other issue was the output function was setting all the values to 10 volts instead of 5. I attached a file that sets it to 5 volts.