RAW to percentage/temperature
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
RAW to percentage/temperature
What is the math performed by the firmware to convert RAW analog input values into percentage and temperature?
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
Re: RAW to percentage/temperature
By temperature do you mean the old RCX temp sensor? Every thermistor will have a different rate of change and so there isn't a "one size fits all" equation. And to get a raw vs. percentage equation just grab a potentiometer and a simple program that will log raw and percentage values every hundred ms or so and slowly rotate the pot at a constant rate. Then graph it with a spreadsheet program. You should be able to figure something out from that.
One King to rule them all, One King to find them,
One King to bring them all and in the darkness bind them
On Earth where Shadows lie.
One King to bring them all and in the darkness bind them
On Earth where Shadows lie.
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: RAW to percentage/temperature
Yes, the equation used for the RCX Temp sensor (10k thermistor in series with a 2k2 resistor). I know I could compare the percentage to the RAW, but I figured that there are probably just a couple simple formulas that are used to get the values. And I do know that all thermistors have differing specs. BTW, how do you plot on a graph (what programs and such are needed)?
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
Re: RAW to percentage/temperature
The book "Extreme NXT" has a graph that compares temperature (from RCX Legacy sensor) and raw value. I think it also has a graph that compares raw and percentage values. I'm sure that with a bit of basic algebra you could figure out a equation that would convert raw to percentage, and with something slightly more advanced you could get the equation for temperature.
-EDIT- Oh and for graphing programs I use MS Office "Excel" in Windows and Open Office "Spreadsheet" in Ubuntu. I actually prefer Open Office 'cause it's just that, open. Which also means it's free. But if you don't want to download anything to your computer, Google Docs might work.Never used it though, so I'm not 100% sure. Ok, second edit . I checked out Google Docs and if you have a better-than-dialup internet connection, it should work for charts/graphs whatever.
-EDIT- Oh and for graphing programs I use MS Office "Excel" in Windows and Open Office "Spreadsheet" in Ubuntu. I actually prefer Open Office 'cause it's just that, open. Which also means it's free. But if you don't want to download anything to your computer, Google Docs might work.
One King to rule them all, One King to find them,
One King to bring them all and in the darkness bind them
On Earth where Shadows lie.
One King to bring them all and in the darkness bind them
On Earth where Shadows lie.
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: RAW to percentage/temperature
Ok, thanks for the help. BTW though, I would like it if someone had the actual formula.
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
Re: RAW to percentage/temperature
Percentage is fairly easy:
p_val = (raw_val * 100) / 1023;
where raw_val is a value from 0-1023, without normalisation (this is important). The FW will normalise certain sensor raw values, like the light and sound sensor because their values never reach the full range. Perhaps this is not the case for sensors configured as RCX raw or whatever. It should be easy to test this with a simple pot meter
I don't know what the formula is for the resistance/temp conversion but the above should help you.
Regards,
Xander
p_val = (raw_val * 100) / 1023;
where raw_val is a value from 0-1023, without normalisation (this is important). The FW will normalise certain sensor raw values, like the light and sound sensor because their values never reach the full range. Perhaps this is not the case for sensors configured as RCX raw or whatever. It should be easy to test this with a simple pot meter
I don't know what the formula is for the resistance/temp conversion but the above should help you.
Regards,
Xander
| My Blog: I'd Rather Be Building Robots (http://botbench.com)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: RAW to percentage/temperature
That formula just scales the RAW values into a 0-100 range. I know that technically, that IS percentage. What I want is the range used by the light sensor etc., or IS it that simple (linear, and covers the entire RAW range)? I guess I'll have to try it out. To get resistance, I think that will give me ohms from RAW (according to the extreme NXT book, and it seems logically correct).
Code: Select all
R = (10,000*Raw)/(1023-Raw)
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
Re: RAW to percentage/temperature
This is what I use in my ROBOTC driver for a calibrated light sensor:
Where lslow is the minimal value the light sensor will have and lshigh is the top end. This is called normalisation. It will also return a value from 0-100.
- Xander
Code: Select all
/**
* Read the normalised value of the Light Sensor, based on the low and high values.
* @param link the Light Sensor port number
* @return the normalised value
*/
int LSvalNorm(tSensors link) {
long currval = 0;
_LScheckSensor(link);
if (!legols_calibrated) {
_LSreadCalVals(lslow, lshigh);
}
currval = LSvalRaw(link);
if (currval <= lslow)
return 0;
else if (currval >= lshigh)
return 100;
return ((currval - lslow) * 100) / (lshigh - lslow);
}
- Xander
| My Blog: I'd Rather Be Building Robots (http://botbench.com)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: RAW to percentage/temperature
Ok, that makes sense. Thank you.
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
-
- Posts: 323
- Joined: 29 Sep 2010, 05:03
Re: RAW to percentage/temperature
Hi Matt,
Why not grab the source for the firmware and take a look. Judging by your other posts I think you would find it interesting and although the code is a little strange it's not that hard to understand...
Andy
Why not grab the source for the firmware and take a look. Judging by your other posts I think you would find it interesting and although the code is a little strange it's not that hard to understand...
Andy
Who is online
Users browsing this forum: No registered users and 3 guests