Converting an integer to a string is easy with itoa(), if your library includes that function. ~ Bob Ammerman RAm Systems > -----Original Message----- > From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu] On Behalf > Of James Cameron > Sent: Thursday, November 06, 2014 6:54 AM > To: Microcontroller discussion list - Public. > Subject: Re: [PIC] >=20 > On Thu, Nov 06, 2014 at 12:41:20PM +0100, Tam=E1s Fekete wrote: > > Hi everyone! > > I am not sure if this problem is related to this topic. But I don't > > know where else it would fit. > > I am using a dspic33fj128mc802 with mplab xc16 compiler. I have to > > read data from an ADC at about 1ms intervals. The data that I get is a > > floating point number. I convert this number into a string using the > > function sprintf. Send out the string. At the PC side I receive and > > save the data with putty.exe. Then save the session in a .dat file. I > > can use this .dat file with matlab to plot the results. > > > > The problem is that sprintf really slows down the process. I should be > > taking samples at about 1ms intervals and because of the sprintf > > function this is between 5-7 mseconds. I checked this with an > > oscilloscope and without the sprintf function I can get down to even > > less than 1ms intervals easily. > > > > If anybody could suggest a faster way to make a string out of a > > floating point number or another way to send and receive the data I > > would be very thankful. >=20 > Yes, I've had sprintf take all the time it likes. >=20 > What I would do is read the data from ADC registers and either transmit i= t as > is, or encode it as hexadecimal. Then do the conversion on the PC side. >=20 > But I don't know that chip, so I can't be specific. >=20 > Also, I don't know the compiler or library you mention, so I don't know what > other functions might be available. I would check for ecvt or some > equivalent, and compare conversion time against sprintf. >=20 > -- > James Cameron > http://quozl.linux.org.au/ > -- > http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .