Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

George Antoniadis's Content

There have been 25 items by George Antoniadis (Search limited from 29-March 23)


By content type

See this member's

Sort by                Order  

#23836 Netduino Firmware v4.2.0 RC4 (Netduino + Netduino Plus)

Posted by George Antoniadis on 06 February 2012 - 07:43 AM in Beta Firmware and Drivers

Just in case people forget these two things. 1) You MUST install the new bootloader http://wiki.netduino....ashx?HL=sam,ba 2) You MUST use the MFDeploy from 4.2 framework, 4.1 MFDeploy WILL cause you problems. - Chris thanks for this RC, it has been long awaited for and the bugs fixed will save lots of asses! :P



#19160 PowerState.RebootDevice soft/hard option.

Posted by George Antoniadis on 14 October 2011 - 08:49 AM in Netduino 2 (and Netduino 1)

I'm using the
PowerState.RebootDevice
method and I was wondering what the differences between the soft/hard options are and when each should be used.

Thanks! :)



#18328 Socket.Connect blocks all threads?

Posted by George Antoniadis on 22 September 2011 - 01:45 PM in Netduino Plus 2 (and Netduino Plus 1)

In 4.2 socket.connect() should work much better. Can you provide the code that kills it? ps. please post the 4.2 version you are using too.



#18042 Mono bootloader and 4.2beta

Posted by George Antoniadis on 15 September 2011 - 12:41 PM in Beta Firmware and Drivers

Ok, after a lot of trolling on the forums I figured out that the problem is AppDomains: False on the 4.2 firmware. Is this something that can be changed without the 4.2 source? Thanks.



#18036 Installing application over TCP

Posted by George Antoniadis on 15 September 2011 - 09:36 AM in Netduino Plus 2 (and Netduino Plus 1)

Hey, I was looking for the same thing and stumbled upon this thread by Chris: http://forums.netdui...nd-sample-apps/ This is essentially an app that tries to dynamically load a PE application and execute it. It works perfectly in 4.1.x but not in 4.2 (http://forums.netdui...der-and-42beta/) I modified it a bit so that when it boots it has two options, run the core application or if it doesn't exist or cannot load, load a recovery.pe that will connect to a server and download the core.pe again and reboot. I'll try to make a complete example in the next couple of days and post it. If you have any luck/questions please post! ^_^



#17918 Mono bootloader and 4.2beta

Posted by George Antoniadis on 13 September 2011 - 10:39 AM in Beta Firmware and Drivers

I was playing around with the Mono Bootloader that allows running PEs from the SD card.
http://forums.netdui...nd-sample-apps/

Everything works as excepted on the 4.1.1beta firmware but the Bootloader dies when being run against the 4.2beta.
The problem seems to be that some stuff have been removed (maybe for the sake of ram/rom?).

netduinoAppClassInstance = AppDomain.CurrentDomain.CreateInstanceAndUnwrap("MonoNetduinoApp, Version=1.0.0.0", "MonoNetduinoApp.Program");
Gets caught with:
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'MonoNetduinoApp'
A first chance exception of type 'System.NotImplementedException' occurred in mscorlib.dll

Any ideas if the bootloader could work some how on the 4.2b?

Thanks! :)



#16193 Netduino with 24Bit ADC (LTC2400) Help.

Posted by George Antoniadis on 02 August 2011 - 04:18 PM in Netduino Plus 2 (and Netduino Plus 1)

Hey Richard, if you need any help please do ask :)



#15898 Netduino Plus Firmware v4.2.0 BETA 1

Posted by George Antoniadis on 25 July 2011 - 11:42 AM in Beta Firmware and Drivers

Happens to me too quite a lot. Same setup win7 64 / vs 2010. Ctrl+break-ing the deployment and resetting the board seems to be the only solution I have found. Has the netduino driver been updated for the 4.2 beta?



#15785 Netduino Plus Firmware v4.2.0 BETA 1

Posted by George Antoniadis on 22 July 2011 - 01:50 PM in Beta Firmware and Drivers

Have you tried the PowerState.Reboot method that's built into .NET MF?


Ahem. Err, no I hadn't tried it :/
Seems to be working just fine, both the soft and hard options.
/facepalm

Thanks a million Chris :)



#15784 Socket.Connect blocks all threads?

