Jump to content
OMRON Forums

Gathering a single 12-bit value ("Y:$78005") using VB.NET from HMI


Sergio

Recommended Posts

I am using a PMAC turbo without DPR. A HMI written in VB.NET is used to setup various recipes parameters and also to collect cycle data. I have setup Data Gathering to collect position and following errors along the cycle. It is all working fine as shown on the cycle plot attached. The problem I am having is to add gathering for an analog input value that is defined as [color=#FF0000][b]M105->Y:$78005,12,12,S (only 12 bits)[/b][/color] I use the following routines from PcommServer: PcommServer.SetGather(_deviceNumber, 16, "Y:$78005", True, bStatus) Once the HMI is notified that data is avaialble I get the data as follows: PcommServer.CollectGatherData(_deviceNumber, iNumSources, iNumSamples, bPmacStatus) iUpperBound = iNumSamples - 1 ReDim AnalogInput1(iUpperBound) PcommServer.GetGatherSamples(_deviceNumber, 16, AnalogInput1, bStatus) AnalogInput1 is defined as a Double in VB which is 8 bytes. The question is:: How do I unpack the value being returned by GetGatherSamples – AnalogInput1 which is 8 bytes. I have tried all sorts of masks but I am not getting the correct value (If I just poll the M105 values with calls to GetResponseEx I get the correct values so I know the input is good. I must be doing something wrong with my mask. The latest I have tried is: Ai1(iSample) = AnalogInput1(iSample) And &HFFFFFF (get the lower 3 bytes) Thanks
Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

Sergio, I'm not sure this would be helpful for you or not since it is in C#, but I was reading some data from gather buffer and here is an extract from my code: [code] Pmac.GetResponseEx(m_nDevice, "END GAT", false, out response_str, out response_int); // Getting the gathered data back Pmac.CollectGatherData(m_nDevice, out pSources, out pSamples, out bSuccess); object firstset = null; object secondset = null; Pmac.GetGatherSamples(m_nDevice, 0, ref firstset, out bSuccess); Pmac.GetGatherSamples(m_nDevice, 1, ref secondset, out bSuccess); double[] PhasePos = (double[])firstset; double[] FltrVelocity = (double[])secondset; [/code]
Link to comment
Share on other sites

Thanks Sina. The problem was that the value I wanted was M105->Y:$78005,12,12,S and I though that GetGatherSamples would return the value without any offset on the referenced parameter. If turns out that GetGatherSamples return the value with the 12 bit offset as well. The solution was just to shift the returned value 11 bits to the right.
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

×
×
  • Create New...