I'm writing C# application and I switch from KFlop to Kogna.
To refresh my GUI I have a timer to ask MainStatus each 250ms. I always can read axis position/destination, but how can I get kogna's bit?
I need to read bit from 218 to 223 (EX_IO8 to EX_IO13)
As workaround I could use ReadBit command, but I would like to use MainStatus to use the same mechanism used with Kflop.
Thanks
Raffaello
Re: KOGNA read I/O bit from main status
Posted: Tue Dec 05, 2023 11:03 pm
by TomKerekes
Hi Raffaello,
You should be able to use the GetBitState200 method for getting bits 200 through 289 from the Main Status Record.
public int GetBitState200(int index)
{
return GetValue(MainStatus.BitsState200[index - 200 >> 5], (index - 200) & 0x1F, 1);
}
but I always get the wrong value. I have put a break point when I ask for a new status end I observ that the value of MainStatus.BitState[] and MainStatus.BitState200[] are identical.
I'm using the DSPKOGNA.out from 5.3.1
Thanks
Raffaello
Re: KOGNA read I/O bit from main status
Posted: Thu Dec 07, 2023 6:40 pm
by TomKerekes
Hi Raffaello,
That would be the result if the correction was not made. There were 2 corrections. The other was this:
/// <summary>
/// Bulk status record Current KFLOP/Kogna 64 IO Bit states
/// Kogna - 90 bits 200-289 of state lsb=I/O bit200
/// </summary>
public int[] BitsState200
{
get
{
return MainStatus.BitsState;
}
}
/// <summary>
/// Bulk status record Current KFLOP/Kogna 64 IO Bit states
/// Kogna - 90 bits 200-289 of state lsb=I/O bit200
/// </summary>
public int[] BitsState200
{
get
{
return MainStatus.BitsState200;
}
}
public int Enables => MainStatus.Enables;
public int AxisDone => MainStatus.AxisDone;
public int[] BitsDirection => MainStatus.BitsDirection;
public int BitsDirection200 => MainStatus.BitsDirection200;
public int BitsDirection280 => MainStatus.BitsDirection280;
public int[] BitsState => MainStatus.BitsState;
public int[] BitsState200 => MainStatus.BitsState200;
public int PinMuxModes => MainStatus.PinMuxModes;
Attached is a corrected KM_MainStatus.cs file. Are you able to recompile KMotion_dotNet?
I recompiled KMotion_dotNet project with this KM_MainStatus.cs to get a new KMotion_dotNet.dll that I use in my project.
When I decompile the new dll to check if the two modification are applied I can find both.
How you can see (I hope the link works ), the BitStates200[] is a 2 elements array (in your video was 3 elements) and it is equal to BitState[]
So, should be my recompilation dosen't work fine
Raffaello
Re: KOGNA read I/O bit from main status
Posted: Fri Dec 08, 2023 7:01 pm
by TomKerekes
Hi Raffaello,
It seems it is somehow still using an old binary. One thing I sometimes do is delete the new binary to see if I indeed get a dll not found error as a sanity check.
I don't understand why you look at decompiled code rather than the actual source code.
Re: KOGNA read I/O bit from main status
Posted: Fri Dec 08, 2023 11:07 pm
by Moray
Rather than delete files, I often just add a random letter to the filename.
I keep all my old KMotion installs, but just add an x to the end, that way if I've still got something pointing to the wrong directory I quickly know about it, but I still have access to all the files in case there is something I've forgotten to copy over.
Re: KOGNA read I/O bit from main status
Posted: Mon Dec 11, 2023 2:40 pm
by TorRaf
Hello,
in the source file BitState200[] is a three elements array