Discussion in "8051 Discussion Forum" started by    romel_emperado    Nov 4, 2010.
Thu Jan 06 2011, 04:50 am

it is an 16 bit no mean it is int
FF=MSB byte
FE=LSB byte



ah okay thanks majoka but how do i convert that to binary?

0xFFFE = 1111 1111 1111 1110 
is it the same way in converting to decimal?? if not how?




---------------------------------------------------------------------------------------------------
another question majoka.

what is the difference if i put a void inside the parentheses? what is the difference of the two functions actually?
void stop_datalog(void); 

void stop_datalog();


------------------------------------------------------------------------------------------------

what does this line below means u8 * data? why using u8 * data??

void datalog_sm(u8 * data)


[ Edited Thu Jan 06 2011, 04:55 am ]
Thu Jan 06 2011, 09:22 am
romel_emperado

0xFFFE = 1111 1111 1111 1110


yes it is right every hex no in fact is represented in the binary form so u not need to convert it conversion is done normally from decimal to hexa decimal and hexa decimal to decimal
let say a register has value 0xff
a=0xff
now it is also equal to a=255
even we not convert it
if convert to ascii then
(a/100)+0x30=msb byte of 255 mean 2+0x30=32 it is ascii of 2
(a/10)%10=5+0x30=mid byte of 255 =ascii of 5
(a%10)=5+0x30=ascii of 5

void stop_datalog(void);
and
void stop_datalog();


it has same meaning when we leave braces empty compiler understand it as void

u8 * data?


it is equal to like as

unsigned char * data;


it is pointer type variable name as data

void datalog_sm(u8 * data)


here pointer is passing to a function


[ Edited Thu Jan 06 2011, 09:23 am ]
 romel_emperado like this.
Thu Jan 06 2011, 09:31 am
thanks so much majoka

I'll ask you more later if I see some lines I dont understand.. thanks
Thu Jan 06 2011, 10:49 am
welcome romel ur welcome
Thu Jan 06 2011, 06:29 pm
guys can you understand this? this code is actually saving recorded data into a file.. i dont understand some lines..



# Get the next data set bytes
      set byte0     [lindex $hex_arr $i]
      set byte1     [lindex $hex_arr [expr $i+1]]
      set byte2     [lindex $hex_arr [expr $i+2]]  
      set byte3     [lindex $hex_arr [expr $i+3]]
      set rec_hr    0 
      set rec_temp  0 
      set rec_alt   0 

      # Decode data
      switch $rec_mode {
        0x01 { # HR
            set rec_hr      [format %d $byte0]
          }
        0x02 { # TEMP
            set rec_temp    [format %2.1f [expr [format %2.1f [expr (($byte0<<8) | $byte1)]]/10]]
            # Move to next data set        
            set i [expr $i+2-1]
          }
        0x04 { # ALT
            set rec_alt     [format %d [expr ($byte0<<8) | $byte1]]
            # Move to next data set        
            set i [expr $i+2-1]
          }
        0x07 { # HR + TEMP + ALT
            set rec_hr      [format %d $byte0]
            set rec_temp    [format %2.1f [expr [format %2.1f [expr (($byte1<<4) | (($byte2>
>
4)&0x0F))]]/10]]
            set rec_alt     [format %d [expr (($byte2&0x0F)<<8) | $byte3]]
            # Move to next data set        
            set i [expr $i+4-1]
          }
        0x03 { # HR + TEMP
            set rec_hr      [format %d $byte0]
            set rec_temp    [format %2.1f [expr [format %2.1f [expr (($byte1<<8) | $byte2)]]/10]]
            # Move to next data set        
            set i [expr $i+3-1]
          }
        0x05 { # HR + ALT
            set rec_hr      [format %d $byte0]
            set rec_alt    [format %d [expr ($byte1<<8) | $byte2]]
            # Move to next data set        
            set i [expr $i+3-1]
          }
        0x06 { # TEMP + ALT
            set rec_temp    [format %2.1f [expr [format %2.1f [expr (($byte0<<4) | (($byte1>
>
4)&0x0F))]]/10]]
            set rec_alt     [format %d [expr (($byte1&0x0F)<<8) | $byte2]]
            # Move to next data set        
            set i [expr $i+3-1]
          }
        }
        
        # Convert metric temperature and altitude to Imperial units 
        if { $sync_use_metric_units == 0 } {
          set rec_temp [format %2.1f [expr ($rec_temp*9)/5+32]]
          set rec_alt  [format %.0f [expr $rec_alt*3.28084]]
        }

        # Write data set to file
        puts $wp "[clock format $start_time -format {%d.%m.%Y}],[clock format $start_time -format {%H:%M:%S}],$rec_hr,$rec_temp,$rec_alt"
      
        # Calculate time for next data sample
        set start_time  [expr $start_time + $rec_interval]
    }
  }
  close $wp
  
  after 500
  updateStatusSYNC "Data download finished."
}






example what is the function of this?
if { $sync_use_metric_units == 0 } {
          set rec_temp [format %2.1f [expr ($rec_temp*9)/5+32]]
          set rec_alt  [format %.0f [expr $rec_alt*3.28084]]

Thu Jan 06 2011, 08:03 pm
I dont know what programming language it is..
seems like its parsing data coming in a specific format and then storing it in file..

for the second one..
set rec_temp [format %2.1f [expr ($rec_temp*9)/5+32]]

%2.1 means.. 2 digits before and 1 digit after decimal. rec_temp is a string variable.

similarly
rec_alt [format %.0f [expr $rec_alt*3.28084]]

it formats the result with no decimal point. i donno he could have used %d instead
Thu Jan 06 2011, 08:29 pm
thanks ajay... that's a Tk language.. it's very weird...

that is my base code and im going to write a new code in python with similarity of that..lol

I also dont know python... WTF!

this is the last part of my task after this Its done.. lol
Tue Jan 11 2011, 01:31 am
python thing is going around in my office too its really weird language
Tue Jan 11 2011, 02:11 am


python thing is going around in my office too

Ajay Bhargav


I knew there were a lot of snakes in India,
but I didn't realise you had them in your offices !


[ Edited Tue Jan 11 2011, 02:11 am ]
Tue Jan 11 2011, 02:23 am
haha... nice one! just trying to get control over python

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Richardgar
Sat Apr 20 2024, 11:05 am
AntoniaRoons
Fri Apr 19 2024, 09:59 pm
carpinteyrowrl
Fri Apr 19 2024, 02:51 pm
DonaldJAX
Fri Apr 19 2024, 01:08 pm
Lewisuhakeply
Thu Apr 18 2024, 06:00 pm
Darrellciz
Thu Apr 18 2024, 11:07 am
Charlessber
Thu Apr 18 2024, 09:29 am
BartonSem
Thu Apr 18 2024, 04:56 am