Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problems with PIC32-PINGUINO OTG SD card
18-04-2012, 06:06 PM,
#1
Problems with PIC32-PINGUINO OTG SD card
Hello,

For the past week I have been having trouble getting two things working on my new PIC32-PINGUINO OTG board. I would first like to address one issue - writing to the SD card.

My goal is to make a simple data logger which takes data from a analog input and write it to a text file on a micro SD card. I am using a Sandisk 8 GB FAT 32 formatted card with X3 branch working with Windows 7. (PYTHON 2.6) installed. The blink.pde example works perfectly and I can change the blink rate. As a start I have tried compiling the example program, DIR.pde which is included in the X3 branch.

I get this error from the compiler, (i.e. the SDCS define is missing), but the code compiles OK for my Pinguino micro board without these errors.

Board: PIC32 Pinguino OTG
Proc: 32MX440F256H
C:\Users\snsmith\Documents\pinguinox3\p32\include\pinguino\libraries/sd/sdmmc.c:29:15: error: 'SDCS' undeclared (first use in this function)
C:\Users\snsmith\Documents\pinguinox3\p32\include\pinguino\libraries/sd/sdmmc.c:42:15: error: 'SDCS' undeclared (first use in this function)
C:\Users\snsmith\Documents\pinguinox3\p32\include\pinguino\libraries/sd/sdmmc.c:48:15: error: 'SDCS' undeclared (first use in this function)
C:\Users\snsmith\Documents\pinguinox3\p32\include\pinguino\libraries/sd/diskio.c:249:2: error: 'SDCS' undeclared (first use in this function)
error while linking C:\Users\snsmith\Documents\pinguinox3\examples\10.Libraries\SD\Dir.o

I noticed that the #defines in the sdmmc.h file have been commented out for these boards.

// I/O definitions
#if defined(PIC32_PINGUINO) || defined (PIC32_PINGUINO_OTG)
//#define READ_LED 13
//#define WRITE_LED 13
//#define SDWP // Write Protect input
//#define SDCD // Card Detect input
//#define SDCS 8 // D8_MMC_#SS Card Select output
// #define SDCS 8 // RB13/MMC_#SS Card Select output
#endif

Can anyone give a suggestion on what to change in SDCS to make the code work correctly or is it not working yet? If someone can point me to the correct pin definition list for the OTG board I may be able to help fix the code issue (the correct values for the defines?). I really appreciate any help!

Thanks
Togz
Reply
18-04-2012, 06:42 PM, (This post was last modified: 20-04-2012, 10:10 AM by mf01.)
#2
RE: Problems with PIC32-PINGUINO OTG SD card
Hi Togz,

unfortunately the SD library in the x.3 branch appears to have been broken when support for the PIC32 Pinguino Micro was added at the end of March :-(.

Luckily it is not too difficult to "patch" the files to get it working again.

*** Update 20 Apr 2012 ***

Do NOT re-instate the #defines in the sdmmc.h file that have been commented out for the PIC32 Pinguino and PIC 32 Pinguino OTG boards.

Checking on the PIC32 Pinguino OTG schematic Pinguino Pin 13 is used not only by LED1, the green LED, but also for SD/MMC Pin 5 so using it as a Read or Write LED is likely to interact (probably unfavourably) with reading or writing data.

*** End of 20 Apr 2012 update ***

Firstly make sure that you have the latest version of the file:-

/p32/include/pinguino/libraries/sd/scmmc.h

(it was updated in r336/13 April 2012 to remove a spurious second "*/" at the end of the first multi-line comment at the start of the file.

Look in the folder that has all the Pinguino files and find the following files :-

/p32/include/pinguino/libraries/sd/fileio.c
/p32/include/pinguino/libraries/sd/fileio.h

In BOTH files change the line :-
Code:
#if !defined (PIC32_PINGUINO) && !defined (PIC32_PINGUINO_OTG) && !defined (PIC32_PINGUINO_MICRO)
to read
Code:
#if !defined (PIC32_PINGUINO_MICRO)

The line is line 41 in fileio.c and line 55 in fileio.h.

There is also an incorrect type declaration in in the DataLogger.pde example. This does stop the program from compiling or running but would be best to correct. In DataLogger.pde change the line that reads :-
Code:
int             i, b, l, btw, bw, br;
to read:-
Code:
UINT             i, b, l, btw, bw, br;

As noted above with the first change the DataLogger.pde compiles OK on my Ubuntu system, although there are some warnings in the stdout file. The change to the DataLogger.pde file noted above gets rid of some of the warnings (but not all of them :-( ) but they do not stop the program from compiling and running OK.

Regards
Board = PIC32-Pinguino-OTG Rev C
OS = Linux Unbuntu 11.10 till 26 Apr 2012
OS = Linux Unbuntu 12:04 from 27 Apr 2012
Reply
19-04-2012, 04:04 AM,
#3
RE: Problems with PIC32-PINGUINO OTG SD card
mf01,

The suggestion worked very well. I was able to write data to my SD card and read it on my PC. I still have issues with the Pinguino OTG driver and can't get the USB virtual serial port working, but that's a problem for tomorrow. The hardest part of it all was really getting Python installed.

Hopefully I will be able to develop a full data logger and share the code.

Thanks
Togz
Reply
19-04-2012, 10:28 AM,
#4
RE: Problems with PIC32-PINGUINO OTG SD card
Hi Togz,

what other functionality do you are you intending to include in your data logger ?

Also was there any particular reason that you started with the x.3 version of Pinguino. X.3 is the current development branch and as such can have problems due to unexpected interactions between files being changed.

It is possible (and not too difficult) to get the SD library running under x.2 which may give you a more stable platform for your experimentation. I have successfully run various versions of the SD library under x.2.

It may also be easier to get X.2 running as there are some pre-packaged installers for Windows available on http://code.google.com/p/pinguino32/downloads/list. If you use these you do not appear to have to install the various python, wxpython etc packages mentioned on the Pinguino Windows wiki page. You will probably also need to install the appropriate Windows drivers. If you are running Windows 7 see http://wiki.pinguino.cc/index.php/Windows_7 although I did notice that there is a file setup-libusb-win7-8bits.exe in the /extra folder within the Pinguino32.X folder created when you run the PinguinoX.2 rev305 setup.exe installer so it might be worth trying this before following the steps on the wiki.

Regards
Board = PIC32-Pinguino-OTG Rev C
OS = Linux Unbuntu 11.10 till 26 Apr 2012
OS = Linux Unbuntu 12:04 from 27 Apr 2012
Reply
19-04-2012, 02:46 PM,
#5
RE: Problems with PIC32-PINGUINO OTG SD card
Our data logger will have several spi based maxim thermocouple amplifiers, current measurement and voltage measurement and will record the data to the FAT 32 sd card. It would be good if the system was configurable from the USB virtual com port so we can connect to a terminal to setup the system. The OTG was great due to the battery charger.

The reason I was working with X3 was the FAT 32 file system. I was trying to get the X3 to port to X2 - I think now that the fixes are there for X3 I can port the SD library back to X2 based upon the forum posts about doing that. I couldn't get the FAT 32 system it to work with X2 because of the bugs in X3.

Does the CDC virtual Serial port work with X2 and what is the best instructions on getting the serial port to work with windows 7? I think I have seen some alternatives to getting that working on the board I. I will try some of them. I have gotten the CDC virtual USB drivers to work in the past with Microchip's examples, so it shouldn't be too bad.

I will definitely give it a try with X2 and report back on the results of the project.

Thanks
Togz
Reply
19-04-2012, 04:21 PM, (This post was last modified: 19-04-2012, 04:24 PM by mf01.)
#6
RE: Problems with PIC32-PINGUINO OTG SD card
Hi Togz,

if you copy all the files from the SD directory of your working X.3 versions into the corresponding directory in X.2/trunk, together with the X.3 SD.pdl32 file and the X.3 examples for the SD library into their corresponding directories then the SD library should work OK.

Since I wrote my earlier post this morning I have installed r305 x.2 from http://code.google.com/p/pinguino32/downloads/list onto a relatively new Windows 7 laptop. After running PinguinoX.2 rev305 setup.exe, I then ran setup-libusb-win7-8bits.exe which you should find in the Pinguino32X.2/extra folder created by the PinguinoX.2 rev305 setup.

Once that has been done I connected the Pinguino to the computer using a USB lead and put the Pinguino into boot loader mode. This triggered the automatic installation of the necessary drivers for uploading programs to the Pinguino board. You have to make sure that the installation of the drivers has been completed before either disconnecting the board or trying to upload a program. Once the installation of the drivers was complete I was able to transfer a program from the computer to the Pinguino board.

As a side note, the Pinguino board is only seen as a USB device if it is either in boot loader mode or running software that makes use of USB, such as CDC. It may be this that gave you difficulty in getting the board and your computer to talk to each other. It also means that the first time your run a program on the board using CDC additional drivers will probably need to be installed. This was definitely the case when I connected a PIC32 Pinguino OTG to a Windows Vista netbook this afternoon (I did not use the Windows 7 laptop as I did not have a terminal emulator on it - what terminal emulator software are you using ?).

Have you considered using 1-wire temperature sensors such as the DS18B20 for your temperature measurement. Initially they look quite complex to use, but if you only use one sensor per digital input/output they are relatively straightforward, particularly if you use dedicated power rather than parasitic power, and only need one pull-up resistor per sensor. Depending on how many temperature sensors you need, it is possible to use the pads for CONN3 on the PIC32 Pinguino OTG to get access to additional digital input/outputs.

Regards
Board = PIC32-Pinguino-OTG Rev C
OS = Linux Unbuntu 11.10 till 26 Apr 2012
OS = Linux Unbuntu 12:04 from 27 Apr 2012
Reply
19-04-2012, 11:49 PM,
#7
RE: Problems with PIC32-PINGUINO OTG SD card
mf01,

I had some excellent success today getting the X3 SD library datalogger example working with X2 and the suggestions you had made. One note was that I had trouble getting the CDC device driver to work as you mentioned. What worked for me was using the device driver posted at this thread in the forum posted by moreno. I used the datalogger.pde from X3 and made your changes. I was able to change the file names and write multiple files to the SD card. I commented out the return line so it would go ahead and write to the file without serial input.

http://forum.pinguino.cc/showthread.php?tid=3419

I am using Tera Term to try to get the CDC class working but no luck yet. I was able to get the PC to recognize the board on virtual serial port 10 but no luck getting it to write data yet - maybe it is a port setting. I will also try on my Vista and XP laptops later now that I have things working pretty well.

As for the temperature sensors that's a great suggestion although we need to use thermocouples for our application. So we'll be using MAX6675ISA+TCT-ND and trying to make it work with SPI bus which should be no problem.

When I get the CDC serial port class going I'll post the example of a new data logger application. I'm sure at this point it is a minor issue.

Togz!
Reply
20-04-2012, 10:19 AM,
#8
RE: Problems with PIC32-PINGUINO OTG SD card
Togz,

good to hear of your progress.

One thing I did find out whilst looking for something else and that is a possible reason why the #define lines were commented out in the sdmmc.h file. On the PIC32 Pinguino OTG board Pinguino Pin 13 is used not only for LED1 (the green LED) but also for the clock used for reading and writing data to the SD card. I have updated my earlier post in this thread to note this and advise against changing those lines. This is more for the sake of others reading this thread as I think you have moved past that point.

Regards
Board = PIC32-Pinguino-OTG Rev C
OS = Linux Unbuntu 11.10 till 26 Apr 2012
OS = Linux Unbuntu 12:04 from 27 Apr 2012
Reply
12-01-2013, 07:08 PM,
#9
RE: Problems with PIC32-PINGUINO OTG SD card
I have a Pinguino Pic 32 Micro Rev.B .
Where could I find a suitable SD logger demo? The one included in IDE x.3 includes RTC instructions (and who knows whatelse) hence is not compatible with MICRO version.
Reply
16-01-2013, 04:18 PM,
#10
RE: Problems with PIC32-PINGUINO OTG SD card
Hi jumpjack,

the existing datalogger example makes use of the RTCC library in two ways:-
  1. as a source of data to be logged, i.e. the date and time of the information being logged
  2. via some elements of the SD library to set the data and time of the files written to the SD card
Taking 1. above first, without knowing which revision (r?) of X.3 you are using if your look at the latest version of the datalogger (DataloggerOTG.pde) on the Google Code website (DataLoggerOTG.pde) it should be relatively easy to strip out the code that makes use of the RTCC - the contents of the setup loop and the lines within the main loop that either make use of RTCC functions or make use of curDate or curTime. Alternatively rather than stripping out the lines with curDate or curTime in the main loop it may be simplest to replace the various instances of curDate and curTime, e.g. curDate.wday, with a suitable value to simulate the values that would have been returned.

Taking item 2 above, the latest version of the SD library in X.3 takes account of the fact that the PIC32 Micro does not have a RTCC and so uses dummy values for the date and time so that all files appear to have been written at 01 Jan 2012 12:00:00.

Regards
Board = PIC32-Pinguino-OTG Rev C
OS = Linux Unbuntu 11.10 till 26 Apr 2012
OS = Linux Unbuntu 12:04 from 27 Apr 2012
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)