Posted by George Antoniadis on 22 July 2011 - 01:45 PM in Netduino Plus 2 (and Netduino Plus 1)

I actually wanted to test the bleeding edge of 4.2beta2 since a couple of problems I had seem to be resolved in the issue tracker with a note "fixed for beta2" but can't find a public repository for its source. The bug fix is dated 15th of july but the latest commit on the head is july 9th :? Sorry I wasn't more clear before.



#15778 Netduino Plus Firmware v4.2.0 BETA 1

Posted by George Antoniadis on 22 July 2011 - 01:16 PM in Beta Firmware and Drivers

I just noticed this on the changelog: 13. Enhanced deployment reliability (software reset enhancements) Has a proper reset method been introduced that could be called via code to reset the netduino? The GPIO to reset pin method doesn't really work so a proper software reset would be nice.



#15772 Socket.Connect blocks all threads?

Posted by George Antoniadis on 22 July 2011 - 07:36 AM in Netduino Plus 2 (and Netduino Plus 1)

Without trying to sound pushy or something - simply wondering: Is there some guide on how to build the netduino firmwares from svn or some other version control system? Of course all the classic disclaimers will be taken for granted: no bitching on bugs, no bug reports on testing code and if it gets bricked we'll use it as a door stopper! ^_^ I simply want to test some bug fixes like the sockets and possible com fixes. Thanks in advance.



#15448 Socket.Connect blocks all threads?

Posted by George Antoniadis on 14 July 2011 - 07:16 AM in Netduino Plus 2 (and Netduino Plus 1)

I posted a basic bug report on the sockets connect timeouts and blocking. http://netmf.codeple...m/workitem/1089 Please vote for it if you are interested so maybe someone will take the time and help! :D



#15444 Socket.Connect blocks all threads?

Posted by George Antoniadis on 14 July 2011 - 06:56 AM in Netduino Plus 2 (and Netduino Plus 1)

Vincent as I said in the previous post the problem occurs (at least in 4.2b1) on the socket connection when the endpoint ip is not reachable or the cable is unplugged. The socket connection doesn't have a timeout property and the thread will never get disposed. On your code the problem is on the .connect and not on the new socket part. Consider adding your socket stuff in a separate thread for the time being until we find a proper way to do this. Also please remember that the threads will keep alive if they don't manage to connect and may pile up.



#15179 Socket.Connect blocks all threads?

Posted by George Antoniadis on 07 July 2011 - 01:18 PM in Netduino Plus 2 (and Netduino Plus 1)

