Maybe I missed it but I don't see in your posts where you describe the input (transducer?) or the algorithm. Do you have something like this? transducer -> number_format -> algorithm -> output If so, the best solution will probably take all steps in consideration. You already mentioned that the output is offloaded for display. If the algorithm can be modified to accommodate integer input or what the transducer produces, why not go with that? It looks like the algorithm needs to call the shot, as long as it produces meaningful values even if they have to be converted by the other PIC. Again, I am probably missing something. An example of adapting an algorithm: A transducer produces degrees C in 8q8 format. The desired result is degrees F * 10. It will be output to a device that will handle the display routine like your example. There will be one decimal point precision. Now consider that the temperature is actually Deg C * 256. So you could do something like this: Deg F * 10 = ((((transducer_value/256)*9)/5)+32)*10 But we can do something like this instead: Deg F * 10 = 18 * Deg_C + 320 It could be implemented something like this: temp1 = transducer>>4; // temp1 = Deg C * 16 temp2 = transducer>>7; // temp2 = Deg C * 2 DegC18 = temp1 + temp2; // DegC18 = Deg C * 18 result = DegC18 + 320; // Deg F * 10 This can be further refined. Also, negatives are not considered here. But comparing to the previous example, much less code space is required as only shifts and additions are needed. Now we have something like this: transducer -> algorithm -> output --- I don't see what difference using a compiler has since it produces assembly (or machine) code anyway. It is always good to keep an eye on the assembly list file anyway. BTW, what "format" is the "data at the incoming point"? David On Thu, 14 Mar 2002 22:48:48 +0100 Claudio Tagliola wrote: > Thanx all for the help (nice crash course Tony :) I'm looking at > ordering the book, it looks very good. > > What I understand from Spehro the 2's complement signing method is > easier to do math with compared to the highest bit sign. Display isn't > very important, that module has a separate pic, so it has time enough to > get the numbers displayed. The other end is a PC, so that has power > enough to convert it back to a 'normal' format. The math is much more > important, we have one module which has to do a fair amount of gonio > routines (calculate a heading from the three axis orientation), but > still only at about 10 Hz max, so that'll leave enough cpu cycles left > to get that done. > > However, as I'm using a C compiler, what would be the more advisable > route: convert data at the incoming point to a format the compiler can > handle or write some specific fixed point routines to handle the math I > want to do? From what I've read, the 12q4 format is good, with a range > of -2000 to 2000 and an accuracy of 0.067 (right? I messed up with the > range before, so a check can't hurt :). > > (Look out, ramblings ahead...) This range is mainly used for angles (no > surprise with a 360 value range), math is mostly navigation. So one > other option is a binary value for a full rotation (256 for example). If > you put this into the 12q4 format, the 4 bit accuracy will be converted > back to roughly 0.1 degree (0.0937 to be exact). However, this will make > some calculations a bit easier, as any overflow of the 8q4 fixed point > can be discarded, as that would point to the same direction again. Total > range would be -2880 to 2880. Hmm... That's a bit much for angles. > > Last ramble: 8q8 with scaled 256 as a full 360 degree rotation. This > would be easy math, 8q8 operator 8q8 with 16q8 result math routines are > plenty available. Most results can discard the highest 8 bits, so that > would result in nice clean code. Am I overlooking something here? > Problems I might encounter? > > Regards, > Claudio > > -- > http://www.piclist.com hint: The list server can filter out subtopics > (like ads or off topics) for you. See http://www.piclist.com/#topics > -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.