I know the variable types : Single, Double and Float are 'experimental' in GCB. Has there been any further thought of implementing them for math operations (Multiplication, Division)?
Below is code that works in VisualBasic.NET that derives the registers for the SI5351a clock generator. Mostly Unsigned 32 bit integers which GCB can handle, and a float variable (currently N/A in GCB).
I have been told I could use Integer math to do the same thing, but at a loss on how to do it.
' Calc Output Multisynth Divider and R with e = 0 and f = 1 => msx_p2 = 0 and msx_p3 = 1DimdAsUInteger=4Dimmsx_p1AsUInteger=0' If fout > 150 MHz then MSx_P1 = 0 and MSx_DIVBY4 = 0xC0, see datasheet 4.1.3Dimmsx_divby4AsInteger=0Dimrx_divAsInteger=0DimrAsInteger=1Iffout>150000000UIThenmsx_divby4=&HC' MSx_DIVBY4[1:0] = 0b11, see datasheet 4.1.3ElseIffout<292969UIThen' If fout < 500 kHz then use R divider, see datasheet 4.2.2. In reality this means > 292 968,75 Hz when d = 2048DimrdAsInteger=0DoWhile(r<128)AndAlso(r*fout<292969UI)r<<=1rd+=1Looprx_div=rd<<4d=CUInt(600000000UI \ (r*fout))' Use lowest VCO frequency but handle d minimumIf(dMod2)<>0Then' Make d even to reduce spurious and phase noise/jitter, see datasheet 4.1.2.1.d+=1EndIfIfd*r*fout<600000000UIThen' VCO frequency to low check and maintain an even d valued+=2EndIfElse' 292968 Hz <= fout <= 150 MHzd=600000000UI \ fout' Use lowest VCO frequency but handle d minimumIfd<6Thend=6ElseIf(dMod2)<>0Then' Make d even to reduce phase noise/jitter, see datasheet 4.1.2.1.d+=1EndIfIfd*fout<600000000UIThen' VCO frequency to low check and maintain an even d valued+=2EndIfEndIfmsx_p1=CUInt(128*d-512)DimfvcoAsUInteger=CUInt(d)*r*fout' Calc Feedback Multisynth DividerDimfmdAsDouble=CDbl(fvco)/fref' The FMD value has been foundDimaAsInteger=CInt(Math.Truncate(fmd))' a is the integer part of the FMD valueDimb_cAsDouble=CDbl(fmd)-a' Get b/cDimcAsUInteger=1048575UIDimbAsUInteger=CUInt(Math.Truncate(CDbl(b_c)*c))Ifb>0Thenc=CUInt(Math.Truncate(CDbl(b)/b_c+0.5))' Improves frequency precision in some casesIfc>1048575UIThenc=1048575UIEndIfEndIfDimmsnx_p1AsUInteger=CUInt(128*a+128*b \ c-512)' See datasheet 3.2Dimmsnx_p2AsUInteger=CUInt(128*b-c*(128*b \ c))Global_msnx_p2=msnx_p2'For fine tuning WSPR channelsDimmsnx_p3AsUInteger=c
Currently I have to let my VB.NET do the calculation, then I have to store the answers to EEPROM.
I hear floating point math is slow, but speed isn't concern.
Just let me know if GCB will possibly have this capability in the future!
regards,
Jeff
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The current focus is to get the release out and that does not include an enhancement to floats. We know the issues with floats and we dont know when or how to fix yet.
Jon one. Get the release out and that will be a few weeks away. :-)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I know the variable types : Single, Double and Float are 'experimental' in GCB. Has there been any further thought of implementing them for math operations (Multiplication, Division)?
Below is code that works in VisualBasic.NET that derives the registers for the SI5351a clock generator. Mostly Unsigned 32 bit integers which GCB can handle, and a float variable (currently N/A in GCB).
I have been told I could use Integer math to do the same thing, but at a loss on how to do it.
Currently I have to let my VB.NET do the calculation, then I have to store the answers to EEPROM.
I hear floating point math is slow, but speed isn't concern.
Just let me know if GCB will possibly have this capability in the future!
regards,
Jeff
The current focus is to get the release out and that does not include an enhancement to floats. We know the issues with floats and we dont know when or how to fix yet.
Jon one. Get the release out and that will be a few weeks away. :-)
But, I would use the code from this post - https://sourceforge.net/p/gcbasic/discussion/projects&guides/thread/117a0e2636/?limit=250#7872