Author Topic: hyper terminal hexa  (Read 12496 times)

0 Members and 1 Guest are viewing this topic.

Offline benjiTopic starter

  • Supreme Robot
  • *****
  • Posts: 830
  • Helpful? 0
hyper terminal hexa
« on: April 13, 2008, 02:20:29 PM »
i did connect my sharp ir to my pc serial port
what im doing is that ,my atmega is reading adc value ,store it in a variable, send this variable through uart

i can see my data on the hyper terminal screen but its coded,, its a font(ascii),,how do i turn it back to hexa or decimal?
good ol' BeNNy

Offline izua

  • Supreme Robot
  • *****
  • Posts: 682
  • Helpful? 0
    • izua electronics
Re: hyper terminal hexa
« Reply #1 on: April 13, 2008, 02:49:08 PM »
hyperterminal bad, bray's terminal good  :D
Check out my homepage for in depth tutorials on microcontrollers and electronics.

Offline frank26080115

  • Supreme Robot
  • *****
  • Posts: 322
  • Helpful? 2
Re: hyper terminal hexa
« Reply #2 on: April 13, 2008, 04:20:27 PM »
something even more awesome, if you use linux, KontrollerLab is a fully featured IDE and it has this terminal built in, it doesn't interfere with any other program reading the same port, and it has different graphing functions too like a o'scope or a histogram

Offline dunk

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 1,086
  • Helpful? 21
    • dunk's robot
Re: hyper terminal hexa
« Reply #3 on: April 13, 2008, 04:28:34 PM »
Quote
i can see my data on the hyper terminal screen but its coded,, its a font(ascii),,how do i turn it back to hexa or decimal?
that's not really what a terminal emulator like HyperTerminal is designed to do.

why not just transmit the 3 ASCII characters that make up the number?
something like this:
Code: [Select]
void transmit_ascii_num(int i)
{
   char h = (i / 100) + '0' ;                     // h = hundreds
   char t = ((i % 100) / 10) + '0' ;           // t = tens
   char o = (i % 10)  + '0' ;                    // o = ones

   tx(h);                                                 // where "tx(char)" is your UART transmit function.
   tx(t);
   tx(o);

   return;
}

dunk.

paulstreats

  • Guest
Re: hyper terminal hexa
« Reply #4 on: April 13, 2008, 05:25:42 PM »
theres also a standard function itoa() that does this. It converts the int value into an array of characters which have the related ascii symbols of the number. So giving it the number 12 will return 2 characters 1 is 0x31 and the other is 0x32. When sent sent to hyperterminal these show the ascii characters of 1 and 2 ie.12

to use it you must send it an int and also give it a char array to return its characters to, and also state the base radix that you would like returned.

Code: [Select]
unsigned char[5] outstring;                     //the char array that will store the converted number
int mynum = 12;                     //the number to convert

itoa(mynum,outstring,10);        //send the int and char to itoa and tell it we want to use a base radix of 10.

uartputS(outstring);                // finally send the converted number to hyperterminal


once the number 12 gets sent to itoa() the array outstring contains the following:-

outstring[0] = 0x31               //this is the ascii code for the number 1
outstring[1] = 0x32               //this is the ascii code for the number 2
outstring[2] = undefined       // not used
outstring[3] = undefined
outstring[4] = undefined

If you just send the number 12 to hyperterminal the screen will become blank because 12 (or 0x0C) is the ascii code for starting a new page, so the itoa function converts the decimal value into hex characters that display as the decimal value but have no relation to the actual number 12.

If you cant find the itoa() function in any of your built in libraries, let me know and ill post it for you

Offline benjiTopic starter

  • Supreme Robot
  • *****
  • Posts: 830
  • Helpful? 0
Re: hyper terminal hexa
« Reply #5 on: April 14, 2008, 03:46:40 AM »
thanks paul this is awsome,, and yea i have the function,i just have a question about it

should the outstring contain 5 elements? cuz my input isnt an int ,its 8 bits variables
so actually 3 elements would do

if one of the outstring elements is undefined,would it send it via uart?what does this show on hyperterminal?

thanks
good ol' BeNNy

paulstreats

  • Guest
