2023-06-21 05:40 AM
i am sending data on serial is 3 when is display is this 3 but i can conver in bninary then become 00110011 instead 00000011.and when i invert it then i got 01100110 instead of 11111100 ,why so ?
2023-07-12 09:11 AM
Ok, but what part / product are we even talking about here? Present the problem better, you'll get better answers..
RS232 level shifters implicitly "invert" the level. Out of CMOS drivers on an MCU the line is typically HIGH in the idle state, the START bit is LOW, and the data bits shift out LSB first, and normal/expected logic levels, ie 0 LOW, 1 HIGH
Some of the newer STM32 families have UART pins can be logically inverted as part of the Advanced Features.
2023-07-15 12:52 PM - edited 2023-07-15 12:56 PM
@Ranjeet Singh wrote:i am sending data on serial is 3 when is display is this 3 but i can conver in bninary then become 00110011 instead 00000011.and when i invert it then i got 01100110 instead of 11111100 ,why so ?
How is it possible to convert "3" in decimal to "00110011" in binary?
If it is "3" from the ASCII table then it is necessary to convert ASCII to decimal:
The value of the character "3" from the ASCII table is not 3 in decimal. The value of the character "3" in ASCII is 51 in decimal:
Table here: https://www.ascii-code.com/
Since characters start from "0" to "9", a programmer can convert the character "3" to ASCII by removing the value of the character "0" in ASCII.
This way the decimal value of the ASCII character "3" = equal to the value of "3" - "0" = (51) - (48) = 3 (which is 3 in decimal).
No inversion occurs anywhere in this conversion.
2023-07-15 01:07 PM
Note that the character "3" from the ASCII table is considered just a SYMBOL, not the relative position value (which would be 51 in decimal base, or 063 in octal base, or 33 in hexadecimal base).
The American Standard Code for Information Interchange (ASCII) was an early standardized encoding system for text. Encoding is the process of converting characters in human languages into binary sequences that computers can process.
ASCII’s library includes every upper-case and lower-case letter in the Latin alphabet (A, B, C…), every digit from 0 to 9, and some common symbols (like /, !, and ?). It assigns each of these characters a unique three-digit code and a unique byte."
"The number of characters that ASCII can represent is limited to the number of unique bytes available, since each character gets one byte. If you do the math, you’ll find that there are 256 different ways of groups eight 1s and 0s together. This gives us 256 different bytes, or 256 ways to represent a character in ASCII. When ASCII was introduced in 1960, this was okay, since developers needed only 128 bytes to represent all the English characters and symbols they needed."
2023-07-18 09:10 PM
your answer is correct for decimal to binary conversion but how i can invert it as a mention in my question ?
2023-07-19 05:12 AM
You're communicating the issue poorly, you're not answering questions to understand the "problem" you're attempting to describe.
Identify the part you are talking about.
Show the current code.
Show the current output.
Show how you want/expect it to look, and why normal output methods aren't working.
Is the question about flipping the bit state high or low? Or is this how to convert numbers to/from binary forms.
USART->TDR = ~data; // Negate data written to transmit data register.
At a PIN level, look at the UART configuration options.
2023-07-19 05:19 AM - edited 2023-07-19 05:21 AM
In Arduino..
Serial.println((char)'3'); // 00110011
Serial.println((char)3); // 00000011
uint8_t data = {1,2,3,4 }; // As bytes, not ASCII printing
Serial.write(data, sizeof(data));
2023-07-20 12:01 AM
how to invert it?
2023-07-20 10:46 AM
Ok, but you've stated that half a dozen times already. Do you work with someone who can communicated effectively in English? Heck draw a diagram if that's easier..
Invert WHAT? For WHAT purpose? WHAT are you connecting together, and WHAT are the expectations?
char i = 3; // the value 3, not the character '3'
i = ~i; // Invert bitwise
HAL_UART_Transmit(&husart1, (uint8_t *)&i, sizeof(i), 100);
2023-07-21 12:43 AM
when we inverted this received data ('Y') using an inverter circuit( using Transistor) the actual data ('4') which we were sending from the mcu , was received in Original form (4).
our Expectation is to know the logic behind this inversion , so that we can directly use this logic in our program on the receiver end , and Receive the Original data without using any inverter circuit.
2023-07-21 11:51 PM - edited 2023-07-21 11:52 PM
Seems to be a problem with the communication, what is the schematic for that IR part?
How is the transmission and reception via IR being handled?
To simplify the IR transmission, a base frequency is used (carrier frequency), usually 38kHz, and spaces between the pulses, in this way a protocol is created that can identify the signals, such as NEC Remote Protocol and RC5 Remote Protocol.
IR receiver (TV, air conditioning etc.):
https://www.sparkfun.com/datasheets/Sensors/Infrared/tsop382.pdf
See here: