Author Topic: sending data to axon through hyperterminal  (Read 2544 times)

0 Members and 1 Guest are viewing this topic.

Offline ukeshTopic starter

  • Full Member
  • ***
  • Posts: 107
  • Helpful? 0
sending data to axon through hyperterminal
« on: December 02, 2009, 09:20:35 AM »
Hello!
I'm trying to send a data to the axon through hyper terminal (UART1). But it doesn't seem to work ??? But the code compiled without an error. Am i doing something wrong?
my code:
Code: [Select]
void control(void)
{
int temp;
rprintf("\n enter the data");
temp=uart1GetByte();//returns -1 if no data present
if (temp==1)//if data received
while(1)
{
servo(PORTE,4,1400);
delay_ms(20);
}
}

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,658
  • Helpful? 169
    • Society of Robots
Re: sending data to axon through hyperterminal
« Reply #1 on: December 02, 2009, 10:51:34 AM »
You have the while loop in the wrong spot. Do this:
Code: [Select]
void control(void)
{
int temp;
rprintf("\n enter the data");

while(1)
{
temp=uart1GetByte();//returns -1 if no data present
if (temp==1)//if data received
servo(PORTE,4,1400);

delay_ms(20);
}
}

Offline ukeshTopic starter

  • Full Member
  • ***
  • Posts: 107
  • Helpful? 0
Re: sending data to axon through hyperterminal
« Reply #2 on: December 02, 2009, 12:18:58 PM »
Tried your code. But doesn't seem to work too. ???

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,658
  • Helpful? 169
    • Society of Robots
Re: sending data to axon through hyperterminal
« Reply #3 on: December 02, 2009, 12:25:14 PM »
Can you define 'doesn't seem to work'?

We can't help if you don't tell us any information :P

Offline ukeshTopic starter

  • Full Member
  • ***
  • Posts: 107
  • Helpful? 0
Re: sending data to axon through hyperterminal
« Reply #4 on: December 02, 2009, 12:38:56 PM »
Code: [Select]
We can't help if you don't tell us any information :PSure ;D
On the hyper terminal, i get enter the data statement. After that when i press 1, and press enter in my keyboard nothing happens. The program just seems to stop there?

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,658
  • Helpful? 169
    • Society of Robots
Re: sending data to axon through hyperterminal
« Reply #5 on: December 02, 2009, 12:56:08 PM »
How do you know nothing happens?

Add a line in your code to reply when it gets data:
Code: [Select]
void control(void)
{
int temp;
rprintf("\n enter the data");

while(1)
{
temp=uart1GetByte();//returns -1 if no data present
if (temp==1)//if 1 received
{
servo(PORTE,4,1400);
rprintf("stuff received");
delay_ms(20);
}

}
}

Offline ukeshTopic starter

  • Full Member
  • ***
  • Posts: 107
  • Helpful? 0
Re: sending data to axon through hyperterminal
« Reply #6 on: December 02, 2009, 11:13:06 PM »
I think the data is not sent to the axon. It gets stuck at the same place of the program

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,658
  • Helpful? 169
    • Society of Robots
Re: sending data to axon through hyperterminal
« Reply #7 on: December 02, 2009, 11:19:21 PM »
Lets just use my code. Put this in the control() function and see if pushing r helps.

Code: [Select]
char temp;
while(1)
{
temp=uart1GetByte();//returns -1 if no data present
if (temp == 'r')//if data received
rprintf("stuff");
}

Offline ukeshTopic starter

  • Full Member
  • ***
  • Posts: 107
  • Helpful? 0
Re: sending data to axon through hyperterminal
« Reply #8 on: December 03, 2009, 03:22:42 AM »
It works ;) And when i try this code it doesnt.
Code: [Select]
void control(void)
{
int temp;
rprintf("\n enter the data");
while(1)
{
temp=uart1GetByte();//returns -1 if no data present
if (temp==1)//if data received
rprintf(" entered no is 1");
}
}
If you dont mind, can you explain why the first code didnt work? you said i placed the while loop statement in the wrong place. In my first code, the axon gets input once and if that input is equal to 1, the servo runs for an infinite time. Am i understanding something wrong?
« Last Edit: December 03, 2009, 04:06:12 AM by ukesh »

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,658
  • Helpful? 169
    • Society of Robots
Re: sending data to axon through hyperterminal
« Reply #9 on: December 03, 2009, 08:06:02 AM »
Quote
In my first code, the axon gets input once and if that input is equal to 1, the servo runs for an infinite time.
In your first code, you have an infinite while loop with the servo code in it. Your code would never exit that while loop to check for a new character.

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,941
  • Helpful? 98
Re: sending data to axon through hyperterminal
« Reply #10 on: December 03, 2009, 08:09:59 AM »
if (temp==1)//if data received

That line is expecting a value of 1 or 0x01. That is an ASCII "Start of Header" or a 'Control A'. Is that the keys you pressed?

The code example that did work used
if (temp == 'r')//if data received
which is expecting the 'r' ASCII character.

Here is info on ASCII:
http://en.wikipedia.org/wiki/ASCII

edit: corrected the 'r' character.
« Last Edit: December 03, 2009, 02:22:44 PM by waltr »

Offline chelmi

  • Supreme Robot
  • *****
  • Posts: 496
  • Helpful? 15
Re: sending data to axon through hyperterminal
« Reply #11 on: December 03, 2009, 09:34:10 AM »
The code example that did work used
if (temp == 'r')//if data received
which is expecting a Carriage Return ASCII character.
'r' is the character r. '\r' is carriage return.

Chelmi.

Offline ukeshTopic starter

  • Full Member
  • ***
  • Posts: 107
  • Helpful? 0
Re: sending data to axon through hyperterminal
« Reply #12 on: December 07, 2009, 11:00:49 AM »
It now works guys. Thanks for pointing me about ASCII code :)

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,941
  • Helpful? 98
Re: sending data to axon through hyperterminal
« Reply #13 on: December 07, 2009, 03:04:01 PM »
Woo Hoo, isn't it a great feeling.

 


Get Your Ad Here