Re: hyper terminal hexa
« Reply #6 on: April 14, 2008, 04:57:12 AM »
The outstring can be any size, I usually just use 5 because an int has the possibility of a 5 digit value (32000). It can be reduced if you know that it isnt going to overflow.

The undefined values in the outstring simply wont be printed.

Im not sure if it works properly by sending just an 8 bit char, it might only accept an int but you could do the following:


Code: [Select]
char mychar = 0x08;

unsigned char[3] outstring;

itoa((int)mychar,*outstring,10)


So you send a character but write (int) in brackets before the char name to convert its value for this purpose only to an int.
Also you will notice that there is a * before outstring, you need to do this because you are just sending a pointer to the array (i forgot to put it in the original post)

Offline superchiku

  • Supreme Robot
  • *****
  • Posts: 952
  • Helpful? 5
  • cooll
Re: hyper terminal hexa
« Reply #7 on: April 14, 2008, 07:10:56 AM »
as  i told u bfore in my earlier post use this code, it is tested and debugged

Code: [Select]
# include<stdio.h>
# include<avr/io.h>

# include<util/delay.h>
# include<avr/interrupt.h>
# include<stdlib.h>
# include<string.h>
# include<avr/pgmspace.h>



#define USART_BAUDRATE 38400
#define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL)))- 1)


 char u[11]="adcvalue\r\n";
 char *d;
 char b[10];
 char *p;
 
 unsigned int a;

void adcinitialize();
void uartinitialize();
void adcgetvalue();
void transferusart();
void printvalue(char *);

 int main(void)
  {
   adcinitialize();
   uartinitialize();
   while(1)
    {
adcgetvalue();
     
p=itoa(a,b,10);

strcat_P(b,PSTR("\r\n"));

d=&u[0];

transferusart();

     
     }       
   

   return(0);
   }
 
 
 
 void adcinitialize()
  {
   
  ADCSRA|=_BV(7)|_BV(ADPS2)|_BV(ADPS1);
  ADMUX=0x60;
  ADCSRA|=(1<<ADSC);
  while(!(ADCSRA & (1<<ADIF)));
  ADCSRA|=(1<<ADIF);
  TCCR1B|=(1<<CS12);
 
  }
 
  void uartinitialize()
   {
    UCSRB= (1<<RXEN) | (1<<TXEN);
    UCSRC= (1 << URSEL) | (1 << UCSZ0) | (1 << UCSZ1);
    UBRRL=BAUD_PRESCALE;
UBRRH=(BAUD_PRESCALE>>8);
   }
void adcgetvalue()
 {
 
   ADMUX=0x61;
   ADCSRA|=(1<<ADSC);
  while(!(ADCSRA & (1<<ADIF)));
  ADCSRA|=(1<<ADIF);
  a=ADCH;
 }
 
void transferusart()
 {
   
   while (*d != '\0')
    {

     while ((UCSRA & (1 << UDRE)) == 0) {}; // Do nothing until UDR is ready for more data to be written to it
      UDR =*d ; // Echo back the received byte back to the computer
      d++;
}
TCNT1=0;
while(TCNT1<=60000){};
TCNT1=0;
 printvalue(p);
 }
 
 void printvalue(char *l)
  {
   
   while (*l != 0x00)
    {
 

  while ((UCSRA & (1 << UDRE)) == 0) {}; // Do nothing until UDR is ready for more data to be written to it
      UDR =*l ; // Echo back the received byte back to the computer
     
     
     l++;
    }
TCNT1=0;
while(TCNT1<=60000){};
TCNT1=0;
  }
 

   
JAYDEEP ...

IT AND ROBOTICS ENGINEER

"IN THE END IT DOESNT EVEN MATTER"

Offline benjiTopic starter

  • Supreme Robot
  • *****
  • Posts: 830
  • Helpful? 0
Re: hyper terminal hexa
« Reply #8 on: April 14, 2008, 09:35:12 AM »
thanks paul,, and sorry superchiku i should have seen it,thanks anyways
good ol' BeNNy

Offline superchiku

  • Supreme Robot
  • *****
  • Posts: 952
  • Helpful? 5
  • cooll
Re: hyper terminal hexa
« Reply #9 on: April 14, 2008, 10:21:29 AM »
no problem , do post the sensor digital o/p and graph when you use the code
JAYDEEP ...

