New newlib test builds available 20120429

Announcements for new builds and MPIDE enhancements
Post Reply
ricklon
Posts: 178
Joined: Sun May 22, 2011 6:59 am

New newlib test builds available 20120429

Post by ricklon » Mon Apr 30, 2012 1:25 am

Hi All, I'm vey glad to get some new builds up here. This includes the latest newlib updates from Jason.

Latest status:
https://github.com/chipKIT32/chipKIT32- ... ate=closed

Linux32
https://github.com/downloads/chipKIT32/ ... 9-test.tgz

Mac OS X
https://github.com/downloads/chipKIT32/ ... 9-test.dmg

Windows
https://github.com/downloads/chipKIT32/ ... 9-test.zip

-_Rick

jasonk
Posts: 100
Joined: Mon May 23, 2011 6:38 am
Location: Chandler, Arizona
Contact:

Re: New newlib test builds available 20120429

Post by jasonk » Mon Apr 30, 2012 7:21 am

Thats great! Some of the changes in the compiler and Newlib libc are:
  • Addressed a problem with floating-point conversions (%f) in formatted IO functions such as sprintf
  • Reduced the size of the stdout and stdin buffers in order to reduce data-memory usage
  • Reduced the malloc page size in order to reduce the heap size requirements and better tune the algorithm for small-memory devices
  • Added (compiler-only) support for the PIC32MX1 and MX2 families. Support for the Arduino/chipKIT core and libraries will be coming soon.
Jason Kajita
Microchip Technology
Follow me on Twitter

rasmadrak
Posts: 218
Joined: Mon Aug 15, 2011 9:21 pm
Location: Sweden
Contact:

Re: New newlib test builds available 20120429

Post by rasmadrak » Mon May 07, 2012 12:12 am

Hi there!

Just wanted to say that SD card loading works A LOT better in this release! Thanks!

WestfW
Posts: 148
Joined: Wed May 25, 2011 12:17 am

Re: New newlib test builds available 20120429

Post by WestfW » Tue May 08, 2012 6:30 am

So is newlib just an experiment, or is it the future of ChipKit?

jasonk
Posts: 100
Joined: Mon May 23, 2011 6:38 am
Location: Chandler, Arizona
Contact:

Re: New newlib test builds available 20120429

Post by jasonk » Tue May 08, 2012 7:15 am

Newlib is intended to be the future of the chipKIT compiler.
Jason Kajita
Microchip Technology
Follow me on Twitter

rasmadrak
Posts: 218
Joined: Mon Aug 15, 2011 9:21 pm
Location: Sweden
Contact:

Re: New newlib test builds available 20120429

Post by rasmadrak » Sat May 12, 2012 2:15 am

Hello again -

I found a bug (and the solution) in the latest SD card library.
It might have been reported before - but is still present.

In the file "Sd2Card.cpp" , on rows 380 and 403 it says "n = count - 1;" and " while (offset_++ < 514) spiRec();" respectively.

These should be changed to read:

n = count;
and
while (offset_++ < 512) spiRec();

Without these changes the last byte in each block will never be read...
If only the n = count is changed, the performance will drop until 514 -> 512 bytes (its' probably error checking/double loading) .

So -
I thought my bitpacking routine was faulty, but it turns out to be the library. It looked like it worked when I loaded an unpacked image, but the error was always there - just masked better.

Hope this helps anyone!

ronaldstanley
Posts: 6
Joined: Fri May 18, 2012 10:32 am

Re: New newlib test builds available 20120429

Post by ronaldstanley » Fri May 18, 2012 10:38 am

you can change the loop and then use it with the take other condition in the loop.

hdphilip
Posts: 39
Joined: Sat Apr 14, 2012 7:54 am

Re: New newlib test builds available 20120429

Post by hdphilip » Tue May 22, 2012 1:14 am

ok, here's something i ran across, I'd be curious if anyone can confirm it,

the following code is supposed to calculate the running average.

When i compile it under Mpide 0023 20111221 it works fine,
But when i compile it under Mpide 0023 20120429-windows-test, it has many Errors
i will say the errors do seem to be valid,

any ideas?

Code: Select all

const int numReadings = 20;// how many readings do we want to average
float readings[numReadings];      // the readings from the analog input
int index = 0;                  // the index of the current reading
float total = 0;                  // the running total
int averageS = 0;      


void setup(){
}

void loop(){ 
   
  running_average();
    }
  
  void running_average (){
  total= total - readings[index]; // subtract the last reading:        
  readings[index] = analogRead(0); // read from the sensor:
  total= total + readings[index];  // add the reading to the total:     
  index = index + 1;// advance to the next position in the array:                     
    if (index >= numReadings)   // if we're at the end of the array...           
        index = 0;    // ...wrap around to the beginning:                        
  averageS = total / numReadings;  // calculate the average: 

    }

Philip

User avatar
Demolishun
Posts: 31
Joined: Sun May 27, 2012 6:48 pm
Location: USA
Contact:

Re: New newlib test builds available 20120429

Post by Demolishun » Thu May 31, 2012 11:56 am

This version seems to have fixed the milis() issue I had with the November release. Thank you.

@hdphillip,
I am not sure what might be happening with your code, but you should consider using a filter rather than an average. A filter can be done on 2 samples at a time.

Here is a link that may help:
http://www.automationdirect.com/static/ ... er/ch8.pdf
This covers PID loops, but at the end it describes a digital filter. Remember like a loop it must be run at a specific interval to maintain frequency response. This means it is best to have the processed samples at a deterministic rate. Here is the equation they use for the filter in case the PLC code is harder to decipher:
(newsample - prevresult) * 0.2 + prevresult = prevresult

The 0.2 value is the filter value. The lower the value the increased number of samples to change a value. So the 0.2 is kind of like increasing the number of points in an average. As you can see you are only doing 1 multiplication, 1 subtraction, and 1 addition.

Now this is a low pass filter. It will tend to pass lower frequencies. Now you can change that operation by doing this:
This equation is wrong:
maxvalue - ((newsample - prevresult) * 0.2 + prevresult) = prevresult
Try this. It gives more weight to a rapidly changing signal:
((prevresult - newsample) * 0.2 + newsample) = prevresult

This will tend to pass higher frequencies. Combine these is different ways and you can create notch filters and band pass filters. Just make sure you are doing this at a deterministic rate (same time between calculations).

Have fun.

Post Reply