Let me turn this thread back to track.
It seem all light or sound sensor call "SysComputeCalibValue" any way.
if calibration block used, "SysUpdateCalibCacheInfo" be called.
And I saw "Todo figure out what this function is intended for",
Does this thread mean it will be remove from todo list?
How to calibrate light sensor using nxc?
Re: How to calibrate light sensor using nxc?
I apologize for not working on this subject faster. I did decompile the RXE you posted and saw that it called those two system call functions. I haven't ever wrapped them up in higher level API routines, sadly. But they should work with their associated structures.
I have no idea why it writes 0 and 1023 to the Light Sensor.cal calibration cache file. Perhaps there are uses of this block that result in different values being written to the cache.
John Hansen
Code: Select all
a00E8 byte[] 'Light Sensor'
// ...
getin [b]uw002D[/b], ub006D, NormalizedValue
mov c00BE.a00C0, a00E8
mov c00BE.uw00C2, [b]uw002D[/b]
syscall ComputeCalibValue, c00BE
mov [b]uw002D[/b], c00BE.uw00C2
Code: Select all
sw001D sword
sw001E sword 1023
// ...
a00D6 byte[] 'Light Sensor'
a00D8 byte[] 0x0
// ...
mov c0086.a0088, a00D8
mov c0086.uw008A, sw001D
mov c0086.uw008B, sw001E
syscall UpdateCalibCacheInfo, c0086
John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
http://bricxcc.sourceforge.net/
Re: How to calibrate light sensor using nxc?
0 and 1023 is default calibration value(AKA no calibration). They are the min and max value of raw.
In calibration mode, the block will read the raw value of sensor, and set it to min or max position of calibration cache.
And the cache will be set to 0 and 1023 if calibration "delete" be selected.
PS:I known you working hard on EV3, and I expect it.
In calibration mode, the block will read the raw value of sensor, and set it to min or max position of calibration cache.
And the cache will be set to 0 and 1023 if calibration "delete" be selected.
PS:I known you working hard on EV3, and I expect it.
Re: How to calibrate light sensor using nxc?
I would love to plug in some NXC light sensor calibration and read calibrated value functions into the official API headers and online documentation if anyone (hint, hint) wanted to provide me with some nice ones.
I am trying to focus pretty much exclusively on EV3 stuff so that I can get as much done as possible by launch, which is getting closer every day.
John Hansen
I am trying to focus pretty much exclusively on EV3 stuff so that I can get as much done as possible by launch, which is getting closer every day.
John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
http://bricxcc.sourceforge.net/
Re: How to calibrate light sensor using nxc?
I'm actually not sure what this topic is about or where or what the problem is.
is it about getting the most bright sensor value and the most dark sensor value and the current sensor value in between in percent related to the difference?
Why would one need an API function for that?
v: current ADC_raw
low: min test-range ADC_raw
high: max test-range ADC_raw
vpercent=100*(v-low)/(high-low)
or what am I missing?
(ceterum censeo:
On the other hand, a API function that is really missing since many years, right from the start, is a
providing data traffic transmission control (and -correction) in order to daisy-chain NXTs, pass local variables of any data type (even different arrays[250] of float or integer!) to remote NXTs (and call them back) and being able to use all remote I/Os at any NXT as if they were local )
is it about getting the most bright sensor value and the most dark sensor value and the current sensor value in between in percent related to the difference?
Why would one need an API function for that?
v: current ADC_raw
low: min test-range ADC_raw
high: max test-range ADC_raw
vpercent=100*(v-low)/(high-low)
or what am I missing?
(ceterum censeo:
On the other hand, a API function that is really missing since many years, right from the start, is a
comfortable, easy + trouble-free network & remote control for rs485, Xbee, BT, USB
providing data traffic transmission control (and -correction) in order to daisy-chain NXTs, pass local variables of any data type (even different arrays[250] of float or integer!) to remote NXTs (and call them back) and being able to use all remote I/Os at any NXT as if they were local )
Re: How to calibrate light sensor using nxc?
You are right. But.....v: current ADC_raw
low: min test-range ADC_raw
high: max test-range ADC_raw
vpercent=100*(v-low)/(high-low)
Lego firmware provided a "calibration mechanism", so user doesn't care the min or max raw value things when they using light or sound sensor.Just put a sensor block.Or put a calibrate block at the beginning if they want to calibrate. And NOTHING changes in code except adding calibrate block.
And you code is the SysComputeCalibValue doing exactly.
Let me explain the implementation of SysComputeCalibValue and SysUpdateCalibCacheInfo in lego firmware. Actually, I want to provide some words for document, but you guys known my english level .I would love to plug in some NXC light sensor calibration and read calibrated value functions into the official API headers and online documentation if anyone (hint, hint) wanted to provide me with some nice ones.
1.Threre are two places to store calibration data. One is in the file system naming "Sound sensor.cal" or "Light sensor.cal", the other one in the memory loading from file when program start.
2.There are only two values for each calibration data -- min raw value and max.
3.SysUpdateCalibCacheInfo will update the calibration data in memory.
4.The SysComputeCalibValue, do something like doc-helmut 's code. Find the calibaration data, then calculate the scale value using the min or max raw value . The min and max will be 0 and 1023 if calibration data don't exist.
5.That's all almost.
6.In NXT-G, a calibration block changes only one value of calibration data, min or max. But SysUpdateCalibCacheInfo needs them two. How to get another one? There isn't a SysGetCalibCacheInfo.
So,NXT-G read it from file directly, then update the cache and write back the file.It's silly and slow.
User will get the same sensor value from NXC and NXT-G , if ScaleValue for light or sound is calibrated in NXC.
Who is online
Users browsing this forum: Semrush [Bot] and 0 guests