OLED on PIC18

Next will be to display GPS coordinates on the OLED,

>then I need to add 24LC1025 logging (same i2c bus), >and port the PIC 16F690 (IIRC) Geiger counter code >and HV controller to this, >and then add the SDcard driver... (SDcard sockets have arrived).

Wrote the logging code to 24LC1025 EEPROM, 2.5 days logging of counts per minute, time, and GPS position. Ported the GM counter code. Added Lipo battery control. Wrote the basic SDcard code, write sector and read sector works.

1kB FLASH code memory space left to write the routines to put the data and get the data from the SDcard (now test bytes only). Should be possible :-) Then few hundred years logging on SDcard..... Solar powered of course.

Dinner time again. :-)

Reply to
Jan Panteltje
Loading thread data ...

Source code PIC 18 asm:

formatting link

I took the NXP application note AN10406 "Accessing SD/MMC card using SPI on LPC2000", it is in C, and rewrote the code in PIC asm, use software SPI. That app note is very clear how to play with SD (MMC). There exists PIC 18 asm code by someone for SDcards, but it was big, used registers i already used for other things, and it did not work (probably my fault but OK), and it was FAT. SDcard spec is a bit heavy , this was faster,. As the PIC has no 512 bytes RAM free due to other stuff, I cannot pre-assemble a sector so I cheated. Memory (MMC) is cheap, so I write 32 bytes of data per 512 byte sector on the SDcard. For a 1 GB card there are 2147483648 sectors, at one record per minute that makes ( (2^32 / 4) / 1024) / (60 * 24 * 365) * 2 = 3.990015 years log time (I like wcalc -EE in Linux). And 1 GB SD cards are becoming rare....

Anyways this is just test code, but if you want SDcard logging and see [how] I use no FAT filesystem, as there is only one 'log' file, I added a menu function to print out the SDcard database in human readable form via RS232 (will take a while at 4800 Bd if the card is full), so I will likely also write a Linux command line program to access the card on the PC, dd if=/dev/sdb bs=512 count=1 skip=100 > mylog works for example. Who needs a filesystem, and I did not want to mess with FAT and other useless stuff here as it only takes away space, makes things slower, and maybe even is copyright polluted by Microsoft.

And now about speed, it seems the SDcard sort of times out after a while if you do not talk to it, as I log once per minute it looks like I have to wake up the card every time I write a record. But it works. If no card is present the system logs to an external 24LC1025 EEPROM, for a 2.5 days, so if you lose the card. The software needs to check the SDcard socket switch some day, else it slows down when no card present waiting for a response timout.

Anyways,\ Loading hex file: Program 15024 bytes at address 0x000000 ID 0 bytes at address 0x200000 Config 14 bytes at address 0x300000 EEPROM 0 bytes at address 0xf00000

I STILL have about 1 kB FLASH program memory free for little stuff that needs fixing and some code, may even shrink the code space.

Here is the test setup with a test fixture I made to test the SDcard:

formatting link

The various pots are to simulate the GM voltage, Lipo voltage, and GM pulse input, the sliding switch at the bottom selects GPS or no GPS, if no GPS the serial input is used to talk to it and set parameters, if set to GPS it reads GPS data, just a RS232 switch. These switches are tricky, they are _not_ break before make, that got me at one point, and that is why you see a series resistor in the serial output wire from the GPS module. The little chip with 8 legs walking around is a 24LC1025 that I took out of its socket for testing. The scope probe is on the PWM output for the HV driver for the GM tube, it has everything in software, even soft start. the bigger board with all the LEDs is the NOPPP PIC programmer... Top left is the Raspberry Pi driving it (every thing is developed with gpasm on it). The black box top right has a MAX232 in it as logic level to RS232 converter. That thing on the right is a keyboard, LOL, and the red wires go to a 9V adaptor that powers the noppp programmer and via an 7805 the Dealextreme EM-411 GPS module, the OLED is there too, and the table if from Ikea, the SDcard is a 1GB. Now that should cover everything. Time to start thinking about the layout of the board.

From type 'X' to dump recorded data: .... Record 34 CPM 0

15:10 UTC lat 34 d 8.1234 m N lon 7 d 55.7690 m W alt 5.0 m GPS 1 UGM 161.92 Ubatt 6.0 V ticks per minute alarm level 65535 accum 1 R accum alarm level 65537

Record 35 CPM 0

15:11 UTC lat 34 d 8.1234 m N lon 7 d 55.7690 m E alt 5.0 m GPS 1 UGM 161.92 Ubatt 6.1 V ticks per minute alarm level 65535 accum 1 R accum alarm level 65537

Record 36 CPM 0

15:12 UTC lat 34 d 8.1234 m N lon 7 d 55.7690 m E alt 5.0 m GPS 1 UGM 161.92 Ubatt 6.1 V ticks per minute alarm level 65535 accum 1 R accum alarm level 65537

Record 37 CPM 0

15:13 UTC lat 34 d 8.1234 m N lon 7 d 55.7690 m E alt 5.0 m GPS 1 UGM 161.28 Ubatt 6.0 V ticks per minute alarm level 65535 accum 1 R accum alarm level 65537

I dunno where lat 34 d 8.1234 m N, lon 7 d 55.7690 m E is, it is modified anti drone data, but it should give some idea of what -, and how it is logged.

Reply to
Jan Panteltje

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.