Welcome, Guest. Please Login.
Surveyor Corporation Surveyor SRV-1
Home Help Search Login

Surveyor Robotics Forum

Welcome to the user support forum for Surveyor SRV-1 robots, SRV-1 robot controllers and SVS stereo vision systems. To register for this forum, please send an email to support@surveyor.com which includes your desired forum user name, your registration email address, and a brief explanation of why you wish to join, and we will create a forum account for you.

Please note that there is a Search button in the forum toolbar for forum topics. Another effective search method for the entire surveyor.com site is to use Google, e.g. "xyz site://www.surveyor.com" where "xyz" is the search topic.



Pages: 1
Send Topic Print
Interfacing a Digital Temperature Sensor (Read 2322 times)
dlb04001
YaBB Newbies
*




Posts: 10
Interfacing a Digital Temperature Sensor
02/12/08 at 8:12am
 
I currently have the ARM7 board, and I want to add a temperature sensor to it. I chose the Analog Devices TMP03 due to its relatively low power consumption, and the cool feature of digital modulation- it outputs a pulse with a width directly proportional to the temperature measured. Being new to this whole SRV thing, I was wondering if a) connecting it to the open UART port would be reasonable, and b) how complicated would it be to get the temperature information sent from the robot to the base computer?
Back to top
 
 
  IP Logged
admin
YaBB Administrator
*****




Posts: 3676
Re: Interfacing a Digital Temperature Sensor
Reply #1 - 02/12/08 at 8:20am
 
If it's PWM, you just need to connect to a GPIO pin and add some code to measure the pulse width.  I just did this with the Blackfin board and ADXL202E accelerometers that likewise generate a PWM waveform.
Back to top
 
 

SRV-1 Development Team
Surveyor Corporation
Email WWW   IP Logged
atl03001
YaBB Newbies
*




Posts: 26
Re: Interfacing a Digital Temperature Sensor
Reply #2 - 04/06/08 at 1:15pm
 
I just soldered a digital temp sensor to pin 6 on the LPC board, which corresponds to P0.5. I put this code in utils.c to read the value of P0.5:
 
//Read Pin 5 for temp sensor
unsigned char P05_read()  
{
     return (unsigned char)((IOPIN0 & 0x00000020) >> 5);
}
 
since I saw that was how the other pins were read. After adding another case, I called GetTemp to measure the pulse width of the temp sensor (see below), and everything kept freezing. I couldn't find anything on initializing p0.05, so do I have to initialize P0.05 as an input, or is it one by default?
 
int GetTemp(void) {
 
     unsigned char a;
     unsigned int b;
     int T2 =0;
     int T1=10; //T1 is 10 ms for temps < 75 C
 
     
     //wait until 1 in P05 (T1 is high)
     do { a = P05_read(); }
     while(a==0);
 
     //wait for 0 to read values (T2)
     do { a = P05_read(); }
     while(a==1);
 
     //for 25 ms, which is max length of T2
     for (b=0;b<25;b++)  
     {
 
           a = P05_read();
 
           if(a!= 1)  
           {  
           T2++;  
           }
 
           delayUs(1000);      //delay 1 ms
     }
 
     //Do math to find Temp in degrees F: T=455 - (720*T1)/(T2)
     T1=720*T1;
     T1=T1/T2;
     T1=455-T1;
 
     return T1;
}
Back to top
 
 
  IP Logged
admin
YaBB Administrator
*****




Posts: 3676
Re: Interfacing a Digital Temperature Sensor
Reply #3 - 04/06/08 at 2:21pm
 
Yes - you have to set the GPIO pin direction using the IODIR0 register.  If you take a look at http://www.surveyor.com/srvdownload/srv-053007.zip in utils.c, you will see example code in bits_dir() on how to set the i/o bit directory.  I am fairly certain that setting the respective bit to 0 makes it input, 1 makes it output.  I believe you need to clear the output values as well.
 
So, for p0.05,  
 
PINSEL0 &= 0xFFFFF3FF;    // should program p0.05 for GPIO
IOSET0 = 0x00000020;     // should clear p0.05
IODIR0 &= 0xFFFFFFDF;     // should set p0.05 to input
 
Then you read IOPIN0 & 0x00000020
Back to top
 
« Last Edit: 04/06/08 at 2:24pm by admin »  

SRV-1 Development Team
Surveyor Corporation
Email WWW   IP Logged
Pages: 1
Send Topic Print