free 8051 Microcontroller Projects AVR PIC Microcontroller Projects Tutorials Ebooks Libraries, interfacing tutorials, lcd tutorial, stepper motor, dc motor 8051 assembly language programming electronics and communication ECE CSE pdf ebooks library BE final year project ideas Embedded systems

 
8051 microcontroller 8051 microcontroller
Forums

Rickey's World :: Discussion Forums :: Discuss and Learn :: 8051 Discussion Forum
 
<< Previous thread | Next thread >>
how to convert hex to ascii decimal in c/c++
Go to page       >>  
Moderators: Ajay Bhargav, Arun Kumar V, pdi33, Shailesh NAYAK, ۞ TPS ۞, shyam, sashijoseph, ExperimenterUK, DavesGarage
Author Post
DaveChika
Thu Dec 31 2009, 12:32AM
 User Offline
Registered Member #24812
Joined: Wed Dec 30 2009, 11:33AM

Posts: 18
Thanked 0 times in 0 posts

pls can can i convert hex values retrived fro counters to ascii decimal values which is sent to the serial buffer of 8952 microcontroller



Back to top

Ajay Bhargav
Thu Dec 31 2009, 02:57AM
Rickey's World Admin

 User Offline

Registered Member #1
Joined: Fri Feb 24 2006, 04:56AM

Posts: 7509
Thanked 1326 times in 1250 posts
its simple to do in C.

assuming 1 byte parameter.

CODE:
const char asciitable[] = "0123456789";
char ascii[3];

ascii[2] = asciitable[val/100];
val = val/100;
ascii[1] = asciitable[val/10];
val = val/10;
ascii[0] = asciitable[val];
 


www.rickeyworld.info
If you feel satisfied with the user's forum reply please click on the thank button.

Obey forum rules!
Respect others!
Back to top

TsK
Thu Dec 31 2009, 05:25AM
 User Offline
Registered Member #13791
Joined: Wed Jan 07 2009, 10:24AM

Posts: 29
Thanked 2 times in 2 posts
If u got a value like 9999

unit=value%10;
ten=(value%100)/10;
hundred=(value/100)%10;
thousand=value/1000;

with the results just add 0x30 that stands for Zero in the ascii table.

^^ Brazuca na parada
Back to top


This post has been thanked 1 time
 DaveChika 
DaveChika
Fri Jan 01 2010, 03:43PM
 User Offline
Registered Member #24812
Joined: Wed Dec 30 2009, 11:33AM

Posts: 18
Thanked 0 times in 0 posts
Please can someone help me with the c/c++ code for this project am doing,
the circuit is the picture of my project,it measures heartbeat using LDR an an LED light source, the analog signal is the amplified by the Opamp LM358 which is the fed to pin P3.4 of the microcontroller which outputs it to the serialbuffer SBUF,please can u help me with a C/ C++ code for this project.



Back to top

DaveChika
Fri Jan 01 2010, 03:48PM
 User Offline
Registered Member #24812
Joined: Wed Dec 30 2009, 11:33AM

Posts: 18
Thanked 0 times in 0 posts
this is where i need to convert hex values retrived from counters to ascii decimal values which is sent to the serial buffer of 8952 microcontroller,Please can anyone help me with the C code to masure the Data at P2 and also count the Number of pulses it receives from the Opamp LM358

Back to top

Ajay Bhargav
Mon Jan 04 2010, 03:40AM
Rickey's World Admin

 User Offline

Registered Member #1
Joined: Fri Feb 24 2006, 04:56AM

Posts: 7509
Thanked 1326 times in 1250 posts
as per the circuit the heartbeat sensor output is given to T1 (timer 1) input pin. so you can configure T1 as counter and read pulses in 1 sec so you can get value of heartbeat per second. check frequency counter project for reference.

And for temperature sensor, you need to read ADC value then convert it to corresponding temperature value.

www.rickeyworld.info
If you feel satisfied with the user's forum reply please click on the thank button.

Obey forum rules!
Respect others!
Back to top

DaveChika
Mon Jan 04 2010, 04:00AM
 User Offline
Registered Member #24812
Joined: Wed Dec 30 2009, 11:33AM

Posts: 18
Thanked 0 times in 0 posts
pls how can i set the counter to read pulses @ exactly 1sec and am using timer 1 as timer for the serial port baudrate and timer/counter0 for counting of the pulses.(P3.4= T0)

PLEASE how can i set counter 0 to resd the pulses @ exactly 1 sec in C.

[ Edited Mon Jan 04 2010, 04:04AM ]

Back to top

Ajay Bhargav
Mon Jan 04 2010, 04:45AM
Rickey's World Admin

 User Offline

Registered Member #1
Joined: Fri Feb 24 2006, 04:56AM

Posts: 7509
Thanked 1326 times in 1250 posts
make timer to trigger at every 50ms so 50ms triggered 20 times means 1 sec delay.

use counter to count 50ms triggers. check your circuit carefully, timer 1 is used for heartbeat sensor.

www.rickeyworld.info
If you feel satisfied with the user's forum reply please click on the thank button.

Obey forum rules!
Respect others!
Back to top

DaveChika
Mon Jan 04 2010, 04:59AM
 User Offline
Registered Member #24812
Joined: Wed Dec 30 2009, 11:33AM

Posts: 18
Thanked 0 times in 0 posts
yes i made a mistake on the circuit,pls can you give me the exact values i will load on my counters (TH0/TLO) to achieve this,
thanks for your anticipated favourable response.

Back to top

Ajay Bhargav
Mon Jan 04 2010, 05:05AM
Rickey's World Admin

 User Offline

Registered Member #1
Joined: Fri Feb 24 2006, 04:56AM

Posts: 7509
Thanked 1326 times in 1250 posts
read datasheet calculate if you cant i will help you out.

search in forum for timer help.

www.rickeyworld.info
If you feel satisfied with the user's forum reply please click on the thank button.

Obey forum rules!
Respect others!
Back to top

Go to page       >>   

Jump:     Back to top

Syndicate this thread: rss 0.92 Syndicate this thread: rss 2.0 Syndicate this thread: RDF
Powered by e107 Forum System

8051 Microcontroller Projects 8051 AVR tutorials PIC microcontroller, 8051 assembly language programming electronics and communication ECE CSE pdf ebooks library BE final year project ideas Embedded systems