Jump to content
  • 0

unstable "analog.read" function behavior with chipKIT WiFire


tnag

Question

I am developing a wireless data logger using Analog Shield and chipKIT WiFire, and am struggling with unstable "analog.read" function behavior.

My code steps are as follows: 1) acquire analog voltage with Analog Shield, 2) save data into SD and 3) send the data with UDP over WiFi.

It works sometimes, but most of the time, it stops at an analog.read function. I cannot understand this inconsistent behavior. Below is the sample code which reproduces the same issue.

----- code starts from here -----
#include <MRF24G.h> // sketch works if this line is commented out
#include <DEIPcK.h> // sketch works if this line is commented out
#include <DEWFcK.h> // sketch works if this line is commented out
#include <analogShield.h>
#include <SPI.h> // include SPI.h after analogShield.h inclusion. otherwise fails

void setup()
{
    Serial.begin( 9600 );
}

void loop()
{
    unsigned int count = analog.read( 0, false );
    Serial.println( count );
    delay( 50 );
}
----- code ends -----

First, I doubt power shortage, so I have tried two different power supply configuration: via UART(J1), and an external 9V supply via DC plug(J15) with J16 jumper setting set to EXT, but no luck.

Is there any possibility of library conflicts? FYI, I use modified version of "analogShield.h" library downloaded from https://forum.digilentinc.com/topic/2211-analog-shield-and-chipkit-wifire-compatibility/

Any input would be greatly appreciated.

Link to comment
Share on other sites

11 answers to this question

Recommended Posts

Hi tnag,

 I would first make sure that you have the most recent version of arduino 1.6.12 and the most recent chipKit core which is 1.3.1. I was able to upload your sketch as well as the passthrough example multiple times with the wi-fire and analog shield with no issue. I did not verify voltage but i did verify serial communication.  

thank you,

Jon

wi_fire_esc.jpg

Link to comment
Share on other sites

Thank you for checking the code on your environment.

I have tested with another WiFire board and it worked without any problem. The revision is "C" on both boards. I wonder what could be wrong with the other board. It worked with single task programs - just UDP communication, or just ADC. It fails if these UDP and ADC tasks are combined.

Is there any possibility of having different configurations such as firmware version?

Link to comment
Share on other sites

Hi tnag,
 

Go to file ->preferences and click show verbose output during compilation and upload and then upload the sketch it will show you a whole bunch of information about the process that you can compare with the other wi-fire if you still have access to it. Hopefully this will show were the difference is.

thank you,

Jon

Link to comment
Share on other sites

Hi Jon,

Thanks for the advise.

I have set the IDE preference, compiled and uploaded a sketch on both chipKIT WiFire boards. Except for COM port, a temporary folder name (e.g. arduino_build_570134) and Program rate, the messages are identical and I could not file any difference. I have copied these messages into two separate text files and used WinMerge to compare them.

Is there any other approach to try?

Link to comment
Share on other sites

Hi tnag,

So I only have the analogshield library at the path C:\Users\jpeyron\Documents\Arduino\libraries as shown below. If i add the other librarys there is causes many errors which starts with the read function in the analog.read because the chipkit core includes all the libraries exept the analogshield. Do you have the other libraries included in your folder with a similar path as C:\Users\jpeyron\Documents\Arduino\libraries. If so remove them from that folder and let me know what happens.

thank you,

Jon

wifire_esc.jpg

Link to comment
Share on other sites

Hi Jon,

I only have the analog shield library in the user library folder. Actually, I have uninstalled all the Arduino related files including Arduino15 folder in user AppData, and reinstalled Arduino IDE etc. for the debugging purpose a little while ago.

 

img.PNG

Link to comment
Share on other sites

Hi Jon,

It does not give me an error message but just hangs when the "analog.read" does not execute properly. 

I have downloaded and installed MPIDE (mpide-0150-windows-20150820) and tried on both WiFire boards. This time, it failed at "SD.begin" function all the time. 

I found the forum entry and it seems that a loop rate should be adjusted for a board clock rate: https://forum.digilentinc.com/topic/1353-problems-with-wi-fire-and-sd-card/#comment-4617

It says "change the number of NOPs to (# of NOPS * 200)/80" in the file "Sd2Card.cpp", but I think I need more information. 

Link to comment
Share on other sites

Hi tnag,

Since i have not been able to duplicate your issue with the wi-fire i would suggest to either try debugging the libraries using Serial.printl( ); in arduino or mpide. You could also use something like this using mpide and mplabx to have a real debugger. 

thank you,

Jon

 

Link to comment
Share on other sites

Hello Jon,

Thanks for your help.

Before closing this issue, let me ask one thing. Is the Analog Shield officially supported by chipKIT WiFire Rev.C? If so, can you think of this as an initial failure? The other board has never showed any symptom and your environment as well.

Regards,

tnag

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...