Before posting a bug report please verify this too.
The following code behaves differently on 4.1.x and 4.2b1. (Make sure the ip doesn't exist on your LAN or that the ethernet is not connected)

static void Main()
        {
            new Thread(BlinkStatusLed).Start();
            new Thread(Connect).Start();
        }

        static void Connect()
        {
            try
            {
                Debug.Print("TRY");
                Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                s.Connect(new IPEndPoint(new IPAddress(new byte[] { 10, 10, 0, 43 }), 80));
                Debug.Print("DONE");
            }
            catch (SocketException e)
            {
                Debug.Print("THROW");
                throw;
            }
        }

        static void BlinkStatusLed()
        {
            OutputPort onboardLed = new OutputPort(Pins.ONBOARD_LED, false);
            while (true)
            {
                onboardLed.Write(!onboardLed.Read());
                Thread.Sleep(500);
            }
        }

On 4.1.x: Blocks the blink led thread and never reaches DONE or THROW.
On 4.2b1: The blink led thread keeps working as expected but never reaches DONE or THROW.

4.2b1 Is a very good step but the connection timeout cannot be set.
There are two timeouts available on the socket (SendTimeout and ReceiveTimeout) but not one for connect.
In the normal .NET frameworks in order to allow for Connection timeouts the AsyncCallback and socket.BeginConnect must be used, but in the micro framework the BeginConnect doesn't exist. So that's a no-go.

I tried hacking up a timeout emulation class for a project I am working on but I seem to be having a problem with the Thread.Abort() method.

How it works:
You create a new object ConnectionExtraThreaded, give it the endpoint ip, three callbacks (success, failure, timeout) and a timeout in milliseconds.

The object will start two threads. Connection and Timeout.
When the user specified timeout is reached the Timeout Thread will try to Abort() the Connection Thread.

This is where everything gets messy.
It keeps throwing an exception over and over again. I understand that this is normal .NET activity but can't find a way to properly kill the connection thread.

Any hints/ideas?

using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.NetduinoPlus;

namespace sample_sockets
{
    public delegate void ConnectionExtraThreadedSuccessCallback();
    public delegate void ConnectionExtraThreadedFailureCallback();
    public delegate void ConnectionExtraThreadedTimeoutCallback();

    public class ConnectionExtraThreaded
    {
        private IPEndPoint endPoint;
        private int millisecondsTimeout;
        private ConnectionExtraThreadedSuccessCallback successCallback;
        private ConnectionExtraThreadedFailureCallback failureCallback;
        private ConnectionExtraThreadedTimeoutCallback timeoutCallback;
        private Thread connectionThread;
        private Thread timeoutThread;

        public ConnectionExtraThreaded(IPEndPoint endPoint, ConnectionExtraThreadedSuccessCallback successCallback,
 ConnectionExtraThreadedFailureCallback failureCallback, ConnectionExtraThreadedTimeoutCallback timeoutCallback, 
 int millisecondsTimeout)
        {
            this.endPoint = endPoint;
            this.millisecondsTimeout = millisecondsTimeout;
            this.successCallback += successCallback;
            this.failureCallback += failureCallback;
            this.timeoutCallback += new ConnectionExtraThreadedTimeoutCallback(this.ConnectionThreadKill);
            this.timeoutCallback += timeoutCallback;

            this.connectionThread = new Thread(this.Connect);
            this.timeoutThread = new Thread(this.Timeout);

            this.connectionThread.Start();
            this.timeoutThread.Start();
        }

        private void Timeout()
        {
            Thread.Sleep(this.millisecondsTimeout);
            Debug.Print("ConnectionExtraThreaded: Connection timed out after " + this.millisecondsTimeout / 1000 + 
" seconds. Executing timeout callback.");
            this.timeoutCallback();
        }

        private void ConnectionThreadKill()
        {
            Debug.Print("ConnectionExtraThreaded: Killing connection thread.");
            this.connectionThread.Abort();
        }

        private void Connect()
        {
            try
            {
                Debug.Print("ConnectionExtraThreaded: Attempting connection.");
                Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                s.Connect(endPoint);
                Debug.Print("ConnectionExtraThreaded: Connection was successful. Executing success callback.");
                this.successCallback();
            }
            catch (System.Threading.ThreadAbortException e)
            {
                Debug.Print("ConnectionExtraThreaded: Connection aborted.");
            }
            catch (Exception e)
            {
                Debug.Print("ConnectionExtraThreaded: Connection died.");
            }

        }
    }

    public class Program
    {
        static void Main()
        {
            new Thread(BlinkStatusLed).Start();
            new Thread(Connect).Start();
        }

        static void Connect()
        {
            new ConnectionExtraThreaded(new IPEndPoint(new IPAddress(new byte[] { 10, 10, 0, 43 }), 80), 
  connectionSuccess, connectionFailure, connectionTimeout, 5000);
        }

        static void connectionSuccess()
        {
            Debug.Print("SUCCESS");
        }

        static void connectionTimeout()
        {
            Debug.Print("TIMEOUT");
        }

        static void connectionFailure()
        {
            Debug.Print("FAILED");
        }

        static void BlinkStatusLed()
        {
            OutputPort onboardLed = new OutputPort(Pins.ONBOARD_LED, false);
            while (true)
            {
                onboardLed.Write(!onboardLed.Read());
                Thread.Sleep(500);
            }
        }
    }
}



#15116 Socket.Connect blocks all threads?

Posted by George Antoniadis on 06 July 2011 - 08:19 AM in Netduino Plus 2 (and Netduino Plus 1)

I keep having weird problems with network connectivity and sockets. If the network cable is not plugged in or the endpoint is not reachable it keeps on trying pausing all threads. Also there still doesn't seem to be a timeout for when it will stop trying to connect. Is there a tried and proven way to verify ethernet connectivity and to actually manage to use sockets without pausing everything in 4.2?



#15044 Socket.Connect blocks all threads?

Posted by George Antoniadis on 05 July 2011 - 12:23 PM in Netduino Plus 2 (and Netduino Plus 1)

Is there an update about this on the 4.2 beta?



#13607 uIP Introduction

Posted by George Antoniadis on 25 May 2011 - 12:03 PM in General Discussion

The way the MF currently works with socket is killing me at the moment so reading about uIP makes me a happy man. How easy would it be to make this play nice with a netduino plus?



#13445 Netduino with 24Bit ADC (LTC2400) Help.

Posted by George Antoniadis on 19 May 2011 - 08:08 AM in Netduino Plus 2 (and Netduino Plus 1)

Mario thanks for still being around :)
I seem to have solved the whole thing.

