Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Binary/BCD Convertion

Status
Not open for further replies.

aduri

New Member
I Have to represent one 16 bit integer variable "count" and to transform it in bcd (denied) to control 6 contraves of a receiver.
Every contraves has 4 terminals and they are connected with four multiplexer 4512BE.
My problem is:
1- It's usefull to use pic 16f877A while connecting a lot of CPU pins (6x4=24 terminals) in order to obtain
in output the direct command of the contraves or
2- to use an external converter binary/BCD or
3- to serializzare all (with 74HC595).

Surely it is also necessary to use a buffer for having 5V of output.

I use miKrobasic or in alternative the c.

Thanks of the eventual suggestion or clarification.
 
I don't really follow what you are asking. If you are asking how to convert from Binary to BCD in Microbasic then have a look in the help file for Dec2Bcd16.

Mike.
 
depending on how you get your 16 bit value, you may want make BCD your native format. Add and sub are pretty easy. Mul and div, much harder.

piclist has a number of routines -
 
I have tried this Mikrobasic code but after number 99 he does not work

Code:
countbin = Dec2Bcd16(count)  ' conversione da decimale a binario
final= countbin

     if (count =0) then portb=255 portc=255 portd=255
       else
       if  (count<100)  then    portb = not final portc=255 portd=255
            else
            if (count >99) then portb=final
            if  (count<10000)  then    final=(final-255)  portc=not final portd=255
       		      else
                if (count >9999) then portb=0 portc=0
       'else
      'if  (count<300000)  then    portb = not final portc=255 portd=255
      ' else if (count >9999) then portb=0 portc=0

       '  end if
               end if
            end if
            end if
         end if
      end if

Antonio
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top