Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/15/07 06:22
Read: times


 
#143297 - No majic
Responding to: ???'s previous message
print(adc_sum);
this prints a single character.
print('A'); will print an A.
print(65) will not print 65. it will print the ASCII character for 65.
I gets worse. assuming you ADC has a REF voltage of 3 VDC a gain one 1 and is 8 bits. If you input 3 volts you get 255.

Avoiding floats we can scale to millivolts

millivolts = (adc_counts * 3000UL)/ 255 (note 255* 3000 = 765000 and requires a long)

Now to display it.
First you must set your LCD to the Home position (or any other fixed position)
Then use atoi() or sprintf to format it to a buffer (array of char). then print it one char at a time.
better, but more wore if you have limited code space is as follows:

millivolts = 1234
the_char = millivolts % 10 // you get 4
millivolts = millivolts /10 // millivolts is now 123
the_char = the_char + '0' // now it is ASCII '4'
save in an buffer in reverse order.
Make a loop and repeat.

With a little more code you can print without using a buffer.








List of 30 messages in thread
TopicAuthorDate
ADC Problem            01/01/70 00:00      
   Circuit ?            01/01/70 00:00      
   Clarify?            01/01/70 00:00      
   Crosspost            01/01/70 00:00      
      Clarification            01/01/70 00:00      
         Still no circuit            01/01/70 00:00      
         Power supply            01/01/70 00:00      
   What about the adc lowbyte ?            01/01/70 00:00      
      Power Supply            01/01/70 00:00      
         Power supply            01/01/70 00:00      
            Power Supply            01/01/70 00:00      
      ADC lowbyte            01/01/70 00:00      
         sorry for confusing you but            01/01/70 00:00      
            Thanks for the time            01/01/70 00:00      
               mmmhhh one more time            01/01/70 00:00      
                  LCD code            01/01/70 00:00      
                     No majic            01/01/70 00:00      
                     delay            01/01/70 00:00      
                        Writing Timing Loops in C            01/01/70 00:00      
                           Lucky            01/01/70 00:00      
                              Very true!            01/01/70 00:00      
                                 Your adc value must be 123. {            01/01/70 00:00      
                                    Power Supply Problem            01/01/70 00:00      
                                       We can not see what you are looking at            01/01/70 00:00      
                                          current limiting power supply?            01/01/70 00:00      
                                             Power Supply            01/01/70 00:00      
   Power Supply            01/01/70 00:00      
   ADC0804 with 8051            01/01/70 00:00      
      Start a new thread!            01/01/70 00:00      
      Sorry Dude!!!            01/01/70 00:00      

Back to Subject List