View previous topic :: View next topic |
Author |
Message |
chek2020
Joined: 23 Apr 2006 Posts: 4
|
send serial output to infra red terminal |
Posted: Sun Apr 23, 2006 7:58 am |
|
|
hai, i need somebody can give me some technical help.
i am using PIC16F716 interface to get input digital temperature sensor(DS1820) to terminal infra red.
the problem now is how i going to send my temperature data to infra red?
#define TX PIN_B3
....
long temperature;
long temp;
int CountPerC, CountRemain;
.....
temp=(((temperature>>1)*100)-25)+(((CountPerC-CountRemain)*100)/CountPerC);
TX == temp; //send data to terminal infra red, but this line no work!
....
is it the correct way? but sound that i dun have any responce output. please guide me. |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Sun Apr 23, 2006 8:10 am |
|
|
You need to better describe your hardware. A pin is a single bit. Obviously you can't assign a long to this pin. If you need to send more than 1 bit of data with only 1 pin then you would probably do this serially in which case the transmit pin would go high/low for certain durations in order to represent the 16 bit value (long) that you are trying to send. The duration is known as baud rate. You haven't given us any information on how the data is transmitted or received except to say infrared. That isn't enough. |
|
|
new bies Guest
|
more desription about my hardware and others |
Posted: Sun Apr 23, 2006 8:27 am |
|
|
Hai, thank for so fast responding.
basically, let me briefly tell what is my hardware is going what to do.
first, i will get temperature sensor (DS1820)data to PIC16f716. from there it will convert the temp for me and transmit data to infra red. the process is keep instantly send to infra red(real time).
here i show my code here.
i have simply modify the code from this site. hope i am rite.
http://www.ccsinfo.com/forum/viewtopic.php?t=18984
#include <16F716.h> // header file for the PIC16F716
#DEVICE ADC=8 // tell compiler the ADC is 8-bits
#use delay(clock = 40000000) // specify the clock frequency of the PIC
#use rs232(baud=9600, xmit=PIN_B3, rcv=PIN_B2) //set up SERIAL PORT on USART2
#define TX PIN_B3
#define RX PIN_B2
#fuses HS,NOWDT,NOBROWNOUT
#include "pic16F716definition.h"
#BIT DQin = PIN_A0.0 //1-wire input
#BIT DQout = PIN_A0.1 //1-wire output
#include <string.h>
#include "1wire.h"
void main(){
/*----------configure all the ports-------*/
char tempString[9];
long temperature;
long temp;
int CountPerC, CountRemain;
int address[8];
address[0] = 0x10;
address[1] = 0xD6;
address[2] = 0x26;
address[3] = 0x2E;
address[4] = 0x00;
address[5] = 0x08;
address[6] = 0x00;
address[7] = 0xFA;
/*----------configure all the ports-------*/
ADCON1_ADDR = 0x009F;
// 00010101
set_tris_a(0x15); //make DQin and input and DQout and output
#asm
clrwdt
#endasm
delay_ms(1000);
For (;;){
convertTemps(); //initialize bus and start converting
while (DQout == 1); //wait for conversion to finish
init1820(); //initialize sensor
write1wire(MatchROM); //address particular sensor
writeAddress(address);
write1wire(Read9Bytes); //issure read scratchpad command
temperature = 0;
temperature = read1wire(); //read the temperature from the sensor
read1wire(); //ignore next 2 bytes
read1wire(); //ignore next 2 bytes
temp = read1wire();
CountRemain = *(&temp); //Store countRemain
CountPerC = *(&temp+1); //store countPerC
temp=(((temperature>>1)*100)-25)+(((CountPerC-CountRemain)*100)/CountPerC);
TX == temp; //send data to terminal
delay_ms(2000);
}
}//main |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Sun Apr 23, 2006 8:06 pm |
|
|
Read my first sentence again.
Mark wrote: | You need to better describe your hardware. A pin is a single bit. Obviously you can't assign a long to this pin. If you need to send more than 1 bit of data with only 1 pin then you would probably do this serially in which case the transmit pin would go high/low for certain durations in order to represent the 16 bit value (long) that you are trying to send. The duration is known as baud rate. You haven't given us any information on how the data is transmitted or received except to say infrared. That isn't enough. |
|
|
|
chek2020
Joined: 23 Apr 2006 Posts: 4
|
more desription |
Posted: Sun Apr 23, 2006 11:40 pm |
|
|
Hai,
baud rate i use is 2400(mistake from the code,i put as 9600). The data just transmit in binary(ASICC form) to infra red.
from this line:
temp=(((temperature>>1)*100)-25)+(((CountPerC-CountRemain)*100)/CountPerC);
i should get my temp data variable. eg "29" degree
my objective is send this "29" to transmit pin
i understand my code should not put as
TX == temp; //send data to terminal
but i am confuse how i going to send bit by bit corresponce on "29" to terminal.
any sample code for let me refer?
hope this is the information that you want.
thank |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Mon Apr 24, 2006 1:31 am |
|
|
Quote: | but i am confuse how i going to send bit by bit corresponce on "29" to terminal. | This is what we are confused of too. Mark already asked you, but I'll ask it again in other words: what electronics have you connected to your TX pin? |
|
|
chek2020
Joined: 23 Apr 2006 Posts: 4
|
what electronics have you connected to your TX pin? |
Posted: Mon Apr 24, 2006 2:06 am |
|
|
Hai, i am using PIN_B3 as my TX pin.
this TX pin will send a serial bit(data) in binary form to RS232 TX port and then to infra red terminal.
the main concern is the temp(variable) data that i get and send this temp(variable) to TX pin.
thank |
|
|
arunb
Joined: 08 Sep 2003 Posts: 492 Location: India
|
RE: |
Posted: Mon Apr 24, 2006 3:02 am |
|
|
Hi,
Kindly post a circuit diagram...
thanks
arunb |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Mon Apr 24, 2006 3:50 am |
|
|
chek2020 wrote: | this TX pin will send a serial bit(data) in binary form to RS232 TX port and then to infra red terminal. | Let me see if I understand this correctly: You have some external device that uses RS-232 for input and infra red as output? We have seen several devices in this forum some are easy to use while others are more difficult, that's why we are hammering on getting more details of your hardware setup. Can you give us a schematic, manufacturer's name or any other more detailed info on your infra red hardware? |
|
|
chek2020
Joined: 23 Apr 2006 Posts: 4
|
|
Posted: Mon Apr 24, 2006 11:39 am |
|
|
hai,
basically, the circuit diagram is similiar with this http://www.anotherurl.com/therm/graphics/Arbiter_sch2.gif
and http://www.anotherurl.com/therm/images/diagrams/ARBITER.gif but PIC16F716 is instead of using PIC16F84. The rest just using same component. In this stage i just try on just only 1 sensor.
my operation is such that collect temperature and transmit the measurements via wireless(infra red).
Sorry, i was unable to upload my circuit diagram for infra red and others detail due to i dunno where should i to be upload to which http. Anyway, temperature sensor is from dallas 1820 and PIC surely from microchip.
About "You have some external device that uses RS-232 for input and infra red as output?"
my answer is yes. RS232 as a medium to PIC and infra red.
Regarding to my internal infrared circuit. i confirm there was no problem. Because several checking is perfect.
my main question is how to do so that the PIC is sending serial data bits to TX port of RS232.
hope this make you more understand.
thank. |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Mon Apr 24, 2006 12:05 pm |
|
|
printf("%Lu", temp);
should be enough.
Humberto |
|
|
|