| ??? 03/14/12 22:13 Read: times |
#186672 - serial Tx code Responding to: ???'s previous message |
I am using the following bit of code. since I knew that serialangle was going to vary between -20 to +20 I added 20 to my code in order to see the negative numbers, therefore my zero is actually 20. And I also multiplied it by 10 to see one number after the decimal point.
What was actually being seen on my PC when serialangle was going negative the would show a constant 40 through all negative numbers of serialangle.
serialangle = (serialangle +20) * 10;
units = (serialangle % 10) | 0x30;
a = serialangle/ 10;
tens = (a%10) | 0x30;
b = a / 10;
hundreds = (b % 10)|0x30;
c = b / 10;
thousands = (c % 10)|0x30;
d = c / 10;
thousands2= (d % 10)|0x30;
thousands3= d / 10;
thousands3= (thousands3 % 10)|0x30;
SrTx(thousands3);
SrTx(thousands2);
SrTx(thousands);
SrTx(hundreds);
SrTx(tens);
SrTx(0x2E); // decimal point
SrTx(units);
SrTx(0x0A); //space
SrTx(0x0D); //space
|
| Topic | Author | Date |
| I'm having problems calculating negative float values | 01/01/70 00:00 | |
| float values? | 01/01/70 00:00 | |
| 65536 no | 01/01/70 00:00 | |
| negative float numbers | 01/01/70 00:00 | |
| Two comparisons | 01/01/70 00:00 | |
| Insufficient justification | 01/01/70 00:00 | |
re:insufficient justification | 01/01/70 00:00 | |
| how are numbers transmitted? | 01/01/70 00:00 | |
| serial Tx code | 01/01/70 00:00 | |
| Data type? | 01/01/70 00:00 | |
| Data type? | 01/01/70 00:00 | |
| serialangle data type | 01/01/70 00:00 | |
| Just a question of readability | 01/01/70 00:00 | |
| re: just a question of readability | 01/01/70 00:00 | |
| why do you keep babbeling about 'float' | 01/01/70 00:00 | |
| float reason | 01/01/70 00:00 | |
| fixed point | 01/01/70 00:00 | |
| re:fixed point | 01/01/70 00:00 | |
| typecast | 01/01/70 00:00 |