IT AND ROBOTICS ENGINEER

"IN THE END IT DOESNT EVEN MATTER"

Offline benjiTopic starter

  • Supreme Robot
  • *****
  • Posts: 830
  • Helpful? 0
Re: hyper terminal hexa
« Reply #10 on: April 17, 2008, 04:28:52 PM »
Quote
hyperterminal bad, bray's terminal good 

maan this is one great piece of art, thanks
good ol' BeNNy

Offline superchiku

  • Supreme Robot
  • *****
  • Posts: 952
  • Helpful? 5
  • cooll
Re: hyper terminal hexa
« Reply #11 on: April 18, 2008, 01:29:45 AM »
whats bray's terminal?
JAYDEEP ...

IT AND ROBOTICS ENGINEER

"IN THE END IT DOESNT EVEN MATTER"

Offline izua

  • Supreme Robot
  • *****
  • Posts: 682
  • Helpful? 0
    • izua electronics
Re: hyper terminal hexa
« Reply #12 on: April 18, 2008, 07:10:08 AM »
check the link.
two dudes decided hyperterminal sucked. one of them was bray and finished his terminal with a whole bunch of options for debugging. the other one, izua, found bray's terminal and never finished his own terminal software :P
Check out my homepage for in depth tutorials on microcontrollers and electronics.

Offline superchiku

  • Supreme Robot
  • *****
  • Posts: 952
  • Helpful? 5
  • cooll
Re: hyper terminal hexa
« Reply #13 on: April 18, 2008, 11:23:26 AM »
hm.. u use which software to make the terminal?
JAYDEEP ...

IT AND ROBOTICS ENGINEER

"IN THE END IT DOESNT EVEN MATTER"

Offline izua

  • Supreme Robot
  • *****
  • Posts: 682
  • Helpful? 0
    • izua electronics
Re: hyper terminal hexa
« Reply #14 on: April 18, 2008, 01:07:46 PM »
c++ mostly.
Check out my homepage for in depth tutorials on microcontrollers and electronics.

Offline superchiku

  • Supreme Robot
  • *****
  • Posts: 952
  • Helpful? 5
  • cooll
Re: hyper terminal hexa
« Reply #15 on: April 24, 2008, 02:08:07 AM »
is it advanced C or embedded
JAYDEEP ...

IT AND ROBOTICS ENGINEER

"IN THE END IT DOESNT EVEN MATTER"

Offline izua

  • Supreme Robot
  • *****
  • Posts: 682
  • Helpful? 0
    • izua electronics
Re: hyper terminal hexa
« Reply #16 on: April 24, 2008, 01:07:56 PM »
it was a terminal software for the pc. if you consider the intel cpu as embedded, then yes, it was embedded.
i use the term software for PC software, and firmware for embedded software (like avr, pic, etc..)

offtopic: this is way offtopic.
Check out my homepage for in depth tutorials on microcontrollers and electronics.

Offline superchiku

  • Supreme Robot
  • *****
  • Posts: 952
  • Helpful? 5
  • cooll
Re: hyper terminal hexa
« Reply #17 on: April 24, 2008, 11:18:26 PM »
this isnt offtopic its realted to programming and may be this can be used in robots also
JAYDEEP ...

IT AND ROBOTICS ENGINEER

"IN THE END IT DOESNT EVEN MATTER"

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: hyper terminal hexa
« Reply #18 on: April 26, 2008, 06:05:55 PM »
everyone bashes hyperterminal . . . I like it tho . . .

Anyway, benji, can you show us the output you have in the terminal? Are you sure its just not an improper baud config?

To convert from ascii, do this:
your_variable = your_variable & 0x0F;

Offline benjiTopic starter

  • Supreme Robot
  • *****
  • Posts: 830
  • Helpful? 0
Re: hyper terminal hexa
« Reply #19 on: April 27, 2008, 03:10:24 AM »
no ,, the baud rate is right,, hyper terminal worked good, but i wanted to see my real numbers,,not coded stuff
try bray's terminal,, its just more robotic,, ;D
good ol' BeNNy

Offline superchiku

  • Supreme Robot
  • *****
  • Posts: 952
  • Helpful? 5
  • cooll
Re: hyper terminal hexa
« Reply #20 on: April 27, 2008, 07:26:44 AM »
you can see have you tried to use itoa function which convers to char and ascii, have you used strcat and attached /r/n at the end of your coverted string?

and have you tried using the progrem function if your using avr
JAYDEEP ...

IT AND ROBOTICS ENGINEER

"IN THE END IT DOESNT EVEN MATTER"

Offline benjiTopic starter

  • Supreme Robot
  • *****
  • Posts: 830
  • Helpful? 0
Re: hyper terminal hexa
« Reply #21 on: April 27, 2008, 09:08:00 AM »
there is no point to add stuff to my code just to use hyperterminal,,bray's terminal is perfect
good ol' BeNNy

Offline superchiku

  • Supreme Robot
  • *****
  • Posts: 952
  • Helpful? 5
  • cooll
Re: hyper terminal hexa
« Reply #22 on: April 27, 2008, 10:20:36 AM »
hmm.. if pre made codes make your life easy then that doesnt mean you cant learn anything , if you try to make your own code , you will be able to learn a lot more..
JAYDEEP ...

IT AND ROBOTICS ENGINEER

"IN THE END IT DOESNT EVEN MATTER"

Offline izua

  • Supreme Robot
  • *****
  • Posts: 682
  • Helpful? 0
    • izua electronics
Re: hyper terminal hexa
« Reply #23 on: April 27, 2008, 11:21:39 AM »
maybe he uses assembler, and an itoa function or ftoa is pretty evil to write.
Check out my homepage for in depth tutorials on microcontrollers and electronics.

Offline superchiku

  • Supreme Robot
  • *****
  • Posts: 952
  • Helpful? 5
  • cooll
Re: hyper terminal hexa
« Reply #24 on: April 27, 2008, 11:37:55 AM »
he uses C too..
JAYDEEP ...

IT AND ROBOTICS ENGINEER

"IN THE END IT DOESNT EVEN MATTER"

Offline benjiTopic starter

  • Supreme Robot
  • *****
  • Posts: 830
  • Helpful? 0
Re: hyper terminal hexa
« Reply #25 on: April 28, 2008, 10:40:26 AM »
its not that i dont want to learn,, its that i would save my time to learn somthin that helps me with my project ,,to improve it,, not learn stuff that i can do the easy way,,thats just my point of view
if you have 2 solutions , get the easier one and save time for another problems,, ;)
good ol' BeNNy

Offline superchiku

  • Supreme Robot
  • *****
  • Posts: 952
  • Helpful? 5
  • cooll
Re: hyper terminal hexa
« Reply #26 on: April 29, 2008, 04:48:54 AM »
REMEMBER ALWAYS "THE EASIEST WAY IS NOT THE BEST WAY ALWAYS"
JAYDEEP ...

IT AND ROBOTICS ENGINEER

"IN THE END IT DOESNT EVEN MATTER"

Offline benjiTopic starter

  • Supreme Robot
  • *****
  • Posts: 830
  • Helpful? 0
Re: hyper terminal hexa
« Reply #27 on: April 29, 2008, 09:13:58 AM »
yea but in this case i think it is,, cause i would be happy if the code gets smaller,, i have tons of things to program other than this little sensor,,
good ol' BeNNy

Offline superchiku

  • Supreme Robot
  • *****
  • Posts: 952
  • Helpful? 5
  • cooll
Re: hyper terminal hexa
« Reply #28 on: May 01, 2008, 12:23:55 AM »
your wish
JAYDEEP ...

IT AND ROBOTICS ENGINEER

"IN THE END IT DOESNT EVEN MATTER"

Offline Steel_monkey

  • Full Member
  • ***
  • Posts: 85
  • Helpful? 0
Re: hyper terminal hexa
« Reply #29 on: May 02, 2008, 04:38:05 PM »
Are there any programs for COM ports which are able to graph data properly? Terminal can, but in poor quality. Also it saves data in hex or ASCI , no decimal option for saving available. So, if I want to graph data, for example, in Maple, I need to do a lot of things ( cut prologue and epilogue for every string, convert it to decimal and graph). Do anybody knows easier way? 

 


Get Your Ad Here