1) Configuration is like this for the schematic I have used:
            return new SPI.Configuration(
               ChipSelectPin,
               false,
               200,
               200,
               false,
               true ,
               1000,
               SPI.SPI_module.SPI1
               );

2) The first line is byte stream from the ADC and the second one is the usable bits
00101000 10010000 01101101 00010011
xxx01000 10010000 01101101 0001xxxx

3 and final) This last thing has freaked me out big time.
The calculation I did to see the Volt value was this:
3000 * adcValue / System.math.pow(2, 24)

This resulted in something obscene.
When a colleague was messing around with my code he changed it to this:
3000.0 * adcValue / System.math.pow(2, 24)

Which actually gave the correct volt value!!!
I don't really get why this happens but I assume it has something to do with my declaration of ltw
Int32 ltw = new byte();
ltw = 0;
And the fact that i'm doing binary calculations on an integer.
So I guess that .net wasn't able to automatically cast it to the correct type.

In any case it seems to be working as expected now.
I'll pack it up a bit better and post it here for future reference.

Mario I'd like to thank you for all your help and patience. :)

G.



#13374 Netduino with 24Bit ADC (LTC2400) Help.

Posted by George Antoniadis on 17 May 2011 - 01:24 PM in Netduino Plus 2 (and Netduino Plus 1)

Ok some things are more clear to me now but others are still foggy.

1) Mario, you said that my clock source should be "external".
According to the schematic I followed for the ADC design the f0 pin of the LTC2400 goes to the VCC.
Posted Image
This should result in the LTC2400 using the internal clock with a 50hz rejection (I have no idea what this rejection is)
Posted Image

What should I change the f0 pin to use an external clock?

2) I got my hands on a scope and I tried to figure out some stuff but without much help.
The top line is the CS and the bottom is the output.
Posted Image

This is a single transaction and the result that I got from my code was this:
[0]: 00101000
[1]: 10010000
[2]: 01101101
[3]: 00010011

3) As for the configuration I changed the clock_edge to true as according to the following graph from the datasheet it seems that when the internal clock is used, the data is sampled on the rising of the clock.
Posted Image



#13221 Netduino with 24Bit ADC (LTC2400) Help.

Posted by George Antoniadis on 13 May 2011 - 10:22 AM in Netduino Plus 2 (and Netduino Plus 1)

I'm currently trying to get my hands on an oscilloscope. Could you please let me know what I need to check with it? Thanks in advance.



#13172 Netduino with 24Bit ADC (LTC2400) Help.

Posted by George Antoniadis on 12 May 2011 - 01:43 PM in Netduino Plus 2 (and Netduino Plus 1)

ps. I'll try to find a scope, till then would a polymeter help?



#13171 Netduino with 24Bit ADC (LTC2400) Help.

Posted by George Antoniadis on 12 May 2011 - 01:40 PM in Netduino Plus 2 (and Netduino Plus 1)

Mario thank you very much for your help, it's greatly appreciated, I'll try not to bore you much with this :P

I tried to pull up the pin6 with a 1K ohm resistor on the 3V3 without any luck.

This is my current SPI configuration.
return new SPI.Configuration(
  ChipSelectPin,
  false,
  0,
  0,
  false,
  false,
  defaultClockRateKHz,
  SPI.SPI_module.SPI1
);

In order to configure the SPI for sampling on the RISING edge should be altered like this:
return new SPI.Configuration(
  ChipSelectPin,
  false,
  0,
  0,
  false,
  true,
  defaultClockRateKHz,
  SPI.SPI_module.SPI1
);
But any ideas on the correct clock rate and Clock_IdleState values?

This is sample from the readArray[] values:
[0]: 01010001
[1]: 00001001
[2]: 10010011
[3]: 10001101
ps. The data are with the pull up on the board

I then "& 0x1F" the first [0] byte to clear up the first bits as they should be junk (according to the arduino/working code).
[0]: 00010001

Then the bytes get shifted to the left and append the next one as 0-1-2-3 which results to this.
[ltw]: 00010001000010011001001110001101

Finally the 4 last bytes are stripped off as they should contain junk data.
[ltw]: 00000101000100001001100100111000

Is my logic sane?



#13162 Netduino with 24Bit ADC (LTC2400) Help.

Posted by George Antoniadis on 12 May 2011 - 11:27 AM in Netduino Plus 2 (and Netduino Plus 1)

Thanks for a fast responce mario. At first I had both the write and read arrays set to 4 bytes and there was no difference. I changed it again now to make sure and still gives out the same results.



#13156 Netduino with 24Bit ADC (LTC2400) Help.

Posted by George Antoniadis on 12 May 2011 - 08:19 AM in Netduino Plus 2 (and Netduino Plus 1)

I'm fairly new with netduino, had mine (plus) for couple of days now and I'm very pleased with it so far.
My electronics skills are pretty basic so please bare with me and my pretty long rant :)

Any help/hints are greatly appreciated.

I've build a 24bit ADC using the LTC2400 based on the this.
This was initially made for arduino on which works like a charm but now I need to move this to my netduino plus.

Looking around in the LTC2400 datasheet for the SPI configuration values helped a bit but some things like "SS Active", "Clock idle" and "Clock rate" are still missing as I am not sure what I should be looking for.

I've created a test project based on the MCP320X Test by GDSever but ended up changing most of the ReadADC method to match the code from my arduino project (provided in the end of the post).

The end results is pretty random, some times it seems to work (usually when voltage is around 1.6v for some weird and most likely random reason).
Let me try to explain what happens.

byte[] writeArray = new byte[];
byte[] readArray = new byte[8];
spi.WriteRead(writeArray, readArray);

This populated the readArray with data on the first 4 bytes and the rest are full of 1111s;
To me this seems wrong, could it be due to SPI configuration values?

Due to the fact that the ADC is 24 bit, the data is split into 4 bytes.
The first byte seems to contain the integer's sign (-/+) and some leading junk data.
The last byte seems have 4 bits junk data in the end.

Does SPI.WriteRead do something with the binary data? Reverse their order or something?

What else might I be missing?

C# ReadADC method.
public Int32 ReadADC(uint numSamples = 1)
{
    Int32 ltw = new byte();

    byte[] writeArray = new byte[4];
    byte[] readArray = new byte[8];

    // Send the command and read the response.
    SPI.Configuration config = CurrentConfig();
    using (SPI spi = new SPI(config))
    {
        Thread.Sleep(100);
        spi.WriteRead(writeArray, readArray);

        ltw = 0;

        bool sig = false;
        if ((readArray[0] & 0x20) == 1)
        {
            sig = true;
        }

        readArray[0] &= 0x1F;
        ltw |= readArray[0];
        if (sig)
        {
            ltw |= 0xF0;
        }
        ltw <<= 8;

        ltw |= readArray[1];
        ltw <<= 8;

        ltw |= readArray[2];
        ltw <<= 8;

        ltw |= readArray[3];

        ltw = ltw / 16;

        spi.Dispose();
    }

    return ltw;

}

Arduino code.
/* LTC2400 24 Bit ADC Test
* Connect an LTC2400 24 Bit ADC to the Arduino Board in SPI Mode
*
*
*
* KHM 2009 /  Martin Nawrath
* Kunsthochschule fuer Medien Koeln
* Academy of Media Arts Cologne

*/
#include <Stdio.h>

#ifndef cbi
#define cbi(sfr, bit)     (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit)     (_SFR_BYTE(sfr) |= _BV(bit))
#endif

#define LTC_CS 2         // LTC2400 Chip Select Pin  on Portb 2
#define LTC_MISO  4      // LTC2400 SDO Select Pin  on Portb 4
#define LTC_SCK  5       // LTC2400 SCK Select Pin  on Portb 5

