How to limit ranges on FRQB in spin.
T Chap
Posts: 4,223
PUB iTRipSet(tr) | f Dira[CurrentTripSetPin]~~ outa[CurrentTripSetPin]~ ctrb := %00110 << 26 + CurrentTripSetPin repeat f := (TripLevel * TripLevelBias) - (tempnew * TempBias) if f > 0 ' filter if negative, if positive then limit min f #>= 500_000_000 frqb := f ' REF output voltages 'frqb := -1 '3.265V 4.294B 'frqb := -2_147483646 '1.655V 2.147B 'frqb := 2_147483647 '1.655V 2.147B 'frqb := 0 '0.000V 0
I know I have posted on this before, but still cannot get my head wrapped around this issue to solve it.
The minimum output of the frqb needs to be 500_000_000 and the code solves that no matter what values the method is receiving. The problem comes from when the frqb rolls over from -1 to anything above. I tried added another line that says
if f < -1
set the max f to -1 to create a cap.
Didn't work, it faulted anyway, maybe the limit max to -1 doesn't behave as I though in this case.
The reason is the DAC output maxes out at 3.265V at f = -1. If the code feeding the method exceeds -1, the voltage drops back to 0, and faults out the system.
I would appreciate if someone could point out a way to limit f to a max of -1, but at the same time allow values to range from 0 to 2.147B?
The values for F need to range from 5_000_000 to 4.294B (-1) only.
Thanks!
Comments
This has the effect of forcing the min and max operators to act on unsigned longs.
-Phil
Thanks Phil, I assume you intended me to set the fmin and fmax to the desired range. In this case above, I set fmin to the lower level DAC output of 500_000_000 and fmax to $8000_0000, but it still is rolling over past 3.2V to 0 and above, ignoring the cap. Maybe I didn't implement the fmin and fmax correctly, I clearly do not get the XOR use here.
-Phil
I think this is what you mean to do if I want the minimum output to be 500_000_000 and the max to be 4.2B or -1.
I will try this at the shop tomorrow.
-Phil
Still no luck, the DAC output (math) blows past 3.265V and starts back up at 0v and faults out because the DAC is too low. It appears that minimum is fine as it only crashes when setting the trip level at a point so that the math can roll over frqb of 0. If the min value was not operating, the system would fault out on bot. Any suggestions appreciated.
$ffff_ffff should be -1 right? I need some way to limit max the frqb to avoid rolling back over to 0v output.
-Phil
Tempnew*tempbias is always positive, and is always subtracted from the first set of values, but is always a small value in comparison.
-Phil
Answered before asked!
Another thought: do you really need 32-bit presicion in frqb? If not, why not set the bias values to produce lower numbers for f, then shift it left when assigning it to frqb?
-Phil
Thanks for the assistance, your last inquiries set me on the path to see the problem.