Maker Pro
Maker Pro

ADC

P

Prakruthi

Jan 1, 1970
0
Could anybody tell me the best way to output the digital words from
the ADC on to the hyperterminal. I seem to facing some problems with
printf. Any other way?

Thanks and regards,
Prakruthi
 
M

martin griffith

Jan 1, 1970
0
Could anybody tell me the best way to output the digital words from
the ADC on to the hyperterminal. I seem to facing some problems with
printf. Any other way?

Thanks and regards,
Prakruthi
1) how are you interfacing the ADC to hyperterminal
2) what ADC is it?
3) Most people say hyperterminal is not very good


martin
 
Could anybody tell me the best way to output the digital words from
the ADC on to the hyperterminal. I seem to facing some problems with
printf. Any other way?

Thanks and regards,
Prakruthi

Use serial communication. Got a serout routine?
 
D

Donald

Jan 1, 1970
0
Prakruthi said:
Could anybody tell me the best way to output the digital words from
the ADC on to the hyperterminal. I seem to facing some problems with
printf. Any other way?

Thanks and regards,
Prakruthi
Prakruthi,

Are you a first year engineering student ?

By your second year you should be able to do all the things you have
asked about on your own.

Please do some of your own homework.

To help you out, go here: http://jfgi.us/

donald
 
P

Prakruthi

Jan 1, 1970
0
martin said:
1) how are you interfacing the ADC to hyperterminal
2) what ADC is it?
3) Most people say hyperterminal is not very good


martin

Hi Martin,

I m interfacing the ADC to the hyperterminal thru a USB using the
ATMega8 microcontroller
I m using the AD7714

The problem is that sometimes I dont see all three bytes of the digital
word on the output.Its a little strange. But I dont know if the problem
is with the printf only.

Regards,
Prakruthi
 
R

Rich Grise

Jan 1, 1970
0
I m interfacing the ADC to the hyperterminal thru a USB using the
ATMega8 microcontroller
I m using the AD7714

The problem is that sometimes I dont see all three bytes of the digital
word on the output.Its a little strange. But I dont know if the problem
is with the printf only.

One possible way to check this is to temporarily not use printf(), but
to format your own data and output it character by character with, say,
putc(), or putch(), or whichever - you could look it up.

Good Luck!
Rich
 
J

jasen

Jan 1, 1970
0
Hi Martin,

I m interfacing the ADC to the hyperterminal thru a USB using the
ATMega8 microcontroller
I m using the AD7714

The problem is that sometimes I dont see all three bytes of the digital
word on the output.Its a little strange. But I dont know if the problem
is with the printf only.

what printf format string are you using?, what do you see?
 
P

Prakruthi

Jan 1, 1970
0
jasen said:
what printf format string are you using?, what do you see?

@Jasen,

I m using %d to print an unsigned char data. I m looking to see a
digital word 3 bytes long. But sometimes I dont see all the three bytes
, I fail to see where they disappear.

Regards,
Prakruthi
 
P

Prakruthi

Jan 1, 1970
0
Rich said:
One possible way to check this is to temporarily not use printf(), but
to format your own data and output it character by character with, say,
putc(), or putch(), or whichever - you could look it up.

Good Luck!
Rich

@Rich,

Thanks Rich, Will try that out.Hope that helps.

Thanks again.
Regards,
Prakruthi
 
R

Roger Hamlett

Jan 1, 1970
0
Prakruthi said:
@Jasen,

I m using %d to print an unsigned char data. I m looking to see a
digital word 3 bytes long. But sometimes I dont see all the three bytes
, I fail to see where they disappear.
Er. If the value is below 100, then %d, will only give two digits. If it
is below 10, %d, will only give one. You need to use %03d, which will give
a three digit field, with leading zeros, to ensure that you actually get
three digits each time.

Best Wishes
 
A

Arlet

Jan 1, 1970
0
Roger said:
Er. If the value is below 100, then %d, will only give two digits. If it
is below 10, %d, will only give one. You need to use %03d, which will give
a three digit field, with leading zeros, to ensure that you actually get
three digits each time.

Best Wishes

Correct, but even then the results aren't really easy to read.

If the 3 bytes from the ADC are in "h", "m" and "l", first convert them
into a 'long' type:

long val = ((long) h << 16) + ((long) m << 8) + (long) l;

and then print this value with printf( "%ld", val );

Or, if you insist on seeing the individual bytes for easier
verification with bit patterns on scope, use something like "%02x",
which prints each byte in 2 digit hex.
 
P

Prakruthi

Jan 1, 1970
0
Roger Hamlett wrote:
..
Er. If the value is below 100, then %d, will only give two digits. If it
is below 10, %d, will only give one. You need to use %03d, which will give
a three digit field, with leading zeros, to ensure that you actually get
three digits each time.

Best Wishes

Thanks for the input Roger. Will try what you suggested. Hope it
works:) Thanks again.

Regards,
Prakruthi
 
P

Prakruthi

Jan 1, 1970
0
Arlet said:
Correct, but even then the results aren't really easy to read.

If the 3 bytes from the ADC are in "h", "m" and "l", first convert them
into a 'long' type:

long val = ((long) h << 16) + ((long) m << 8) + (long) l;

and then print this value with printf( "%ld", val );

Or, if you insist on seeing the individual bytes for easier
verification with bit patterns on scope, use something like "%02x",
which prints each byte in 2 digit hex.

Hi Arlet,

What you say makes a lot of sense. Thanks for the suggestion. Will try
this and keep you posted on the results.

Regards,
Prakruthi
 
Top