void setup() {

 cbi(PORTB,LTC_SCK);      // LTC2400 SCK low
 sbi (DDRB,LTC_CS);       // LTC2400 CS HIGH

 cbi (DDRB,LTC_MISO);
 sbi (DDRB,LTC_SCK);

 Serial.begin(57600);
 // init SPI Hardware
 sbi(SPCR,MSTR) ; // SPI master mode
 sbi(SPCR,SPR0) ; // SPI speed
 sbi(SPCR,SPR1);  // SPI speed
 sbi(SPCR,SPE);   //SPI enable

 Serial.println("LTC2400 ADC Test");

}
float volt;
float v_ref=3.0;          // Reference Voltage, 5.0 Volt for LT1021 or 3.0 for LP2950-3

long int ltw = 0;         // ADC Data ling int
int cnt;                  // counter
byte b0;                  //
byte sig;                 // sign bit flag
char st1[20];             // float voltage text

/********************************************************************/
void loop() {

 cbi(PORTB,LTC_CS);             // LTC2400 CS Low
 delayMicroseconds(1);
 if (!(PINB & (1 << PB4))) {    // ADC Converter ready ?
   //    cli();
   ltw=0;
   sig=0;

   b0 = SPI_read();             // read 4 bytes adc raw data with SPI
   if ((b0 & 0x20) ==0) sig=1;  // is input negative ?
   b0 &=0x1F;                   // discard bit 25..31
   ltw |= b0;
   ltw <<= 8;
   b0 = SPI_read();
   ltw |= b0;
   ltw <<= 8;
   b0 = SPI_read();
   ltw |= b0;
   ltw <<= 8;
   b0 = SPI_read();
   ltw |= b0;

   delayMicroseconds(1);

   sbi(PORTB,LTC_CS);           // LTC2400 CS Low
   delay(200);

   if (sig) ltw |= 0xf0000000;    // if input negative insert sign bit
   ltw=ltw/16;                    // scale result down , last 4 bits have no information
   volt = ltw * v_ref / 16777216; // max scale

   Serial.print(cnt++);
   Serial.print(";  ");
   printFloat(volt,6);           // print voltage as floating number
   Serial.println("  ");

 }
 sbi(PORTB,LTC_CS); // LTC2400 CS hi
 delay(20);

}
/********************************************************************/
byte SPI_read()
{
 SPDR = 0;
 while (!(SPSR & (1 << SPIF))) ; /* Wait for SPI shift out done */
 return SPDR;
}
/********************************************************************/
//  printFloat from  tim / Arduino: Playground
// printFloat prints out the float 'value' rounded to 'places' places
//after the decimal point
void printFloat(float value, int places) {
 // this is used to cast digits
 int digit;
 float tens = 0.1;
 int tenscount = 0;
 int i;
 float tempfloat = value;

 // if value is negative, set tempfloat to the abs value

   // make sure we round properly. this could use pow from
 //<math.h>, but doesn't seem worth the import
 // if this rounding step isn't here, the value  54.321 prints as

 // calculate rounding term d:   0.5/pow(10,places)
 float d = 0.5;
 if (value < 0)
   d *= -1.0;
 // divide by ten for each decimal place
 for (i = 0; i < places; i++)
   d/= 10.0;
 // this small addition, combined with truncation will round our

 tempfloat +=  d;

 if (value < 0)
   tempfloat *= -1.0;
 while ((tens * 10.0) <= tempfloat) {
   tens *= 10.0;
   tenscount += 1;
 }

 // write out the negative if needed
 if (value < 0)
   Serial.print('-');

 if (tenscount == 0)
   Serial.print(0, DEC);

 for (i=0; i< tenscount; i++) {
   digit = (int) (tempfloat/tens);
   Serial.print(digit, DEC);
   tempfloat = tempfloat - ((float)digit * tens);
   tens /= 10.0;
 }

 // if no places after decimal, stop now and return
 if (places <= 0)
   return;

 // otherwise, write the point and continue on
 Serial.print(',');

 for (i = 0; i < places; i++) {
   tempfloat *= 10.0;
   digit = (int) tempfloat;
   Serial.print(digit,DEC);
   // once written, subtract off that digit
   tempfloat = tempfloat - (float) digit;
 }
}

Attached Files





home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.