From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,LOTS_OF_MONEY autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,f822ae7b0f7433c1 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!s34g2000cwa.googlegroups.com!not-for-mail From: "Talulah" Newsgroups: comp.lang.ada Subject: Re: Translating an embedded C algorithm Date: 17 Jan 2007 05:31:28 -0800 Organization: http://groups.google.com Message-ID: <1169040688.133180.20300@s34g2000cwa.googlegroups.com> References: <1168871816.263502.212100@11g2000cwr.googlegroups.com> <45ae0afb$0$22524$39db0f71@news.song.fi> NNTP-Posting-Host: 212.248.198.150 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Trace: posting.google.com 1169040700 5526 127.0.0.1 (17 Jan 2007 13:31:40 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 17 Jan 2007 13:31:40 +0000 (UTC) In-Reply-To: <45ae0afb$0$22524$39db0f71@news.song.fi> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1,gzip(gfe),gzip(gfe) X-HTTP-Via: 1.1 ukman005.uk.landisgyr.com:3128 (squid/2.5.STABLE10) Complaints-To: groups-abuse@google.com Injection-Info: s34g2000cwa.googlegroups.com; posting-host=212.248.198.150; posting-account=z8Bf2AwAAACTha-0EcZ9lFjw3-dKgDhx Xref: g2news2.google.com comp.lang.ada:8222 Date: 2007-01-17T05:31:28-08:00 List-Id: Thanks everyone for your very valuable comments. I'm sorry that the C code I provided had a few problems - I had taken it out of a previous project of mine and edited it for a stand-alone function, but overlooked the values of the constants, and the comment in the header returning INVALID_TEMPERATURE (which was originally FFFF hex), and a couple of other things. To answer Jeffrey Carter's assertion that I am not qualified to write this book, I can only answer that since the majority of embedded RT projects ARE written in C, then the majority audience for the book will be interested in seeing examples written in C. That is no reflection on the "quality" of the language, but is just facing facts. Secondly, the product that this code came from is a domestic electricity meter for India, a market of 18 million devices per year. This is not a safety-critical product at all, but one which in those volumes must be designed for the lowest cost possible. Hence the use of 4 diodes as a temperature sensor, and hence (this may get more argument) the use of C rather than Ada. Crossing an 8k ROM boundary (the current code is just over 32kbytes) adds 3 pence (UK) to the cost on this microcontroller (Renesas H8/3827). Multiply that by 18 million and the resulting half million UK pounds is the reason I program in C. Thirdly, I am thick-skinned enough to brush off rudeness from newsgroup posters, it is just a shame that you decided not to post any useful comments. By asking you kind people for help in reproducing the example in Ada, it hopefully will allow readers to see the advantages that Ada can give them, and encourage them to research Ada as a possible language for future products that would benefit from these advantages, but also to understand the disadvantage of code size and speed (hard hat firmly in place after that!). I understand now that a direct translation of the code into Ada would not be a good illustration of the Ada language, and that an example which performed the same calcuation, but added the additional useful features would better serve. I have been sent an example written by a member of your newsgroup which does this, introducing better protection. I will also write a section in the text describing why a direct translation is a bad idea, and demonstrate how the extra features have made the code much more reliable. Finally, I regret adding the section reading the calibration factor from EEPROM!!! This is irrelevant to what I am trying to do with this example anyway (which is to see how a simple algorithm is implemented in different languages), and I will remove it. It is in the original C code on the electricity meter of course. Thanks again for all this discussion, it is vey useful for me. regards, paul