View Full Version : Questions/Basic/16F628A
BertMan
- 20th September 2005, 19:29
I am building firmware for this pic to interface it with a Vector 2VXe compass module. The datasheet states the basic Datagram Structure to be
Sync Flag
0xAA
Frame Type
0xXX (example 0x01)
Terminator
0x00
If I am using pbp and the shiftin(out) commands, how exatcly do I format the data? Do I send the bit representation of the hex (example: 170 for 0xAA), or could I simply shiftin(out) a variable that contains a string like "0xAA"?
I have a rough draft that I threw up in a couple of days, and now I am going back to fix the areas that I needed more information on. Could I post my code? Its about 700 lines long.
BertMan
- 21st September 2005, 02:21
One, more thing....How many bytes are in a word for this particular mcu. Since it's an 8bit mcu, its two bytes right?
BertMan
- 21st September 2005, 04:19
tap tap tap... is this thing on? One more thing. Does anyone have any experience or code to share on how to convert a floating point number in basic? The output of the Vector compass is in IEEE 754 format, so I assume I have to convert this to a usable format in basic.
BertMan
- 21st September 2005, 19:16
One, more thing....How many bytes are in a word for this particular mcu. Since it's an 8bit mcu, its two bytes right?
Done some research on this and an 8 bit mcu means 8 bits to a word, which is the largest value the mcu can process. So, my next question is, how do I know when to set the variable to type word instead of byte when they both represent the same size - 8 bits?
Am I posting in the wrong forum? Are my questions too stupid to answer? Am I on the right site? Or perhaps my questions are beyond the scope of the members here? Maybe I just dont have enough patience to wait for a response? Do I need to stfu and rtfm? Maybe someone could enlighten me before I go crazy talking to myself :-)
CocaColaKid
- 21st September 2005, 19:17
I've never used it so I can say how it works but there is code on ME Lebs website for performing floating point. I stay away from FP just for headache sake.
And yes there are 2 bytes to a word.
Bit is a Bit
Byte is 8 Bits
Word if 2 Bytes or 16 Bits
BertMan
- 21st September 2005, 19:24
I've never used it so I can say how it works but there is code on ME Lebs website for performing floating point. I stay away from FP just for headache sake.
And yes there are 2 bytes to a word.
Bit is a Bit
Byte is 8 Bits
Word if 2 Bytes or 16 Bits
Yep came across that code. I will be picking it apart this evening to see if it can help me. Unfortunately, I cant stay away from floating point because this is what the v2xe outputs.
Word is 2 bytes? I searched and read forever last night and the only definite conclusion I could reach was that it depends on the archietecture. Since my mcu is 8 bit, does this not mean 8 bit is the highest word the mcu can process?
BertMan
- 21st September 2005, 19:44
Still working on it but here is what I got so far. I havent finished the menu system, nor have I figured a way to convert the floating point numbers coming from the V2Xe.
Ingvar
- 22nd September 2005, 08:50
It might help to look at Melabs site .......
http://www.melabs.com/resources/fp.htm
BertMan
- 22nd September 2005, 17:25
Excellent! There is a subroutine to convert 32bit floats to a usuable ascii format. Hmm.. I dont think the 628 will hold all that code.
CocaColaKid
- 22nd September 2005, 17:50
You could try using the 648, it has 4k.
BertMan
- 29th September 2005, 15:28
I ended up using a math co-mcu to do the conversions. This little 8 pin device can convert strings, floats, and longs using the spi interface and only cost me $14. Here is the link: http://www.sparkfun.com/shop/index.php?shop=1&cat=79. Its the umFPU v2.0. I think the cost justified the headaches of using microcode's floating routines, and you can convert a string to float in about 3 lines of code, so I can still use the 628...YEAH!!! Attached is an alpha version of code that I am waiting to test as soon as the device gets here. You can see floating and long conversions in the routines: FloatToString, ConvertSInt32, and SetConfigMenu.
Conclusion to this thread: If you want an easy to use method for floating point conversion in the IEEE754 format, get a fp co-mcu.
Powered by vBulletin® Version 4.1.7 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.