DEC to BIN
- badir79
- Posts: 12
- Joined: Mon Oct 29, 2012 10:44 pm
- Has thanked: 3 times
- Been thanked: 2 times
- Contact:
DEC to BIN
Hi Everyone!!! I guess this topic already exist, but I just can´t find it in my quick search...
Well, I need some help. How i can convert decimal numbers into binary numbers and show them on a display? In other words, how i can decompose a single byte into their bits and manipulate them?
Thanks a lot for helping me!!!
Well, I need some help. How i can convert decimal numbers into binary numbers and show them on a display? In other words, how i can decompose a single byte into their bits and manipulate them?
Thanks a lot for helping me!!!
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
- Contact:
Re: DEC to BIN
Hi,
You can try the following code...
You can try the following code...
- Attachments
-
- DEC_BIN.fcf
- (11.5 KiB) Downloaded 376 times
- badir79
- Posts: 12
- Joined: Mon Oct 29, 2012 10:44 pm
- Has thanked: 3 times
- Been thanked: 2 times
- Contact:
Re: DEC to BIN
Enamul, thank you very much for your help... But I can´t open it because this file was made in Flowcode V5 I guess, and I only have Flowcode V4; please, can you give it to me in V4, or post an image of the flowchart to see what can I do... Thanks!!!
- badir79
- Posts: 12
- Joined: Mon Oct 29, 2012 10:44 pm
- Has thanked: 3 times
- Been thanked: 2 times
- Contact:
Re: DEC to BIN
Hi,
Now I need to convert single bits from one port pin into a byte... How can I do that? how can I do this inverse process?
Now I need to convert single bits from one port pin into a byte... How can I do that? how can I do this inverse process?
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
- Contact:
Re: DEC to BIN
This one is not so simple like earlier one..what will be the bit rate in that port..Will you allowed to interrupt to detect 1. Is that a continuous transmission or single byte transmission? I have made a program for you but need to tune depending on these Q/A.
- badir79
- Posts: 12
- Joined: Mon Oct 29, 2012 10:44 pm
- Has thanked: 3 times
- Been thanked: 2 times
- Contact:
Re: DEC to BIN
Thank you Enamul, let me see... this is for a serial comunication at a baud rate of 10400 bps, so, the time bit is about 96 micro-seconds. I was thinking in an interrupt, but I need to evaluate that, because in this proyect there will be just one bidireccional comm line, so I will have one pin for TX and one for RX, but due to the interface design, every time I send a bit by the TX port, it reflects in the RX port, so, I'm not sure at this moment an interrupt would work properly for this case. Another thing to consider is that it will need to detect start bit and stop bit. Start bit= '0',/ Byte bits,/ Stop bit ='1'.
Thanks alot for your help Enamul, if you need another detail please ask me... Thanks!!!
Thanks alot for your help Enamul, if you need another detail please ask me... Thanks!!!
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
- Contact:
Re: DEC to BIN
Ok..In that case you can simply use RS232 and that's most easy to deal with. If you don't have hardware RS232 in PIC still you can use software RS232.
- badir79
- Posts: 12
- Joined: Mon Oct 29, 2012 10:44 pm
- Has thanked: 3 times
- Been thanked: 2 times
- Contact:
Re: DEC to BIN
Hello! This is another issue that I have at this moment... I have an hexadecimal value in a string, this is an address for a external EEPROM, from this value, I need to get the memory's high and low addresses , then I need to send these string values as individual bytes via i2c, but, I can't send it as string, so I use the function BYTE = StringToInt (STRING)
Example1:
String 0x47E
String_H = 04
BYTE1 = StringToInt (String_H)
BYTE1= 4
String_L = 7E
BYTE2 = StringToInt (String_L)
BYTE2 = 7
Bytes sent via i2c: 0107, but I need to send 017E
Example2:
String 0x190
String_H = 01
BYTE1 = StringToInt (String_H)
BYTE1= 1
String_L = 90
BYTE2 = StringToInt (String_L)
BYTE2 = 90
Bytes sent via i2c: 015A, but I need to send 0190
So, the addresses sent are not equals to the addresses that I need to send. How can I convert these bytes to hex numbers, or, how can I keep the same value of these strings?
Thanks a lot for helping me!!!
Example1:
String 0x47E
String_H = 04
BYTE1 = StringToInt (String_H)
BYTE1= 4
String_L = 7E
BYTE2 = StringToInt (String_L)
BYTE2 = 7
Bytes sent via i2c: 0107, but I need to send 017E
Example2:
String 0x190
String_H = 01
BYTE1 = StringToInt (String_H)
BYTE1= 1
String_L = 90
BYTE2 = StringToInt (String_L)
BYTE2 = 90
Bytes sent via i2c: 015A, but I need to send 0190
So, the addresses sent are not equals to the addresses that I need to send. How can I convert these bytes to hex numbers, or, how can I keep the same value of these strings?
Thanks a lot for helping me!!!
- Enamul
- Posts: 1772
- Joined: Mon Mar 05, 2012 11:34 pm
- Location: Nottingham, UK
- Has thanked: 271 times
- Been thanked: 814 times
- Contact:
Re: DEC to BIN
Hi,
First of all you can declare an INT variable for the address. In calculation box, just put your hex value in that variable and then simply you have to split that into low and high byte.
Address=0x47E
BYTE_L =Address AND 0x00FF
BYTE_H =Address >> 8
Hope this helps.
First of all you can declare an INT variable for the address. In calculation box, just put your hex value in that variable and then simply you have to split that into low and high byte.
Address=0x47E
BYTE_L =Address AND 0x00FF
BYTE_H =Address >> 8
Hope this helps.